-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
186 lines (173 loc) · 4.93 KB
/
eslint.config.js
File metadata and controls
186 lines (173 loc) · 4.93 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginImportX from 'eslint-plugin-import-x';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginMocha from 'eslint-plugin-mocha';
import globals from 'globals';
export default tseslint.config(
// Global ignores
{
ignores: [
'**/dist/**',
'**/types/**',
'**/node_modules/**',
'**/config/**',
'**/*.js',
'**/*.mjs',
'**/*.cjs',
// Keep the config file itself lintable
'!eslint.config.js',
],
},
// Base recommended configs
eslint.configs.recommended,
...tseslint.configs.recommended,
// TypeScript source files configuration
{
files: ['src/**/*.ts'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
// Use 'import' name for backwards compatibility with existing inline disable comments
import: eslintPluginImportX,
},
rules: {
// Quotes
quotes: ['error', 'single', { avoidEscape: true }],
// Disable rules that conflict with TypeScript
'no-return-await': 'off',
'no-unused-vars': 'off',
// Import rules (using 'import/' prefix for backwards compatibility)
'import/extensions': [
'error',
'always',
{
ts: 'always',
tsx: 'always',
js: 'always',
jsx: 'never',
ignorePackages: true,
},
],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['test/**/*.ts', '**/config/**', '**/*.config.js', '**/*.config.ts'],
peerDependencies: true,
optionalDependencies: false,
},
],
'import/no-mutable-exports': 'off',
'import/order': [
'error',
{
groups: [
['builtin', 'external', 'internal'],
['parent', 'sibling', 'index'],
],
'newlines-between': 'always',
},
],
// General rules
'no-labels': 'off',
'no-restricted-syntax': 'off',
'no-nested-ternary': 'off',
// TypeScript rules
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
},
},
// Test files configuration
{
files: ['test/**/*.ts'],
plugins: {
mocha: eslintPluginMocha,
import: eslintPluginImportX,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.mocha,
},
},
rules: {
// Relaxed rules for tests
'no-void': 'off',
'no-underscore-dangle': 'off',
'func-names': 'off',
'prefer-arrow-callback': 'off',
'no-array-constructor': 'off',
'prefer-rest-params': 'off',
'no-new-wrappers': 'off',
'max-classes-per-file': 'off',
// Mocha rules
'mocha/no-pending-tests': 'error',
'mocha/handle-done-callback': 'error',
'mocha/valid-suite-title': 'error',
'mocha/no-mocha-arrows': 'error',
'mocha/no-hooks-for-single-case': 'error',
'mocha/no-sibling-hooks': 'error',
'mocha/no-top-level-hooks': 'error',
'mocha/no-identical-title': 'error',
'mocha/no-nested-tests': 'error',
'mocha/no-exclusive-tests': 'error',
// Import rules
'import/no-relative-packages': 'off',
// TypeScript rules for tests
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-expressions': 'off', // Chai assertions like expect(x).to.be.true
// TypeScript naming convention for __dirname and __filename
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'forbid',
},
{
selector: 'variable',
format: null,
filter: {
regex: '^__dirname$',
match: true,
},
},
{
selector: 'variable',
format: null,
filter: {
regex: '^__filename$',
match: true,
},
},
],
},
},
// Prettier must be last to override other configs
eslintPluginPrettierRecommended,
);