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

fix: add support for eslint 9 #111

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 44 additions & 37 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
module.exports = {
extends: [
'eslint:recommended',
],
parserOptions: {
const globals = require("globals")

Check failure on line 1 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

'globals' should be listed in the project's dependencies. Run 'npm i -S globals' to add it

Check failure on line 1 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote
const js = require("@eslint/js")

Check failure on line 2 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

'@eslint/js' should be listed in the project's dependencies. Run 'npm i -S @eslint/js' to add it

Check failure on line 2 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote
const pluginNode = require("eslint-plugin-node")

Check failure on line 3 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote

Choose a reason for hiding this comment

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

Use eslint-plugin-n instead, its the currently supported fork and maintained by us in the official eslint-community: https://github.com/eslint-community/eslint-plugin-n

const pluginImport = require("eslint-plugin-import")

Check failure on line 4 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote

Choose a reason for hiding this comment

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

Does not yet support ESLint 9: import-js/eslint-plugin-import#2948

See also: neostandard/neostandard#15

const pluginPromise = require("eslint-plugin-promise")

Check failure on line 5 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote

Choose a reason for hiding this comment

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

Does not yet support ESLint 9: eslint-community/eslint-plugin-promise#449 We will get to it within the eslint-community

See also: neostandard/neostandard#14

const { fixupPluginRules } = require("@eslint/compat")

Check failure on line 6 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote

const npmCliConfig = [{
languageOptions: {
ecmaVersion: 2022,
ecmaFeatures: {},
sourceType: 'script',
globals: {
...globals.browser,

Choose a reason for hiding this comment

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

The previous env was es6 + node, not browser + node

...globals.node,
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
}

Check failure on line 18 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Missing trailing comma
},
env: {
es6: true,
node: true,
},
plugins: [
'node',
'import',
'promise',
],
globals: {
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
plugins: {
node: fixupPluginRules(pluginNode),
import: pluginImport,
promise: pluginPromise

Check failure on line 23 in lib/index.js

View workflow job for this annotation

GitHub Actions / Lint

Missing trailing comma
},
ignorePatterns: ['tap-snapshots/**'],
overrides: [{
files: ['test/**'],
rules: {
'no-global-assign': 'off',
'no-extend-native': 'off',
},
}, {
files: ['lib/**', 'bin/**'],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
}, {
files: ['lib/**'],
rules: {
'no-console': 'error',
},
}],
ignores: ['tap-snapshots/**'],
rules: {
'accessor-pairs': 'error',
'array-bracket-spacing': ['error', 'never'],
Expand Down Expand Up @@ -230,4 +214,27 @@
'promise/catch-or-return': 'error',
'promise/no-new-statics': 'error',
},
},
{
files: ['test/**'],
rules: {
'no-global-assign': 'off',
'no-extend-native': 'off',
},
}, {
files: ['lib/**', 'bin/**'],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
}, {
files: ['lib/**'],
rules: {
'no-console': 'error',
},
Comment on lines +218 to +233

Choose a reason for hiding this comment

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

Add descriptive names to these to more easily identify them in eg. the config inspector, eg:

Suggested change
{
files: ['test/**'],
rules: {
'no-global-assign': 'off',
'no-extend-native': 'off',
},
}, {
files: ['lib/**', 'bin/**'],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
}, {
files: ['lib/**'],
rules: {
'no-console': 'error',
},
{
name: 'Test adaptions',
files: ['test/**'],
rules: {
'no-global-assign': 'off',
'no-extend-native': 'off',
},
}, {
name: 'Shipping code adaptions',
files: ['lib/**', 'bin/**'],
rules: {
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
},
}, {
name: 'Shipping code adaptions, non-cli',
files: ['lib/**'],
rules: {
'no-console': 'error',
},

}
]

module.exports = [
js.configs.recommended,
...npmCliConfig
]
Loading