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] switch to eslint.config.js #3600

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .eslint-doc-generatorrc.js
@@ -1,3 +1,5 @@
'use strict';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file wasn't linted before because it's a dotfile.


/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
configEmoji: [
Expand Down
82 changes: 0 additions & 82 deletions .eslintrc

This file was deleted.

130 changes: 130 additions & 0 deletions eslint.config.js
@@ -0,0 +1,130 @@
'use strict';

const globals = require('globals');
const eslintPluginRecommended = require('eslint-plugin-eslint-plugin/configs/recommended');

const FlatCompat = require('@eslint/eslintrc').FlatCompat;

const eslintrc = new FlatCompat({
baseDirectory: __dirname,
});

module.exports = [
{
ignores: [
'coverage/',
'.nyc_output/',
],
},
...eslintrc.extends('airbnb-base'),
eslintPluginRecommended,
{
languageOptions: {
ecmaVersion: 6,
sourceType: 'commonjs',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: globals.node,
},
rules: {
'comma-dangle': [2, 'always-multiline'],
'object-shorthand': [2, 'always', {
ignoreConstructors: false,
avoidQuotes: false, // this is the override vs airbnb
}],
'max-len': [2, 120, {
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreComments: true,
}],
'consistent-return': 0,

'prefer-destructuring': [2, { array: false, object: false }, { enforceForRenamedProperties: false }],
'prefer-object-spread': 0, // until node 8 is required
'prefer-rest-params': 0, // until node 6 is required
'prefer-spread': 0, // until node 6 is required
'function-call-argument-newline': 1, // TODO: enable
'function-paren-newline': 0,
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
'no-param-reassign': 1,
'no-restricted-syntax': [2, {
selector: 'ObjectPattern',
message: 'Object destructuring is not compatible with Node v4',
}],
strict: [2, 'safe'],
'valid-jsdoc': [2, {
requireReturn: false,
requireParamDescription: false,
requireReturnDescription: false,
}],

'eslint-plugin/consistent-output': 0,
'eslint-plugin/require-meta-docs-description': [2, { pattern: '^(Enforce|Require|Disallow)' }],
'eslint-plugin/require-meta-schema': 0,
'eslint-plugin/require-meta-type': 0,

// overrides airbnb config to add `eslint.config.js` to `devDependencies`
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'test/**',
'tests/**',
'spec/**',
'**/__tests__/**',
'**/__mocks__/**',
'test.{js,jsx}',
'test-*.{js,jsx}',
'**/*{.,_}{test,spec}.{js,jsx}',
'**/jest.config.js',
'**/jest.setup.js',
'**/vue.config.js',
'**/webpack.config.js',
'**/webpack.config.*.js',
'**/rollup.config.js',
'**/rollup.config.*.js',
'**/gulpfile.js',
'**/gulpfile.*.js',
'**/Gruntfile{,.js}',
'**/protractor.conf.js',
'**/protractor.conf.*.js',
'**/karma.conf.js',
'**/.eslintrc.js',
'eslint.config.js',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added eslint.config.js to this list to fix 'globals' should be listed in the project's dependencies, not devDependencies errors. The rest is just copy-pasted from airbnb.

],
optionalDependencies: false,
},
],
},
},
{
files: ['tests/**'],
languageOptions: {
globals: globals.mocha,
},
rules: {
'no-template-curly-in-string': 1,
},
},
{
files: ['markdown.config.js'],
rules: {
'no-console': 0,
},
},
Comment on lines +112 to +117
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copy-pasted from .eslintrc, but this file doesn't seem to exist so it probably can be removed.

{
files: ['.github/workflows/*.js'],
languageOptions: {
ecmaVersion: 2019,
},
rules: {
camelcase: 0,
'no-console': 0,
'no-restricted-syntax': 0,
},
},

];
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -48,6 +48,7 @@
"@babel/plugin-syntax-do-expressions": "^7.18.6",
"@babel/plugin-syntax-function-bind": "^7.18.6",
"@babel/preset-react": "^7.18.6",
"@eslint/eslintrc": "^2.1.0",
"@types/eslint": "=7.2.10",
"@types/estree": "0.0.52",
"@types/node": "^4.9.5",
Expand All @@ -57,12 +58,13 @@
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-doc-generator": "^1.4.3",
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.5.3 || ^4.0.1 || ^5.0.5",
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.5.3 || ^4.0.1 || ^5.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flat config exports that eslint.config.js uses were added in v5.1.0.

"eslint-plugin-import": "^2.27.5",
"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "^1.0.0",
"eslint-scope": "^3.7.3",
"espree": "^3.5.4",
"globals": "^13.20.0",
"istanbul": "^0.4.5",
"jackspeak": "=2.1.1",
"ls-engines": "^0.8.1",
Expand Down