Skip to content

Commit d10f20a

Browse files
authored
upgrade eslint (#3642)
1 parent a32c05e commit d10f20a

File tree

5 files changed

+836
-483
lines changed

5 files changed

+836
-483
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rulesDirPlugin.RULES_DIR = './bin';
77
module.exports = {
88
plugins: ['react', 'rulesdir', 'jsx-a11y', 'react-hooks', 'jest', 'monorepo', 'eslint-plugin-rsp-rules'],
99
extends: ['eslint:recommended'],
10-
parser: 'babel-eslint',
10+
parser: '@babel/eslint-parser',
1111
parserOptions: {
1212
ecmaFeatures: {
1313
'legacyDecorators': true
@@ -149,7 +149,7 @@ module.exports = {
149149
'react/no-did-update-set-state': ERROR,
150150
'react/no-multi-comp': OFF,
151151
'react/no-set-state': OFF,
152-
'react/no-unknown-property': ERROR,
152+
'react/no-unknown-property': [ERROR, {ignore: ['prefix']}],
153153
'react/react-in-jsx-scope': ERROR,
154154
'react/require-extension': OFF,
155155
'react/jsx-equals-spacing': ERROR,

bin/sort-imports.js

Lines changed: 67 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,77 +10,82 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
module.exports = function (context) {
14-
const sourceCode = context.getSourceCode();
15-
let previousDeclaration = null;
13+
module.exports = {
14+
meta: {
15+
fixable: 'code'
16+
},
17+
create: function (context) {
18+
const sourceCode = context.getSourceCode();
19+
let previousDeclaration = null;
1620

17-
/**
18-
* Gets the local name of the first imported module.
19-
* @param {ASTNode} node - the ImportDeclaration node.
20-
* @returns {?string} the local name of the first imported module.
21-
*/
22-
function getFirstLocalMemberName(node) {
23-
if (node.specifiers[0]) {
24-
return node.specifiers[0].local.name.toLowerCase();
25-
}
26-
return null;
21+
/**
22+
* Gets the local name of the first imported module.
23+
* @param {ASTNode} node - the ImportDeclaration node.
24+
* @returns {?string} the local name of the first imported module.
25+
*/
26+
function getFirstLocalMemberName(node) {
27+
if (node.specifiers[0]) {
28+
return node.specifiers[0].local.name.toLowerCase();
29+
}
30+
return null;
2731

28-
}
32+
}
2933

30-
return {
31-
ImportDeclaration(node) {
32-
if (previousDeclaration) {
33-
let currentLocalMemberName = getFirstLocalMemberName(node),
34-
previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
34+
return {
35+
ImportDeclaration(node) {
36+
if (previousDeclaration) {
37+
let currentLocalMemberName = getFirstLocalMemberName(node),
38+
previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
3539

36-
if (previousLocalMemberName &&
37-
currentLocalMemberName &&
38-
currentLocalMemberName < previousLocalMemberName
39-
) {
40-
context.report({
41-
node,
42-
message: "Imports should be sorted alphabetically."
43-
});
40+
if (previousLocalMemberName &&
41+
currentLocalMemberName &&
42+
currentLocalMemberName < previousLocalMemberName
43+
) {
44+
context.report({
45+
node,
46+
message: 'Imports should be sorted alphabetically.'
47+
});
48+
}
4449
}
45-
}
4650

47-
const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier");
48-
const getSortableName = specifier => specifier.local.name.toLowerCase();
49-
const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
51+
const importSpecifiers = node.specifiers.filter(specifier => specifier.type === 'ImportSpecifier');
52+
const getSortableName = specifier => specifier.local.name.toLowerCase();
53+
const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
5054

51-
if (firstUnsortedIndex !== -1) {
52-
context.report({
53-
node: importSpecifiers[firstUnsortedIndex],
54-
message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
55-
data: { memberName: importSpecifiers[firstUnsortedIndex].local.name },
56-
fix(fixer) {
57-
return fixer.replaceTextRange(
58-
[importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]],
59-
importSpecifiers
60-
// Clone the importSpecifiers array to avoid mutating it
61-
.slice()
55+
if (firstUnsortedIndex !== -1) {
56+
context.report({
57+
node: importSpecifiers[firstUnsortedIndex],
58+
message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
59+
data: {memberName: importSpecifiers[firstUnsortedIndex].local.name},
60+
fix(fixer) {
61+
return fixer.replaceTextRange(
62+
[importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]],
63+
importSpecifiers
64+
// Clone the importSpecifiers array to avoid mutating it
65+
.slice()
6266

63-
// Sort the array into the desired order
64-
.sort((specifierA, specifierB) => {
65-
const aName = getSortableName(specifierA);
66-
const bName = getSortableName(specifierB);
67-
return aName > bName ? 1 : -1;
68-
})
67+
// Sort the array into the desired order
68+
.sort((specifierA, specifierB) => {
69+
const aName = getSortableName(specifierA);
70+
const bName = getSortableName(specifierB);
71+
return aName > bName ? 1 : -1;
72+
})
6973

70-
// Build a string out of the sorted list of import specifiers and the text between the originals
71-
.reduce((sourceText, specifier, index) => {
72-
const textAfterSpecifier = index === importSpecifiers.length - 1
73-
? ""
74-
: sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
74+
// Build a string out of the sorted list of import specifiers and the text between the originals
75+
.reduce((sourceText, specifier, index) => {
76+
const textAfterSpecifier = index === importSpecifiers.length - 1
77+
? ''
78+
: sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
7579

76-
return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
77-
}, "")
78-
);
79-
}
80-
});
81-
}
80+
return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
81+
}, '')
82+
);
83+
}
84+
});
85+
}
8286

83-
previousDeclaration = node;
84-
}
85-
};
87+
previousDeclaration = node;
88+
}
89+
};
90+
}
8691
};

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@actions/github": "^1.1.0",
5555
"@babel/cli": "^7.12.10",
5656
"@babel/core": "^7.12.10",
57+
"@babel/eslint-parser": "^7.19.1",
5758
"@babel/node": "^7.12.10",
5859
"@babel/plugin-proposal-decorators": "^7.12.1",
5960
"@babel/plugin-syntax-decorators": "^7.12.1",
@@ -90,11 +91,10 @@
9091
"@testing-library/user-event": "^12.1.3",
9192
"@types/react": "^17.0.37",
9293
"@types/storybook__react": "^5.2.1",
93-
"@typescript-eslint/eslint-plugin": "^4.3.0",
94-
"@typescript-eslint/parser": "^4.3.0",
94+
"@typescript-eslint/eslint-plugin": "^5.40.0",
95+
"@typescript-eslint/parser": "^5.40.0",
9596
"autoprefixer": "^9.6.0",
9697
"axe-core": "^3.0.3",
97-
"babel-eslint": "^10.1.0",
9898
"babel-plugin-istanbul": "^6.0.0",
9999
"babel-plugin-macros": "^3.0.1",
100100
"babel-plugin-react-remove-properties": "^0.3.0",
@@ -110,15 +110,15 @@
110110
"cross-spawn": "^7.0.3",
111111
"diff": "^5.1.0",
112112
"delta-e": "^0.0.8",
113-
"eslint": "^7.10.0",
114-
"eslint-plugin-import": "^2.22.1",
115-
"eslint-plugin-jest": "^24.0.2",
116-
"eslint-plugin-jsdoc": "^30.6.2",
117-
"eslint-plugin-jsx-a11y": "^6.3.1",
113+
"eslint": "^8.25.0",
114+
"eslint-plugin-import": "^2.26.0",
115+
"eslint-plugin-jest": "^27.1.1",
116+
"eslint-plugin-jsdoc": "^39.3.6",
117+
"eslint-plugin-jsx-a11y": "^6.6.1",
118118
"eslint-plugin-monorepo": "^0.3.2",
119-
"eslint-plugin-react": "^7.21.2",
120-
"eslint-plugin-react-hooks": "^4.1.2",
121-
"eslint-plugin-rulesdir": "^0.1.0",
119+
"eslint-plugin-react": "^7.31.10",
120+
"eslint-plugin-react-hooks": "^4.6.0",
121+
"eslint-plugin-rulesdir": "^0.2.1",
122122
"fast-check": "^2.19.0",
123123
"fast-glob": "^3.1.0",
124124
"fs-extra": "^10.0.0",

packages/@react-types/shared/src/events.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import {
1919
// Event bubbling can be problematic in real-world applications, so the default for React Spectrum components
2020
// is not to propagate. This can be overridden by calling continuePropagation() on the event.
2121
export type BaseEvent<T extends SyntheticEvent> = T & {
22-
/** @deprecated Use continuePropagation. */
22+
/**
23+
* Use continuePropagation.
24+
* @deprecated */
2325
stopPropagation(): void,
2426
continuePropagation(): void
2527
}

0 commit comments

Comments
 (0)