Skip to content

Commit

Permalink
Upgrade and fix eslint config (#2879)
Browse files Browse the repository at this point in the history
Previously, `npm install; npm run lint` would fail. Now it succeeds.

This involved a couple changes:
1. switch from eslint legacy to flat config
2. bump some plugins, including removing some straggling references to the unmaintained `eslint-plugin-node` in favor of its sucessor `eslint-plugin-n` and removing `eslint-plugin-import`, which is unused and incompatible with eslint 9.
3. Use the recommended config for `typescript-eslint`.
4. Turn off the rule `@typescript-eslint/no-require-imports`, which currently fails on parts of the codebase.

---------

Co-authored-by: Francis Gulotta <[email protected]>
  • Loading branch information
rotu and reconbot authored Dec 23, 2024
1 parent 5b20aba commit 73a34f9
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 13,803 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

51 changes: 0 additions & 51 deletions .eslintrc.js

This file was deleted.

68 changes: 68 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import nodePlugin from 'eslint-plugin-n'
import mocha from 'eslint-plugin-mocha'
import globals from 'globals'
import js from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslint from '@eslint/js'
import typescriptEslint from 'typescript-eslint'

export default [
{
ignores: ['packages/*/node_modules', '**/docs', 'packages/*/dist/*'],
},
js.configs.recommended,
nodePlugin.configs['flat/recommended-script'],
mocha.configs['flat'].recommended,
...typescriptEslint.configs.recommended,
eslintConfigPrettier,
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
assert: false,
makeTestFeature: false,
shouldReject: false,
},
ecmaVersion: 12,
sourceType: 'commonjs',
},

rules: {
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'n/no-process-exit': 'off',
'no-var': 'error',

'n/no-extraneous-import': [
'error',
{
allowModules: ['sinon', 'chai'],
},
],

'n/no-missing-import': 'off',
'n/no-missing-require': 'off',
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
'n/no-unsupported-features/es-builtins': 'error',
'n/no-unsupported-features/es-syntax': 'off',
'n/no-unsupported-features/node-builtins': 'error',
'n/hashbang': 'off',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'mocha/no-exclusive-tests': 'error',
'mocha/no-hooks-for-single-case': 'off',
'mocha/no-mocha-arrows': 'off',
'mocha/no-pending-tests': 'error',
'mocha/no-setup-in-describe': 'off',
strict: ['error', 'never'],
'valid-jsdoc': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
]
Loading

0 comments on commit 73a34f9

Please sign in to comment.