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

Commit 776390e

Browse files
author
Long Ho
committed
fix(eslint-plugin-formatjs): add missing dep
1 parent bb7dbf8 commit 776390e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2548
-1059
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"singleQuote": true,
33
"trailingComma": "es5",
44
"bracketSpacing": false,
5-
"endOfLine": "lf"
5+
"endOfLine": "lf",
6+
"arrowParens": "avoid"
67
}

package-lock.json

Lines changed: 2201 additions & 721 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,79 @@
1919
"lint": "eslint 'packages/*/src/**/*.ts?(x)' --fix",
2020
"postversion": "npm run prettier",
2121
"prepublishOnly": "npm run build",
22-
"prettier": "prettier --write 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '{src,scripts,test,tests}/**/*.js' '**/*.md'",
23-
"prettier:check": "prettier --check 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '{src,scripts,test,tests}/**/*.js' '**/*.md'",
22+
"prettier": "prettier --write 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
23+
"prettier:check": "prettier --check 'packages/*/{test,tests,src,scripts}/**/*.ts' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
2424
"test": "lerna run lint && npm run prettier:check && cross-env TS_NODE_PROJECT=tsconfig.cjs.json lerna run test"
2525
},
2626
"dependencies": {},
2727
"devDependencies": {
2828
"@babel/cli": "^7.8.4",
2929
"@babel/core": "^7.9.0",
3030
"@babel/parser": "^7.9.4",
31-
"@babel/preset-env": "^7.9.0",
31+
"@babel/preset-env": "^7.9.5",
3232
"@babel/preset-react": "^7.9.4",
3333
"@istanbuljs/nyc-config-typescript": "^1.0.1",
34-
"@microsoft/api-extractor": "^7.7.12",
35-
"@rollup/plugin-json": "^4.0.2",
34+
"@microsoft/api-extractor": "^7.7.13",
35+
"@rollup/plugin-json": "^4.0.3",
3636
"@types/benchmark": "^1.0.31",
3737
"@types/chai": "^4.2.11",
38-
"@types/eslint": "^6.1.9",
39-
"@types/estree": "0.0.42",
38+
"@types/eslint": "^6.8.0",
39+
"@types/estree": "0.0.44",
4040
"@types/estree-jsx": "0.0.0",
4141
"@types/fs-extra": "^8.1.0",
4242
"@types/jest": "^25.2.1",
4343
"@types/mocha": "^7.0.2",
44-
"@types/rimraf": "^2.0.4",
44+
"@types/rimraf": "^3.0.0",
4545
"@types/serialize-javascript": "^1.5.0",
46-
"@typescript-eslint/eslint-plugin": "^2.26.0",
47-
"@typescript-eslint/parser": "^2.26.0",
48-
"babel-jest": "^25.2.6",
46+
"@typescript-eslint/eslint-plugin": "^2.29.0",
47+
"@typescript-eslint/parser": "^2.29.0",
48+
"babel-jest": "^25.4.0",
4949
"benchmark": "^2.1.4",
5050
"chai": "^4.2.0",
5151
"cldr-core": "^36.0.0",
52-
"coveralls": "^3.0.11",
52+
"coveralls": "^3.0.14",
5353
"cross-env": "^7.0.2",
5454
"eslint": "^6.8.0",
55-
"eslint-config-prettier": "^6.10.1",
55+
"eslint-config-prettier": "^6.11.0",
5656
"eslint-plugin-import": "^2.20.2",
5757
"eslint-plugin-jest": "^23.8.2",
58-
"eslint-plugin-prettier": "^3.1.2",
58+
"eslint-plugin-prettier": "^3.1.3",
5959
"eslint-plugin-react": "^7.19.0",
6060
"fast-memoize": "^2.5.2",
6161
"fs-extra": "^9.0.0",
6262
"full-icu": "^1.3.1",
6363
"glob": "^7.1.6",
64-
"jest": "^25.2.7",
65-
"karma": "^4.4.1",
64+
"jest": "^25.4.0",
65+
"karma": "^5.0.2",
6666
"karma-chai": "^0.1.0",
6767
"karma-chrome-launcher": "^3.1.0",
68-
"karma-mocha": "^1.3.0",
69-
"karma-sauce-launcher": "^2.0.2",
68+
"karma-mocha": "^2.0.0",
69+
"karma-sauce-launcher": "^4.1.3",
7070
"lerna": "^3.20.2",
7171
"make-plural-compiler": "^5.1.0",
7272
"mocha": "^7.1.1",
7373
"mocha-lcov-reporter": "^1.3.0",
7474
"nyc": "^15.0.1",
7575
"pegjs": "^0.10.0",
7676
"pre-commit": "^1.2.2",
77-
"prettier": "^1.19.1",
77+
"prettier": "^2.0.5",
7878
"rimraf": "^3.0.2",
79-
"rollup": "^2.3.3",
79+
"rollup": "^2.7.2",
8080
"rollup-plugin-commonjs": "^10.1.0",
8181
"rollup-plugin-node-resolve": "^5.2.0",
8282
"rollup-plugin-replace": "^2.2.0",
8383
"rollup-plugin-terser": "^5.3.0",
84-
"rollup-plugin-typescript2": "^0.26.0",
84+
"rollup-plugin-typescript2": "^0.27.0",
8585
"rollup-plugin-uglify": "^6.0.4",
8686
"serialize-javascript": "^3.0.0",
87-
"source-map-support": "^0.5.16",
87+
"source-map-support": "^0.5.18",
8888
"test262-harness": "^7.3.1",
89-
"ts-jest": "^25.3.1",
89+
"ts-jest": "^25.4.0",
9090
"ts-morph": "^6.0.0",
91-
"ts-node": "^8.8.2",
91+
"ts-node": "^8.9.0",
9292
"ts-pegjs": "^0.2.6",
9393
"tslib": "^1.11.1",
94-
"typescript": "3.7"
94+
"typescript": "3.8"
9595
},
9696
"eslintConfig": {
9797
"parser": "@typescript-eslint/parser",

packages/babel-plugin-react-intl/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
],
1616
"author": "Eric Ferraiuolo <[email protected]>",
1717
"dependencies": {
18-
"@babel/core": "^7.7.2",
19-
"@babel/helper-plugin-utils": "^7.0.0",
20-
"@babel/types": "^7.9.0",
21-
"@types/babel__core": "^7.1.3",
22-
"@types/schema-utils": "^1.0.0",
18+
"@babel/core": "^7.9.0",
19+
"@babel/helper-plugin-utils": "^7.8.3",
20+
"@babel/types": "^7.9.5",
21+
"@types/babel__core": "^7.1.7",
22+
"@types/schema-utils": "^2.4.0",
2323
"fs-extra": "^9.0.0",
2424
"intl-messageformat-parser": "^5.0.0",
25-
"schema-utils": "^2.2.0"
25+
"schema-utils": "^2.6.6"
2626
},
2727
"scripts": {
2828
"clean": "rimraf lib test/fixtures/**/actual.json *.tsbuildinfo",
@@ -40,6 +40,6 @@
4040
"homepage": "https://github.com/formatjs/formatjs#readme",
4141
"gitHead": "8b0baec8eda5002715cf893274fe59782fc2d371",
4242
"devDependencies": {
43-
"json-schema-to-typescript": "^7.1.0"
43+
"json-schema-to-typescript": "^8.2.0"
4444
}
4545
}

packages/babel-plugin-react-intl/src/index.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function getICUMessageValue(
127127
return message;
128128
}
129129

130-
function evaluatePath(path: NodePath): string {
130+
function evaluatePath(path: NodePath<any>): string {
131131
const evaluated = path.evaluate();
132132
if (evaluated.confident) {
133133
return evaluated.value;
@@ -138,7 +138,7 @@ function evaluatePath(path: NodePath): string {
138138
);
139139
}
140140

141-
function getMessageDescriptorKey(path: NodePath) {
141+
function getMessageDescriptorKey(path: NodePath<any>) {
142142
if (path.isIdentifier() || path.isJSXIdentifier()) {
143143
return path.node.name;
144144
}
@@ -217,7 +217,7 @@ function evaluateMessageDescriptor(
217217

218218
function storeMessage(
219219
{id, description, defaultMessage}: MessageDescriptor,
220-
path: NodePath,
220+
path: NodePath<any>,
221221
{extractSourceLocation}: OptionsSchema,
222222
filename: string,
223223
messages: Map<string, ExtractedMessageDescriptor>
@@ -254,7 +254,7 @@ function storeMessage(
254254
}
255255

256256
function referencesImport(
257-
path: NodePath,
257+
path: NodePath<any>,
258258
mod: string,
259259
importedNames: string[]
260260
) {
@@ -289,7 +289,7 @@ function isFormatMessageDestructuring(scope: Scope) {
289289

290290
function isFormatMessageCall(
291291
callee: NodePath<Expression | V8IntrinsicIdentifier>,
292-
path: any
292+
path: NodePath<any>
293293
) {
294294
if (
295295
callee.isIdentifier() &&
@@ -309,6 +309,7 @@ function isFormatMessageCall(
309309
return (
310310
property.isIdentifier() &&
311311
property.node.name === 'formatMessage' &&
312+
!Array.isArray(object) &&
312313
// things like `intl.formatMessage`
313314
((object.isIdentifier() && object.node.name === 'intl') ||
314315
// things like `this.props.intl.formatMessage`
@@ -318,7 +319,7 @@ function isFormatMessageCall(
318319
}
319320

320321
function assertObjectExpression(
321-
path: NodePath,
322+
path: NodePath<any>,
322323
callee: NodePath<Expression | V8IntrinsicIdentifier>
323324
): path is NodePath<ObjectExpression> {
324325
if (!path || !path.isObjectExpression()) {
@@ -350,12 +351,12 @@ export default declare((api: any, options: OptionsSchema) => {
350351
* HACK: We store this in the node instance since this persists across
351352
* multiple plugin runs
352353
*/
353-
function tagAsExtracted(path: NodePath) {
354-
(path.node as any)[EXTRACTED] = true;
354+
function tagAsExtracted(path: NodePath<any>) {
355+
path.node[EXTRACTED] = true;
355356
}
356357

357-
function wasExtracted(path: NodePath) {
358-
return !!(path.node as any)[EXTRACTED];
358+
function wasExtracted(path: NodePath<any>) {
359+
return !!path.node[EXTRACTED];
359360
}
360361
return {
361362
pre() {
@@ -477,9 +478,7 @@ export default declare((api: any, options: OptionsSchema) => {
477478
) {
478479
const attributes = path
479480
.get('attributes')
480-
.filter((attr): attr is NodePath<JSXAttribute> =>
481-
attr.isJSXAttribute()
482-
);
481+
.filter(attr => attr.isJSXAttribute());
483482

484483
const descriptorPath = createMessageDescriptor(
485484
attributes.map(attr => [
@@ -516,7 +515,14 @@ export default declare((api: any, options: OptionsSchema) => {
516515
let descriptionAttr: NodePath<t.JSXAttribute> | undefined;
517516
let defaultMessageAttr: NodePath<t.JSXAttribute> | undefined;
518517
for (const attr of attributes) {
519-
switch (getMessageDescriptorKey(attr.get('name'))) {
518+
if (!attr.isJSXAttribute()) {
519+
continue;
520+
}
521+
switch (
522+
getMessageDescriptorKey(
523+
(attr as NodePath<JSXAttribute>).get('name')
524+
)
525+
) {
520526
case 'description':
521527
descriptionAttr = attr;
522528
break;
@@ -644,10 +650,12 @@ export default declare((api: any, options: OptionsSchema) => {
644650
if (isSingularMessagesDeclMacro(callee, moduleSourceName)) {
645651
processMessageObject(messagesObj as NodePath<ObjectExpression>);
646652
} else {
647-
messagesObj
648-
.get('properties')
649-
.map(prop => prop.get('value') as NodePath<ObjectExpression>)
650-
.forEach(processMessageObject);
653+
const properties = messagesObj.get('properties');
654+
if (Array.isArray(properties)) {
655+
properties
656+
.map(prop => prop.get('value') as NodePath<ObjectExpression>)
657+
.forEach(processMessageObject);
658+
}
651659
}
652660
}
653661
}
@@ -665,7 +673,7 @@ export default declare((api: any, options: OptionsSchema) => {
665673
});
666674

667675
function isMultipleMessagesDeclMacro(
668-
callee: NodePath,
676+
callee: NodePath<any>,
669677
moduleSourceName: string
670678
) {
671679
return (
@@ -675,7 +683,7 @@ function isMultipleMessagesDeclMacro(
675683
}
676684

677685
function isSingularMessagesDeclMacro(
678-
callee: NodePath,
686+
callee: NodePath<any>,
679687
moduleSourceName: string
680688
) {
681689
return (

packages/babel-plugin-react-intl/test/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('options', () => {
6565
// Check message output
6666
expect(require(join(fixtureDir, 'actual.json'))).toMatchSnapshot();
6767
});
68-
it('outputEmptyJson should output empty files', function() {
68+
it('outputEmptyJson should output empty files', function () {
6969
const fixtureDir = join(fixturesDir, 'outputEmptyJson');
7070

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

8484
const actual = transform(join(fixtureDir, 'actual.js'), {})!.code;

packages/cli/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@
4141
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest"
4242
},
4343
"dependencies": {
44-
"@babel/plugin-proposal-class-properties": "^7.5.5",
44+
"@babel/plugin-proposal-class-properties": "^7.8.3",
4545
"@babel/plugin-proposal-optional-chaining": "7",
46-
"@babel/preset-env": "^7.6.0",
47-
"@babel/preset-typescript": "^7.6.0",
48-
"@types/babel__core": "^7.1.3",
46+
"@babel/preset-env": "^7.9.5",
47+
"@babel/preset-typescript": "^7.9.0",
48+
"@types/babel__core": "^7.1.7",
4949
"@types/loader-utils": "^1.1.3",
50-
"@types/lodash": "^4.14.138",
51-
"babel-plugin-const-enum": "^0.0.5",
50+
"@types/lodash": "^4.14.150",
51+
"babel-plugin-const-enum": "^1.0.1",
5252
"babel-plugin-react-intl": "^7.5.1",
5353
"commander": "5.0.0",
5454
"fs-extra": "^9.0.0",
5555
"glob": "^7.1.6",
5656
"loader-utils": "^2.0.0",
5757
"lodash": "^4.17.15",
58-
"loud-rejection": "^2.1.0"
58+
"loud-rejection": "^2.2.0"
5959
},
6060
"bugs": {
6161
"url": "https://github.com/formatjs/formatjs/issues"

packages/eslint-plugin-formatjs/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
"homepage": "https://github.com/formatjs/formatjs#readme",
3030
"dependencies": {
3131
"@types/emoji-regex": "^8.0.0",
32-
"emoji-regex": "^8.0.0",
32+
"emoji-regex": "^9.0.0",
33+
"@typescript-eslint/typescript-estree": "^2.29.0",
3334
"intl-messageformat-parser": "^5.0.0"
3435
},
3536
"peerDependencies": {
36-
"eslint": "^6.0.0"
37+
"eslint": "^6.8.0"
3738
}
3839
}

packages/eslint-plugin-formatjs/src/rules/no-multiple-whitespaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function checkNode(
2727
message: 'Multiple consecutive whitespaces are not allowed',
2828
};
2929
if (messageNode.type === 'Literal' && messageNode.raw) {
30-
reportObject.fix = function(fixer) {
30+
reportObject.fix = function (fixer) {
3131
return fixer.replaceText(
3232
messageNode as Node,
3333
messageNode.raw!.replace(MULTIPLE_SPACES, ' ')

packages/formatjs-extract-cldr-data/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"@formatjs/intl-utils": "^2.2.2",
2222
"@types/glob": "^7.1.1",
23-
"@types/lodash": "^4.14.138",
23+
"@types/lodash": "^4.14.150",
2424
"cldr-core": "^36.0.0",
2525
"cldr-dates-full": "^36.0.0",
2626
"cldr-localenames-full": "^36.0.0",

packages/formatjs-extract-cldr-data/src/extract-relative.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function transformFieldData(data: Fields['week']): FieldData {
9393
future: {},
9494
past: {},
9595
};
96-
Object.keys(data).forEach(function(key) {
96+
Object.keys(data).forEach(function (key) {
9797
const type = key.match(/^(relative|relativeTime)-type-(.+)$/) || [];
9898

9999
switch (type[1]) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import extractCurrencies from '../src/extract-currencies';
22

3-
describe('extract-currencies', function() {
4-
it('should be able to extract en', function() {
3+
describe('extract-currencies', function () {
4+
it('should be able to extract en', function () {
55
expect(extractCurrencies(['en'])).toMatchSnapshot();
66
});
7-
it('should be able to extract uk', function() {
7+
it('should be able to extract uk', function () {
88
expect(extractCurrencies(['uk'])).toMatchSnapshot();
99
});
1010
});

0 commit comments

Comments
 (0)