Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
fix(eslint-plugin-formatjs): add missing dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Ho committed Apr 24, 2020
1 parent bb7dbf8 commit 776390e
Show file tree
Hide file tree
Showing 57 changed files with 2,548 additions and 1,059 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": false,
"endOfLine": "lf"
"endOfLine": "lf",
"arrowParens": "avoid"
}
2,922 changes: 2,201 additions & 721 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,79 +19,79 @@
"lint": "eslint 'packages/*/src/**/*.ts?(x)' --fix",
"postversion": "npm run prettier",
"prepublishOnly": "npm run build",
"prettier": "prettier --write 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '{src,scripts,test,tests}/**/*.js' '**/*.md'",
"prettier:check": "prettier --check 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '{src,scripts,test,tests}/**/*.js' '**/*.md'",
"prettier": "prettier --write 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
"prettier:check": "prettier --check 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
"test": "lerna run lint && npm run prettier:check && cross-env TS_NODE_PROJECT=tsconfig.cjs.json lerna run test"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/parser": "^7.9.4",
"@babel/preset-env": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.9.4",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-extractor": "^7.7.12",
"@rollup/plugin-json": "^4.0.2",
"@microsoft/api-extractor": "^7.7.13",
"@rollup/plugin-json": "^4.0.3",
"@types/benchmark": "^1.0.31",
"@types/chai": "^4.2.11",
"@types/eslint": "^6.1.9",
"@types/estree": "0.0.42",
"@types/eslint": "^6.8.0",
"@types/estree": "0.0.44",
"@types/estree-jsx": "0.0.0",
"@types/fs-extra": "^8.1.0",
"@types/jest": "^25.2.1",
"@types/mocha": "^7.0.2",
"@types/rimraf": "^2.0.4",
"@types/rimraf": "^3.0.0",
"@types/serialize-javascript": "^1.5.0",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"babel-jest": "^25.2.6",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"babel-jest": "^25.4.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"cldr-core": "^36.0.0",
"coveralls": "^3.0.11",
"coveralls": "^3.0.14",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.19.0",
"fast-memoize": "^2.5.2",
"fs-extra": "^9.0.0",
"full-icu": "^1.3.1",
"glob": "^7.1.6",
"jest": "^25.2.7",
"karma": "^4.4.1",
"jest": "^25.4.0",
"karma": "^5.0.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"karma-sauce-launcher": "^2.0.2",
"karma-mocha": "^2.0.0",
"karma-sauce-launcher": "^4.1.3",
"lerna": "^3.20.2",
"make-plural-compiler": "^5.1.0",
"mocha": "^7.1.1",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^15.0.1",
"pegjs": "^0.10.0",
"pre-commit": "^1.2.2",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.3.3",
"rollup": "^2.7.2",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.26.0",
"rollup-plugin-typescript2": "^0.27.0",
"rollup-plugin-uglify": "^6.0.4",
"serialize-javascript": "^3.0.0",
"source-map-support": "^0.5.16",
"source-map-support": "^0.5.18",
"test262-harness": "^7.3.1",
"ts-jest": "^25.3.1",
"ts-jest": "^25.4.0",
"ts-morph": "^6.0.0",
"ts-node": "^8.8.2",
"ts-node": "^8.9.0",
"ts-pegjs": "^0.2.6",
"tslib": "^1.11.1",
"typescript": "3.7"
"typescript": "3.8"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
Expand Down
14 changes: 7 additions & 7 deletions packages/babel-plugin-react-intl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
],
"author": "Eric Ferraiuolo <[email protected]>",
"dependencies": {
"@babel/core": "^7.7.2",
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/types": "^7.9.0",
"@types/babel__core": "^7.1.3",
"@types/schema-utils": "^1.0.0",
"@babel/core": "^7.9.0",
"@babel/helper-plugin-utils": "^7.8.3",
"@babel/types": "^7.9.5",
"@types/babel__core": "^7.1.7",
"@types/schema-utils": "^2.4.0",
"fs-extra": "^9.0.0",
"intl-messageformat-parser": "^5.0.0",
"schema-utils": "^2.2.0"
"schema-utils": "^2.6.6"
},
"scripts": {
"clean": "rimraf lib test/fixtures/**/actual.json *.tsbuildinfo",
Expand All @@ -40,6 +40,6 @@
"homepage": "https://github.com/formatjs/formatjs#readme",
"gitHead": "8b0baec8eda5002715cf893274fe59782fc2d371",
"devDependencies": {
"json-schema-to-typescript": "^7.1.0"
"json-schema-to-typescript": "^8.2.0"
}
}
48 changes: 28 additions & 20 deletions packages/babel-plugin-react-intl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function getICUMessageValue(
return message;
}

function evaluatePath(path: NodePath): string {
function evaluatePath(path: NodePath<any>): string {
const evaluated = path.evaluate();
if (evaluated.confident) {
return evaluated.value;
Expand All @@ -138,7 +138,7 @@ function evaluatePath(path: NodePath): string {
);
}

function getMessageDescriptorKey(path: NodePath) {
function getMessageDescriptorKey(path: NodePath<any>) {
if (path.isIdentifier() || path.isJSXIdentifier()) {
return path.node.name;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ function evaluateMessageDescriptor(

function storeMessage(
{id, description, defaultMessage}: MessageDescriptor,
path: NodePath,
path: NodePath<any>,
{extractSourceLocation}: OptionsSchema,
filename: string,
messages: Map<string, ExtractedMessageDescriptor>
Expand Down Expand Up @@ -254,7 +254,7 @@ function storeMessage(
}

function referencesImport(
path: NodePath,
path: NodePath<any>,
mod: string,
importedNames: string[]
) {
Expand Down Expand Up @@ -289,7 +289,7 @@ function isFormatMessageDestructuring(scope: Scope) {

function isFormatMessageCall(
callee: NodePath<Expression | V8IntrinsicIdentifier>,
path: any
path: NodePath<any>
) {
if (
callee.isIdentifier() &&
Expand All @@ -309,6 +309,7 @@ function isFormatMessageCall(
return (
property.isIdentifier() &&
property.node.name === 'formatMessage' &&
!Array.isArray(object) &&
// things like `intl.formatMessage`
((object.isIdentifier() && object.node.name === 'intl') ||
// things like `this.props.intl.formatMessage`
Expand All @@ -318,7 +319,7 @@ function isFormatMessageCall(
}

function assertObjectExpression(
path: NodePath,
path: NodePath<any>,
callee: NodePath<Expression | V8IntrinsicIdentifier>
): path is NodePath<ObjectExpression> {
if (!path || !path.isObjectExpression()) {
Expand Down Expand Up @@ -350,12 +351,12 @@ export default declare((api: any, options: OptionsSchema) => {
* HACK: We store this in the node instance since this persists across
* multiple plugin runs
*/
function tagAsExtracted(path: NodePath) {
(path.node as any)[EXTRACTED] = true;
function tagAsExtracted(path: NodePath<any>) {
path.node[EXTRACTED] = true;
}

function wasExtracted(path: NodePath) {
return !!(path.node as any)[EXTRACTED];
function wasExtracted(path: NodePath<any>) {
return !!path.node[EXTRACTED];
}
return {
pre() {
Expand Down Expand Up @@ -477,9 +478,7 @@ export default declare((api: any, options: OptionsSchema) => {
) {
const attributes = path
.get('attributes')
.filter((attr): attr is NodePath<JSXAttribute> =>
attr.isJSXAttribute()
);
.filter(attr => attr.isJSXAttribute());

const descriptorPath = createMessageDescriptor(
attributes.map(attr => [
Expand Down Expand Up @@ -516,7 +515,14 @@ export default declare((api: any, options: OptionsSchema) => {
let descriptionAttr: NodePath<t.JSXAttribute> | undefined;
let defaultMessageAttr: NodePath<t.JSXAttribute> | undefined;
for (const attr of attributes) {
switch (getMessageDescriptorKey(attr.get('name'))) {
if (!attr.isJSXAttribute()) {
continue;
}
switch (
getMessageDescriptorKey(
(attr as NodePath<JSXAttribute>).get('name')
)
) {
case 'description':
descriptionAttr = attr;
break;
Expand Down Expand Up @@ -644,10 +650,12 @@ export default declare((api: any, options: OptionsSchema) => {
if (isSingularMessagesDeclMacro(callee, moduleSourceName)) {
processMessageObject(messagesObj as NodePath<ObjectExpression>);
} else {
messagesObj
.get('properties')
.map(prop => prop.get('value') as NodePath<ObjectExpression>)
.forEach(processMessageObject);
const properties = messagesObj.get('properties');
if (Array.isArray(properties)) {
properties
.map(prop => prop.get('value') as NodePath<ObjectExpression>)
.forEach(processMessageObject);
}
}
}
}
Expand All @@ -665,7 +673,7 @@ export default declare((api: any, options: OptionsSchema) => {
});

function isMultipleMessagesDeclMacro(
callee: NodePath,
callee: NodePath<any>,
moduleSourceName: string
) {
return (
Expand All @@ -675,7 +683,7 @@ function isMultipleMessagesDeclMacro(
}

function isSingularMessagesDeclMacro(
callee: NodePath,
callee: NodePath<any>,
moduleSourceName: string
) {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-react-intl/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('options', () => {
// Check message output
expect(require(join(fixtureDir, 'actual.json'))).toMatchSnapshot();
});
it('outputEmptyJson should output empty files', function() {
it('outputEmptyJson should output empty files', function () {
const fixtureDir = join(fixturesDir, 'outputEmptyJson');

const actual = transform(join(fixtureDir, 'actual.js'), {
Expand All @@ -78,7 +78,7 @@ describe('options', () => {
// Check message output
expect(require(join(fixtureDir, 'actual.json'))).toMatchSnapshot();
});
it('without outputEmptyJson should output empty files', function() {
it('without outputEmptyJson should output empty files', function () {
const fixtureDir = join(fixturesDir, 'empty');

const actual = transform(join(fixtureDir, 'actual.js'), {})!.code;
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest"
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-optional-chaining": "7",
"@babel/preset-env": "^7.6.0",
"@babel/preset-typescript": "^7.6.0",
"@types/babel__core": "^7.1.3",
"@babel/preset-env": "^7.9.5",
"@babel/preset-typescript": "^7.9.0",
"@types/babel__core": "^7.1.7",
"@types/loader-utils": "^1.1.3",
"@types/lodash": "^4.14.138",
"babel-plugin-const-enum": "^0.0.5",
"@types/lodash": "^4.14.150",
"babel-plugin-const-enum": "^1.0.1",
"babel-plugin-react-intl": "^7.5.1",
"commander": "5.0.0",
"fs-extra": "^9.0.0",
"glob": "^7.1.6",
"loader-utils": "^2.0.0",
"lodash": "^4.17.15",
"loud-rejection": "^2.1.0"
"loud-rejection": "^2.2.0"
},
"bugs": {
"url": "https://github.com/formatjs/formatjs/issues"
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-plugin-formatjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"homepage": "https://github.com/formatjs/formatjs#readme",
"dependencies": {
"@types/emoji-regex": "^8.0.0",
"emoji-regex": "^8.0.0",
"emoji-regex": "^9.0.0",
"@typescript-eslint/typescript-estree": "^2.29.0",
"intl-messageformat-parser": "^5.0.0"
},
"peerDependencies": {
"eslint": "^6.0.0"
"eslint": "^6.8.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function checkNode(
message: 'Multiple consecutive whitespaces are not allowed',
};
if (messageNode.type === 'Literal' && messageNode.raw) {
reportObject.fix = function(fixer) {
reportObject.fix = function (fixer) {
return fixer.replaceText(
messageNode as Node,
messageNode.raw!.replace(MULTIPLE_SPACES, ' ')
Expand Down
2 changes: 1 addition & 1 deletion packages/formatjs-extract-cldr-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@formatjs/intl-utils": "^2.2.2",
"@types/glob": "^7.1.1",
"@types/lodash": "^4.14.138",
"@types/lodash": "^4.14.150",
"cldr-core": "^36.0.0",
"cldr-dates-full": "^36.0.0",
"cldr-localenames-full": "^36.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function transformFieldData(data: Fields['week']): FieldData {
future: {},
past: {},
};
Object.keys(data).forEach(function(key) {
Object.keys(data).forEach(function (key) {
const type = key.match(/^(relative|relativeTime)-type-(.+)$/) || [];

switch (type[1]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import extractCurrencies from '../src/extract-currencies';

describe('extract-currencies', function() {
it('should be able to extract en', function() {
describe('extract-currencies', function () {
it('should be able to extract en', function () {
expect(extractCurrencies(['en'])).toMatchSnapshot();
});
it('should be able to extract uk', function() {
it('should be able to extract uk', function () {
expect(extractCurrencies(['uk'])).toMatchSnapshot();
});
});
Loading

0 comments on commit 776390e

Please sign in to comment.