-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Adding support for eslint 9 #3244
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
Open
j-castellanos
wants to merge
3
commits into
airbnb:master
Choose a base branch
from
j-castellanos:jc/eslint-9-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+349
−28
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const base = require('./flat'); | ||
|
|
||
| module.exports = [ | ||
| ...base, | ||
| { rules: { 'comma-dangle': 'off', 'max-len': 'off' } }, | ||
| { | ||
| files: ['test/**'], | ||
| rules: { | ||
| 'no-shadow': 'off', | ||
| 'id-length': ['error', { min: 2, properties: 'never', exceptions: ['t'] }], | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| const globals = require('globals'); | ||
| const importPlugin = require('eslint-plugin-import'); | ||
|
|
||
| const bestPractices = require('./rules/best-practices'); | ||
| const errors = require('./rules/errors'); | ||
| const es6 = require('./rules/es6'); | ||
| const imports = require('./rules/imports'); | ||
| const node = require('./rules/node'); | ||
| const strict = require('./rules/strict'); | ||
| const style = require('./rules/style'); | ||
| const variables = require('./rules/variables'); | ||
|
|
||
| module.exports = [ | ||
| { | ||
| languageOptions: { | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| globals: { | ||
| ...globals.es2015, | ||
| ...globals.node, | ||
| }, | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| generators: false, | ||
| objectLiteralDuplicateProperties: false, | ||
| }, | ||
| }, | ||
| }, | ||
| plugins: { | ||
| import: importPlugin, | ||
| }, | ||
| settings: imports.settings, | ||
| rules: { | ||
| ...bestPractices.rules, | ||
| ...errors.rules, | ||
| ...node.rules, | ||
| ...style.rules, | ||
| ...variables.rules, | ||
| ...es6.rules, | ||
| ...imports.rules, | ||
| ...strict.rules, | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| "./rules/imports": "./rules/imports.js", | ||
| "./rules/strict": "./rules/strict.js", | ||
| "./rules/variables": "./rules/variables.js", | ||
| "./flat": "./flat.js", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "scripts": { | ||
|
|
@@ -72,21 +73,22 @@ | |
| "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.1.0", | ||
| "eslint": "^7.32.0 || ^8.2.0 || ^9.0.0", | ||
| "eslint-find-rules": "^5.0.0", | ||
| "eslint-plugin-import": "^2.30.0", | ||
| "in-publish": "^2.0.1", | ||
| "safe-publish-latest": "^2.0.0", | ||
| "tape": "^5.9.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "eslint": "^7.32.0 || ^8.2.0", | ||
| "eslint": "^7.32.0 || ^8.2.0 || ^9.0.0", | ||
| "eslint-plugin-import": "^2.30.0" | ||
| }, | ||
| "engines": { | ||
| "node": "^10.12.0 || >=12.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "confusing-browser-globals": "^1.0.11" | ||
| "confusing-browser-globals": "^1.0.11", | ||
| "globals": "^15.14.0" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/eslint-config-airbnb-base/test/test-flat-parity.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import test from 'tape'; | ||
|
|
||
| import flatConfig from '../flat'; | ||
|
|
||
| import bestPractices from '../rules/best-practices'; | ||
| import errors from '../rules/errors'; | ||
| import es6 from '../rules/es6'; | ||
| import imports from '../rules/imports'; | ||
| import node from '../rules/node'; | ||
| import strict from '../rules/strict'; | ||
| import style from '../rules/style'; | ||
| import variables from '../rules/variables'; | ||
|
|
||
| test('flat config includes all rules from rule files', (t) => { | ||
| // The flat config is an array with one config object | ||
| t.ok(Array.isArray(flatConfig), 'flat config is an array'); | ||
| t.equal(flatConfig.length, 1, 'flat config has one element'); | ||
|
|
||
| const flatRules = flatConfig[0].rules; | ||
|
|
||
| // Merge rules in the same order as flat.js | ||
| const expectedRules = { | ||
| ...bestPractices.rules, | ||
| ...errors.rules, | ||
| ...node.rules, | ||
| ...style.rules, | ||
| ...variables.rules, | ||
| ...es6.rules, | ||
| ...imports.rules, | ||
| ...strict.rules, | ||
| }; | ||
|
|
||
| const flatKeys = Object.keys(flatRules).sort(); | ||
| const expectedKeys = Object.keys(expectedRules).sort(); | ||
|
|
||
| t.deepEqual(flatKeys, expectedKeys, 'flat config has the same rule keys as combined rule files'); | ||
|
|
||
| expectedKeys.forEach((key) => { | ||
| t.deepEqual(flatRules[key], expectedRules[key], `rule "${key}" has matching config`); | ||
| }); | ||
|
|
||
| t.end(); | ||
| }); | ||
|
|
||
| test('flat config has required plugins and settings', (t) => { | ||
| const config = flatConfig[0]; | ||
|
|
||
| t.ok(config.plugins.import, 'import plugin is present'); | ||
| t.ok(config.settings, 'settings are present'); | ||
| t.ok(config.languageOptions, 'languageOptions are present'); | ||
| t.equal(config.languageOptions.sourceType, 'module', 'sourceType is module'); | ||
|
|
||
| t.end(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const airbnb = require('./flat'); | ||
|
|
||
| module.exports = [ | ||
| ...airbnb, | ||
| { rules: { 'comma-dangle': 'off' } }, | ||
| { | ||
| files: ['test/**'], | ||
| rules: { | ||
| 'no-shadow': 'off', | ||
| 'id-length': ['error', { min: 2, properties: 'never', exceptions: ['t'] }], | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = require('eslint-config-airbnb-base/flat'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const reactHooksPlugin = require('eslint-plugin-react-hooks'); | ||
|
|
||
| const reactHooks = require('./rules/react-hooks'); | ||
|
|
||
| module.exports = [ | ||
| { | ||
| files: ['**/*.{js,jsx,mjs,cjs}'], | ||
| plugins: { | ||
| 'react-hooks': reactHooksPlugin, | ||
| }, | ||
| languageOptions: { | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| }, | ||
| rules: reactHooks.rules, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| const reactPlugin = require('eslint-plugin-react'); | ||
| const jsxA11yPlugin = require('eslint-plugin-jsx-a11y'); | ||
|
|
||
| const baseFlatConfig = require('eslint-config-airbnb-base/flat'); | ||
|
|
||
| const react = require('./rules/react'); | ||
| const reactA11y = require('./rules/react-a11y'); | ||
|
|
||
| module.exports = [ | ||
| ...baseFlatConfig, | ||
| { | ||
| files: ['**/*.{js,jsx,mjs,cjs}'], | ||
| plugins: { | ||
| react: reactPlugin, | ||
| 'jsx-a11y': jsxA11yPlugin, | ||
| }, | ||
| languageOptions: { | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| }, | ||
| settings: react.settings, | ||
| rules: { | ||
| ...react.rules, | ||
| ...reactA11y.rules, | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ | |
| "./rules/react": "./rules/react.js", | ||
| "./rules/react-a11y": "./rules/react-a11y.js", | ||
| "./rules/react-hooks": "./rules/react-hooks.js", | ||
| "./flat": "./flat.js", | ||
| "./flat-base": "./flat-base.js", | ||
| "./flat-hooks": "./flat-hooks.js", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "scripts": { | ||
|
|
@@ -73,8 +76,8 @@ | |
| "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.1.0", | ||
| "eslint": "^7.32.0 || ^8.2.0 || ^9.0.0", | ||
| "eslint-find-rules": "^5.0.0", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| "eslint-plugin-import": "^2.30.0", | ||
| "eslint-plugin-jsx-a11y": "^6.10.0", | ||
| "eslint-plugin-react": "^7.36.1", | ||
|
|
@@ -85,7 +88,7 @@ | |
| "tape": "^5.9.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "eslint": "^7.32.0 || ^8.2.0", | ||
| "eslint": "^7.32.0 || ^8.2.0 || ^9.0.0", | ||
| "eslint-plugin-import": "^2.30.0", | ||
| "eslint-plugin-jsx-a11y": "^6.10.0", | ||
| "eslint-plugin-react": "^7.36.1", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-find-rules v5 doesn't support eslint 7, so this will have to be
^4.1.0 || ^5.0.0