Skip to content

Commit

Permalink
Upgrade eslint to 9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
yo35 committed Sep 1, 2024
1 parent c0424c9 commit 31b1f75
Show file tree
Hide file tree
Showing 6 changed files with 572 additions and 606 deletions.
73 changes: 0 additions & 73 deletions .eslintrc.yml

This file was deleted.

6 changes: 0 additions & 6 deletions demo/.eslintrc.yml

This file was deleted.

104 changes: 104 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import eslint from '@eslint/js';
import globals from 'globals';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';

export default tseslint.config(

// Base config
eslint.configs.recommended,
stylistic.configs['recommended-flat'],
...tseslint.configs.strict,
...tseslint.configs.stylistic,

{
rules: {

// Style
'@stylistic/array-bracket-spacing': [ 'error', 'always' ],
'@stylistic/arrow-parens': [ 'error', 'as-needed' ],
'@stylistic/indent': [ 'error', 4, { SwitchCase: 1 } ],
'@stylistic/indent-binary-ops': [ 'error', 4 ],
'@stylistic/linebreak-style': [ 'error', 'unix' ],
'@stylistic/max-statements-per-line': 'off',
'@stylistic/member-delimiter-style': [ 'error', { singleline: { delimiter: 'comma' }, multiline: { delimiter: 'comma' } } ],
'@stylistic/no-multiple-empty-lines': [ 'error', { max: 2 } ],
'@stylistic/operator-linebreak': 'off',
'@stylistic/padded-blocks': 'off',
'@stylistic/quotes': [ 'error', 'single' ],
'@stylistic/semi': [ 'error', 'always' ],

// Core rules (possible problems)
'no-constructor-return': 'error',
'no-duplicate-imports': 'error',
'no-self-compare': 'error',
'no-unmodified-loop-condition': 'error',

// Core rules (suggestions)
'camelcase': 'error',
'curly': 'error',
'eqeqeq': 'error',
'no-alert': 'error',
'no-console': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-implicit-coercion': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-return-assign': [ 'error', 'always' ],
'no-throw-literal': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'no-warning-comments': [ 'warn', { location: 'anywhere', terms: [ 'TODO' ] }],
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-regex-literals': 'error',
'prefer-rest-params': 'error',

// Typescript rules
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': [ 'error', { allow: [ 'private-constructors', 'protected-constructors' ] } ],
'@typescript-eslint/no-extraneous-class': [ 'error', { allowEmpty: true } ],
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/unified-signatures': [ 'error', { ignoreDifferentlyNamedParameters: true } ],
},
},

{
files: [ 'demo/**' ],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
'no-console': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},

{
files: [ 'test/**' ],
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
},
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
);
Loading

0 comments on commit 31b1f75

Please sign in to comment.