diff --git a/packages/eslint-config-airbnb-base/package.json b/packages/eslint-config-airbnb-base/package.json index ff6a8764a7..196f78c2e1 100644 --- a/packages/eslint-config-airbnb-base/package.json +++ b/packages/eslint-config-airbnb-base/package.json @@ -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" diff --git a/packages/eslint-config-airbnb/package.json b/packages/eslint-config-airbnb/package.json index 929110f7e7..eba28173ea 100644 --- a/packages/eslint-config-airbnb/package.json +++ b/packages/eslint-config-airbnb/package.json @@ -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 .", @@ -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" } } diff --git a/packages/eslint-config-airbnb/rules/react.js b/packages/eslint-config-airbnb/rules/react.js index ca16948432..71230fac71 100644 --- a/packages/eslint-config-airbnb/rules/react.js +++ b/packages/eslint-config-airbnb/rules/react.js @@ -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'], @@ -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 @@ -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', }], @@ -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: { diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index a394fe1c3c..dca8b73e8a 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -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, }, });