Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint config] [base] [breaking] support eslint 8; drop eslint < 7 #2498

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"@babel/runtime": "^7.16.0",
"@babel/runtime": "^7.16.3",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-import": "^2.25.3",
"in-publish": "^2.0.1",
"safe-publish-latest": "^2.0.0",
"tape": "^5.3.1"
},
"peerDependencies": {
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.25.2"
"eslint-plugin-import": "^2.25.3"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
Expand Down
41 changes: 26 additions & 15 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
"version": "18.2.1",
"description": "Airbnb's ESLint config, following our styleguide",
"main": "index.js",
"exports": {
".": "./index.js",
"./base": "./base.js",
"./hooks": "./hooks.js",
"./legacy": "./legacy.js",
"./whitespace": "./whitespace.js",
"./rules/react": "./rules/react.js",
"./rules/react-a11y": "./rules/react-a11y.js",
"./rules/react-hooks": "./rules/react-hook.js",
"./package.json": "./package.json"
},
"scripts": {
"prelint": "eclint check * rules/* test/*",
"lint": "eslint .",
Expand Down Expand Up @@ -55,34 +66,34 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-base": "^15.0.0",
"object.assign": "^4.1.2",
"object.entries": "^1.1.5"
},
"devDependencies": {
"@babel/runtime": "^7.16.0",
"@babel/runtime": "^7.16.3",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-find-rules": "^3.6.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.0.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"in-publish": "^2.0.1",
"react": ">= 0.13.0",
"safe-publish-latest": "^1.1.4",
"safe-publish-latest": "^2.0.0",
"tape": "^5.3.1"
},
"peerDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.0.1 || ^3 || ^2.3.0 || ^1.7.0"
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0"
},
"engines": {
"node": ">= 6"
"node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0"
}
}
33 changes: 19 additions & 14 deletions packages/eslint-config-airbnb/rules/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,7 @@ module.exports = {

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

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

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

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

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

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

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

// Prefer exact proptype definitions
// https://github.com/yannickcr/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
// TODO: enable, semver-major, just in case
'react/prefer-exact-props': 'off',
'react/prefer-exact-props': 'error',

// Lifecycle methods should be methods on the prototype, not class fields
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md
'react/no-arrow-function-lifecycle': 'error',

// Prevent usage of invalid attributes
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md
'react/no-invalid-html-attribute': 'error',

// Prevent declaring unused methods of component class
// https://github.com/yannickcr/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md
'react/no-unused-class-component-methods': 'error',
},

settings: {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-airbnb/test/test-react-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const cli = new (CLIEngine || ESLint)({
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
// this doesn't matter for tests
'lines-between-class-members': 0,
// otherwise we need some junk in our fixture code
'react/no-unused-class-component-methods': 0,
},
});

Expand Down