-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump typescript-eslint, switch to flat eslint config (#4930)
* Bump eslint, typescript-eslint npm un @typescript-eslint/parser @typescript-eslint/eslint-plugin npm install --save-dev typescript-eslint@latest eslint@latest eslint-config-prettier@latest eslint-plugin-react@latest https://typescript-eslint.io/blog/announcing-typescript-eslint-v7/ No-Issue * remove all .eslintrc * call eslint without --ext * add globals dev-dep * eslint.config.mjs: working config * fix a bunch of no-const/no-var warnings in tests * no extends * reportUnusedDisableDirectives
- Loading branch information
Showing
19 changed files
with
298 additions
and
191 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import eslint from '@eslint/js'; | ||
import prettierConfig from 'eslint-config-prettier'; | ||
import reactPlugin from 'eslint-plugin-react'; | ||
import globals from 'globals'; | ||
import { | ||
config, | ||
parser, | ||
configs as tsConfigs, | ||
plugin as tsPlugin, | ||
} from 'typescript-eslint'; | ||
|
||
// require('eslint-plugin-react/configs/recommended') does the right thing but can't be imported | ||
// and the .configs.recommended export adds flatconfig-invalid .plugins and .parserOptions .. remove | ||
const reactConfig = { | ||
...reactPlugin.configs.recommended, | ||
plugins: { react: reactPlugin }, // fix for plugins: ['react'] | ||
}; | ||
delete reactConfig.parserOptions; | ||
|
||
export default config( | ||
eslint.configs.recommended, | ||
reactConfig, | ||
...tsConfigs.recommended, | ||
...tsConfigs.stylistic, | ||
prettierConfig, | ||
{ | ||
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'], | ||
plugins: { | ||
'@typescript-eslint': tsPlugin, | ||
react: reactPlugin, | ||
}, | ||
languageOptions: { | ||
ecmaVersion: 2022, | ||
sourceType: 'module', | ||
parser, | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
globals: { | ||
...globals.browser, | ||
}, | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
linterOptions: { | ||
reportUnusedDisableDirectives: true, | ||
}, | ||
rules: { | ||
curly: ['error', 'all'], | ||
'eol-last': ['error', 'always'], | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ argsIgnorePattern: '^_' }, | ||
], | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ fixStyle: 'inline-type-imports' }, | ||
], | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
paths: [ | ||
{ | ||
importNames: [ | ||
'Alert', | ||
'Breadcrumb', | ||
'Chip', | ||
'ChipGroup', | ||
'ClipboardCopy', | ||
'ClipboardCopyButton', | ||
'FileUpload', | ||
'Icon', | ||
'LabelGroup', | ||
'LoginForm', | ||
'NavList', | ||
'Pagination', | ||
'Popover', | ||
'SearchInput', | ||
'Spinner', | ||
'Tooltip', | ||
], | ||
message: 'Import from src/components instead.', | ||
name: '@patternfly/react-core', | ||
}, | ||
{ | ||
importNames: ['CodeEditor'], | ||
message: 'Import from src/components instead.', | ||
name: '@patternfly/react-code-editor', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['config/*.js'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['src/components/patternfly-wrappers/*.{js,jsx,ts,tsx}'], | ||
rules: { | ||
'no-restricted-imports': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['test/**/*.{js,jsx,ts,tsx}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
Cypress: 'readonly', | ||
after: 'readonly', | ||
before: 'readonly', | ||
beforeEach: 'readonly', | ||
cy: 'readonly', | ||
describe: 'readonly', | ||
expect: 'readonly', | ||
it: 'readonly', | ||
}, | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
); |
Oops, something went wrong.