-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy patheslint.config.js
116 lines (107 loc) · 2.45 KB
/
eslint.config.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import importPlugin from 'eslint-plugin-import-x';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import eslintJs from '@eslint/js';
import eslintTs from 'typescript-eslint';
const tsFiles = ['{src,test}/**/*.ts'];
const jsFiles = ['test/**/*.js'];
const languageOptions = {
globals: {
...globals.node
},
ecmaVersion: 2023,
sourceType: 'module'
};
const customTypescriptConfig = {
files: tsFiles,
plugins: {
import: importPlugin,
'import/parsers': tsParser
},
languageOptions: {
...languageOptions,
parser: tsParser,
parserOptions: {
project: './tsconfig.eslint.json'
}
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts']
}
},
rules: {
'import/export': 'error',
'import/no-duplicates': 'warn',
...importPlugin.configs.typescript.rules,
'@typescript-eslint/no-use-before-define': 'off',
'require-await': 'off',
'no-duplicate-imports': 'error',
'no-unneeded-ternary': 'error',
'prefer-object-spread': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
args: 'none'
}
],
'import/order': [
'error',
{
groups: ['type', 'builtin', ['sibling', 'parent'], 'index', 'object'],
'newlines-between': 'never',
alphabetize: {
order: 'asc',
caseInsensitive: true
}
}
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports'
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off'
}
};
const customJavascriptConfig = {
files: jsFiles,
languageOptions: {
...languageOptions,
parserOptions: {
ecmaVersion: 2023
}
},
rules: {
'no-duplicate-imports': 'error',
'no-unneeded-ternary': 'error',
'prefer-object-spread': 'error',
'no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
args: 'none'
}
]
}
};
const recommendedTypeScriptConfigs = [
...eslintTs.configs.recommended.map(config => ({
...config,
files: tsFiles
})),
...eslintTs.configs.stylistic.map(config => ({
...config,
files: tsFiles
}))
];
export default [
{ignores: ['docs/*', 'lib/*']},
eslintJs.configs.recommended,
customJavascriptConfig,
...recommendedTypeScriptConfigs,
customTypescriptConfig
];