-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
eslint.config.mjs
69 lines (64 loc) · 2.39 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { fixupPluginRules } from '@eslint/compat';
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import globals from 'globals';
import tsEslint from 'typescript-eslint';
import { fileURLToPath } from 'url';
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url));
export default tsEslint.config(
// register all of the plugins up-front
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
react: fixupPluginRules(reactPlugin),
'simple-import-sort': simpleImportSortPlugin
}
},
// config with just ignores is the replacement for `.eslintignore`
{ ignores: ['**/node_modules/**', '**/dist/**', '**/.parcel-cache/**'] },
// extends ...
eslint.configs.recommended,
...tsEslint.configs.recommended,
// base config
{
languageOptions: {
globals: { ...globals.es2022, ...globals.browser, ...globals.node },
parserOptions: {
projectService: true,
tsconfigRootDir,
warnOnUnsupportedTypeScriptVersion: false
}
},
rules: {
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
'react/jsx-no-target-blank': 'warn',
'react/jsx-sort-props': [
'error',
{
reservedFirst: true,
callbacksLast: true,
noSortAlphabetically: true
}
]
}
},
{
files: ['**/*.js'],
extends: [tsEslint.configs.disableTypeChecked],
rules: {
// turn off other type-aware rules
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
// turn off rules that don't apply to JS code
'@typescript-eslint/explicit-function-return-type': 'off'
}
},
eslintConfigPrettier
);