Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
211 lines (205 loc) · 7.94 KB
/
Copy patheslint.config.mjs
File metadata and controls
211 lines (205 loc) · 7.94 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
211
import { globalIgnores } from 'eslint/config';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginImport from 'eslint-plugin-import';
import eslintPluginPromise from 'eslint-plugin-promise';
import eslintPluginSecurity from 'eslint-plugin-security';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import vitest from '@vitest/eslint-plugin';
export default tseslint.config([
globalIgnores([
'build/',
'bundle/',
'coverage/',
'out/',
'node_modules/',
'eslint.config.mjs',
'webpack.*.js',
'vitest.*.ts',
'**/*.json',
'**/*.yaml',
'**/*.zip',
'**/.DS_Store',
'**/.tsbuildinfo',
'**/*.md',
'src/services/guard/assets/**',
'sbom/',
'vendor/',
'tst/__mocks__'
]),
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginImport.flatConfigs.recommended,
eslintPluginImport.flatConfigs.typescript,
eslintPluginPromise.configs['flat/recommended'],
eslintPluginUnicorn.configs['flat/recommended'],
eslintPluginSecurity.configs.recommended,
{
languageOptions: {
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
'import/resolver': {
typescript: {
project: 'tsconfig.json',
},
},
},
rules: {
// --- General Code Quality & Best Practices ---
'no-console': 'error',
'no-debugger': 'error',
eqeqeq: ['error', 'always'],
'require-atomic-updates': 'error',
// --- TypeScript-ESLint Rules (Strict & Quality) ---
'@typescript-eslint/no-unused-vars': ['error', { caughtErrors: 'none', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
'no-return-await': 'off',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'prefer-const': 'error',
// --- Import Plugin Rules (Organization & Quality) ---
'import/order': [
'error',
{
groups: [
'builtin', // Node.js built-in modules (fs, path, etc.)
'external', // npm packages
'internal', // Internal modules (configured via settings)
'parent', // Parent directory imports (../)
'sibling', // Same directory imports (./)
'index', // Index file imports (./index)
],
'newlines-between': 'never',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'import/no-self-import': 'error',
'import/no-useless-path-segments': 'error',
'import/no-deprecated': 'error',
'import/first': 'error',
'import/no-duplicates': ['error', { 'prefer-inline': true }],
'import/no-namespace': 'error',
'import/no-named-as-default-member': 'error',
// --- Code Quality Plugin Overrides ---
'unicorn/filename-case': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-ternary': 'off',
'unicorn/catch-error-name': 'off',
'unicorn/prefer-string-raw': 'off',
'unicorn/prefer-split-limit': 'off',
'unicorn/better-dom-traversing': 'off',
'unicorn/consistent-compound-words': 'off',
'unicorn/prefer-includes-over-repeated-comparisons': 'off',
'unicorn/import-style': [
'error',
{
styles: {
path: {
named: true,
},
},
},
],
'unicorn/prefer-string-replace-all': 'warn',
'security/detect-object-injection': 'off',
'security/detect-non-literal-fs-filename': 'off',
'promise/always-return': 'off',
'promise/catch-or-return': 'off',
},
},
{
files: ['src/**'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'os',
importNames: ['userInfo'],
message: 'userInfo is not supported in sandbox Linux environments',
},
{
name: 'fs',
importNames: ['readFileSync', 'readFile'],
message: 'Use methods in FileSystem.ts',
},
],
},
],
},
},
{
files: ['tst/**'],
plugins: {
vitest,
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
},
rules: {
'security/detect-non-literal-regexp': 'off',
'vitest/no-disabled-tests': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/numeric-separators-style': 'off',
'import/no-namespace': 'off',
'unicorn/no-null': 'off',
'unicorn/consistent-function-scoping': 'off',
'import/first': 'off',
'unicorn/switch-case-braces': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'vitest/no-conditional-expect': 'off',
},
},
{
files: ['tools/**'],
rules: {
'no-console': 'off',
'no-empty': 'off',
'import/order': 'off',
'import/first': 'off',
'import/no-namespace': 'off',
'import/no-unresolved': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'unicorn/import-style': 'off',
'unicorn/no-null': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/no-process-exit': 'off',
},
},
eslintPluginPrettierRecommended,
]);