-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
115 lines (112 loc) · 3.49 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
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
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import globals from 'globals'
import vitestPlugin from '@vitest/eslint-plugin'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
// -----------------------------------------------------------------------------
// Exports
// -----------------------------------------------------------------------------
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
eslintPluginPrettierRecommended,
// Global ignores
{
ignores: [`coverage/*`, `node_modules/*`, `dist/*`, `docs/*`],
},
// Default config
{
files: [`**/*.{ts,tsx,mjs,cjs,js}`],
linterOptions: {
reportUnusedDisableDirectives: `error`,
},
languageOptions: {
ecmaVersion: 2020,
sourceType: `module`,
globals: {
...globals.browser,
...globals.node,
...globals.es2020,
},
},
plugins: {
'simple-import-sort': simpleImportSortPlugin,
'unused-imports': unusedImportsPlugin,
},
rules: {
// Generic
'no-undef': `off`,
quotes: [
`error`,
`backtick`,
{ avoidEscape: true, allowTemplateLiterals: true },
],
// Recommended to disable on TypeScript projects. See:
// https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
// Unused imports
'unused-imports/no-unused-imports': `error`,
'unused-imports/no-unused-vars': [
`error`,
{
vars: `all`,
varsIgnorePattern: `^_`,
args: `after-used`,
argsIgnorePattern: `^_`,
},
],
},
},
{
files: [`tests/unit/**/*.unit.test.js`, `tests/unit/setup.js`],
languageOptions: {
globals: {
...vitestPlugin.environments.env.globals,
},
},
plugins: {
vitest: vitestPlugin,
},
rules: {
'vitest/consistent-test-filename': [
`error`,
{
pattern: `.*\\.unit\\.test\\.[tj]s?$`,
},
],
'vitest/consistent-test-it': [
`error`,
{
fn: `it`,
},
],
'vitest/expect-expect': `error`,
'vitest/no-commented-out-tests': `warn`,
'vitest/no-disabled-tests': `warn`,
'vitest/no-duplicate-hooks': `error`,
'vitest/no-focused-tests': `warn`,
'vitest/no-identical-title': `error`,
'vitest/no-standalone-expect': `error`,
'vitest/no-test-return-statement': `error`,
'vitest/prefer-called-with': `error`,
'vitest/prefer-comparison-matcher': `error`,
'vitest/prefer-each': `error`,
'vitest/prefer-equality-matcher': `error`,
'vitest/prefer-hooks-in-order': `error`,
'vitest/prefer-hooks-on-top': `error`,
'vitest/prefer-lowercase-title': `error`,
'vitest/prefer-mock-promise-shorthand': `error`,
'vitest/prefer-spy-on': `error`,
'vitest/prefer-to-be-object': `error`,
'vitest/prefer-to-be': `error`,
'vitest/prefer-to-contain': `error`,
'vitest/prefer-to-have-length': `error`,
'vitest/require-to-throw-message': `error`,
'vitest/valid-describe-callback': `error`,
'vitest/valid-expect': `error`,
'vitest/valid-title': `error`,
},
}
)