Skip to content

Commit 1bc8cab

Browse files
committed
[eslint config] [breaking] support eslint 8; drop eslint < 7
1 parent 37ebbba commit 1bc8cab

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

Diff for: packages/eslint-config-airbnb/package.json

+17-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
"version": "18.2.1",
44
"description": "Airbnb's ESLint config, following our styleguide",
55
"main": "index.js",
6+
"exports": {
7+
".": "./index.js",
8+
"./base": "./base.js",
9+
"./hooks": "./hooks.js",
10+
"./legacy": "./legacy.js",
11+
"./whitespace": "./whitespace.js",
12+
"./rules/react": "./rules/react.js",
13+
"./rules/react-a11y": "./rules/react-a11y.js",
14+
"./rules/react-hooks": "./rules/react-hook.js",
15+
"./package.json": "./package.json"
16+
},
617
"scripts": {
718
"prelint": "eclint check * rules/* test/*",
819
"lint": "eslint .",
@@ -64,25 +75,25 @@
6475
"babel-preset-airbnb": "^4.5.0",
6576
"babel-tape-runner": "^3.0.0",
6677
"eclint": "^2.8.1",
67-
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
68-
"eslint-find-rules": "^3.6.1",
78+
"eslint": "^7.32.0 || ^8.2.0",
79+
"eslint-find-rules": "^4.0.0",
6980
"eslint-plugin-import": "^2.25.3",
7081
"eslint-plugin-jsx-a11y": "^6.5.1",
7182
"eslint-plugin-react": "^7.27.0",
72-
"eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0",
83+
"eslint-plugin-react-hooks": "^4.3.0",
7384
"in-publish": "^2.0.1",
7485
"react": ">= 0.13.0",
7586
"safe-publish-latest": "^2.0.0",
7687
"tape": "^5.3.1"
7788
},
7889
"peerDependencies": {
79-
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
90+
"eslint": "^7.32.0 || ^8.2.0",
8091
"eslint-plugin-import": "^2.25.3",
8192
"eslint-plugin-jsx-a11y": "^6.5.1",
8293
"eslint-plugin-react": "^7.27.0",
83-
"eslint-plugin-react-hooks": "^4.3.0 || ^3 || ^2.3.0 || ^1.7.0"
94+
"eslint-plugin-react-hooks": "^4.3.0"
8495
},
8596
"engines": {
86-
"node": ">= 6"
97+
"node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0"
8798
}
8899
}

Diff for: packages/eslint-config-airbnb/rules/react.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,7 @@ module.exports = {
506506

507507
// Prevent usage of `javascript:` URLs
508508
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
509-
// TODO: enable, semver-major
510-
'react/jsx-no-script-url': ['off', [
509+
'react/jsx-no-script-url': ['error', [
511510
{
512511
name: 'Link',
513512
props: ['to'],
@@ -516,8 +515,7 @@ module.exports = {
516515

517516
// Disallow unnecessary fragments
518517
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
519-
// TODO: enable, semver-major
520-
'react/jsx-no-useless-fragment': 'off',
518+
'react/jsx-no-useless-fragment': 'error',
521519

522520
// Prevent adjacent inline elements not separated by whitespace
523521
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
@@ -526,9 +524,8 @@ module.exports = {
526524

527525
// Enforce a specific function type for function components
528526
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
529-
// TODO: enable! semver-minor, but do it in a major to be safe
530527
// TODO: investigate if setting namedComponents to expression vs declaration is problematic
531-
'react/function-component-definition': ['off', {
528+
'react/function-component-definition': ['error', {
532529
namedComponents: 'function-expression',
533530
unnamedComponents: 'function-expression',
534531
}],
@@ -539,23 +536,31 @@ module.exports = {
539536

540537
// Prevent react contexts from taking non-stable values
541538
// https://github.com/yannickcr/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md
542-
// TODO: enable, semver-minor
543-
'react/jsx-no-constructed-context-values': 'off',
539+
'react/jsx-no-constructed-context-values': 'error',
544540

545541
// Prevent creating unstable components inside components
546542
// https://github.com/yannickcr/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md
547-
// TODO: enable, semver-major
548-
'react/no-unstable-nested-components': 'off',
543+
'react/no-unstable-nested-components': 'error',
549544

550545
// Enforce that namespaces are not used in React elements
551546
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md
552-
// TODO: enable, semver-minor
553-
'react/no-namespace': 'off',
547+
'react/no-namespace': 'error',
554548

555549
// Prefer exact proptype definitions
556550
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
557-
// TODO: enable, semver-major, just in case
558-
'react/prefer-exact-props': 'off',
551+
'react/prefer-exact-props': 'error',
552+
553+
// Lifecycle methods should be methods on the prototype, not class fields
554+
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md
555+
'react/no-arrow-function-lifecycle': 'error',
556+
557+
// Prevent usage of invalid attributes
558+
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md
559+
'react/no-invalid-html-attribute': 'error',
560+
561+
// Prevent declaring unused methods of component class
562+
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md
563+
'react/no-unused-class-component-methods': 'error',
559564
},
560565

561566
settings: {

Diff for: packages/eslint-config-airbnb/test/test-react-order.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const cli = new (CLIEngine || ESLint)({
1313
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
1414
// this doesn't matter for tests
1515
'lines-between-class-members': 0,
16+
// otherwise we need some junk in our fixture code
17+
'react/no-unused-class-component-methods': 0,
1618
},
1719
});
1820

0 commit comments

Comments
 (0)