-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
210 lines (207 loc) · 6.84 KB
/
eslint.config.js
File metadata and controls
210 lines (207 loc) · 6.84 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import-x';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import unusedImports from 'eslint-plugin-unused-imports';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
export default [
js.configs.recommended,
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: import.meta.dirname,
ecmaFeatures: {
jsx: true,
},
},
globals: {
node: true,
es2022: true,
console: 'readonly',
alert: 'readonly',
confirm: 'readonly',
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
process: 'readonly',
fetch: 'readonly',
FormData: 'readonly',
File: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
localStorage: 'readonly',
sessionStorage: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
Buffer: 'readonly',
React: 'readonly',
JSX: 'readonly',
__BUILD_COMMIT__: 'readonly',
HTMLDivElement: 'readonly',
HTMLInputElement: 'readonly',
MouseEvent: 'readonly',
Element: 'readonly',
EventTarget: 'readonly',
Express: 'readonly',
// Vitest (test files)
describe: 'readonly',
it: 'readonly',
test: 'readonly',
expect: 'readonly',
vi: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescript,
'import-x': importPlugin,
'simple-import-sort': simpleImportSort,
'unused-imports': unusedImports,
prettier: prettier,
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-unused-vars': 'off', // handled by unused-imports plugin
'@typescript-eslint/no-explicit-any': 'warn', // Prevent explicit any usage (warn to allow existing code)
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn', // Allow with warning
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-unsafe-assignment': 'warn', // Allow with warning
'@typescript-eslint/no-unsafe-call': 'warn', // Allow with warning
'@typescript-eslint/no-unsafe-member-access': 'warn', // Allow with warning
'@typescript-eslint/no-unsafe-return': 'warn', // Allow with warning
'@typescript-eslint/prefer-nullish-coalescing': 'off', // Disabled due to strictNullChecks requirement
'@typescript-eslint/prefer-optional-chain': 'warn', // Allow with warning
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'warn', // Allow with warning
// Import/Export rules
'import-x/no-duplicates': 'error',
'import-x/no-unresolved': 'off', // TypeScript handles this
'import-x/order': 'off', // handled by simple-import-sort
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
// General rules
'no-console': 'off', // Allow console in development
'no-debugger': 'error',
'no-duplicate-imports': 'error',
'no-unused-vars': 'off', // handled by unused-imports plugin
'prefer-const': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-template': 'error',
'template-curly-spacing': 'error',
'arrow-spacing': 'error',
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
'func-call-spacing': 'error',
'key-spacing': 'error',
'keyword-spacing': 'error',
'object-curly-spacing': ['error', 'always'],
semi: ['error', 'always'],
'semi-spacing': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
},
],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': 'error',
quotes: ['error', 'single', { avoidEscape: true }],
indent: ['error', 2, { SwitchCase: 1, ignoredNodes: ['PropertyDefinition'] }],
'max-len': [
'warn',
{
code: 120,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
// Prettier integration
'prettier/prettier': 'error',
},
},
prettierConfig,
// Test files: relax type-strict rules so lint:check passes with --max-warnings 0
{
files: ['**/*.test.ts', '**/*.test.tsx'],
rules: {
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
},
},
// Node script files: allow console/process (only applied if not ignored)
{
files: ['scripts/**/*.mjs'],
languageOptions: {
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'writable',
},
},
},
{
ignores: [
'node_modules/',
'dist/',
'build/',
'.vite-dev-build/',
'*.js',
'scripts/*.mjs',
'*.d.ts',
'vitest.config.ts',
'public/',
'chrome-extension/',
'src/sdk/**/*',
],
},
];