Skip to content

Commit

Permalink
chore: update to support eslint 9 flat config (#1064)
Browse files Browse the repository at this point in the history
Upgrade to eslint v9 flat config. Custom eslint rules have been tested
and work in the new config file.
Use [globals](https://www.npmjs.com/package/globals) to include [globals
env](https://eslint.org/docs/latest/use/configure/language-options#predefined-global-variables)

eslint-plugin-react since it does not support eslint 9 yet 
Ref: jsx-eslint/eslint-plugin-react#3743

no qa required
  • Loading branch information
michael-siek authored May 16, 2024
1 parent 20b8bbf commit 364e944
Show file tree
Hide file tree
Showing 12 changed files with 455 additions and 772 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

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

This file was deleted.

130 changes: 130 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
const globals = require('globals');
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintPluginPrettier = require('eslint-plugin-prettier');

module.exports = [
eslint.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommended,
{
languageOptions: {
parser: tseslint.parser,
globals: {
...globals.node,
...globals.mocha,
...globals.browser
}
},
settings: {
react: {
version: 'detect'
}
},
plugins: {
prettier: eslintPluginPrettier,
'@typescript-eslint': tseslint.plugin
},
rules: {
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error'
}
},
{
ignores: [
'packages/cli/src/testutils/',
'packages/cli/src/**/**/*.test.ts',
'packages/reporter-earl/coverage/',
'packages/react/examples/',
'**/dist/',
'**/fixtures/external/'
]
},
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
}
},
{
files: ['packages/cli/**'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-function-return-type': 'off'
}
},
{
files: ['packages/cli/**/*.test.ts'],
languageOptions: {
globals: {
...globals.mocha
}
},
rules: {
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
files: ['packages/puppeteer/**'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off'
}
},
{
files: ['packages/react/**'],
languageOptions: {
sourceType: 'module',
globals: {
...globals.node,
...globals.mocha,
...globals.browser
},
ecmaVersion: 2018
}
},
{
files: ['packages/react/test/*.js'],
rules: {
'no-var': 'off'
}
},
{
files: ['packages/reporter-earl/**'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'no-debugger': 'off',
'no-empty-pattern': 'off'
}
},
{
files: ['packages/reporter-earl/tests/*.test.ts'],
languageOptions: {
globals: {
jest: true
}
}
},
{
files: ['packages/reporter-earl/src/types.ts'],
rules: {
'@typescript-eslint/no-empty-object-type': 'off'
}
}
];
Loading

0 comments on commit 364e944

Please sign in to comment.