@heyq02/rslint-config 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/configs/ignores.d.ts +2 -0
- package/dist/configs/imports.d.ts +4 -0
- package/dist/configs/index.d.ts +11 -0
- package/dist/configs/javascript.d.ts +3 -0
- package/dist/configs/jest.d.ts +2 -0
- package/dist/configs/node.d.ts +2 -0
- package/dist/configs/promise.d.ts +2 -0
- package/dist/configs/react.d.ts +5 -0
- package/dist/configs/rstest.d.ts +2 -0
- package/dist/configs/special-cases.d.ts +2 -0
- package/dist/configs/typescript.d.ts +2 -0
- package/dist/configs/unicorn.d.ts +2 -0
- package/dist/env.d.ts +6 -0
- package/dist/globs.d.ts +11 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +665 -0
- package/dist/presets.d.ts +30 -0
- package/dist/types.d.ts +85 -0
- package/dist/utils.d.ts +4 -0
- package/package.json +20 -11
- package/dist/index.d.mts +0 -183
- package/dist/index.mjs +0 -522
package/dist/index.js
ADDED
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import { globalIgnores, globals, importPlugin, jestPlugin, js, jsxA11yPlugin, nodePlugin, promisePlugin, reactHooksPlugin, reactPlugin, rstestPlugin, ts, unicornPlugin } from "@rslint/core";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import node_process from "node:process";
|
|
4
|
+
const GLOB_SRC_EXT = '?([cm])[jt]s?(x)';
|
|
5
|
+
const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
|
|
6
|
+
const GLOB_JS = '**/*.?([cm])js';
|
|
7
|
+
const GLOB_JSX = '**/*.jsx';
|
|
8
|
+
const GLOB_TS = '**/*.?([cm])ts';
|
|
9
|
+
const GLOB_TSX = '**/*.tsx';
|
|
10
|
+
const GLOB_TESTS = [
|
|
11
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
12
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
13
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
14
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
15
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
16
|
+
];
|
|
17
|
+
const GLOB_NODE_MODULES = '**/node_modules';
|
|
18
|
+
const GLOB_DIST = '**/dist';
|
|
19
|
+
const GLOB_LOCKFILE = [
|
|
20
|
+
'**/package-lock.json',
|
|
21
|
+
'**/yarn.lock',
|
|
22
|
+
'**/pnpm-lock.yaml',
|
|
23
|
+
'**/bun.lock',
|
|
24
|
+
'**/bun.lockb'
|
|
25
|
+
];
|
|
26
|
+
const GLOB_EXCLUDE = [
|
|
27
|
+
GLOB_NODE_MODULES,
|
|
28
|
+
GLOB_DIST,
|
|
29
|
+
...GLOB_LOCKFILE,
|
|
30
|
+
'**/coverage',
|
|
31
|
+
'**/temp',
|
|
32
|
+
'**/tmp',
|
|
33
|
+
'**/fixtures',
|
|
34
|
+
'**/output',
|
|
35
|
+
'**/.vitepress/cache',
|
|
36
|
+
'**/.nuxt',
|
|
37
|
+
'**/.next',
|
|
38
|
+
'**/.vercel',
|
|
39
|
+
'**/.changeset',
|
|
40
|
+
'**/.idea',
|
|
41
|
+
'**/.output',
|
|
42
|
+
'**/.vite-inspect',
|
|
43
|
+
'**/.nitro',
|
|
44
|
+
'**/.turbo',
|
|
45
|
+
'**/CHANGELOG*.md',
|
|
46
|
+
'**/*.min.*',
|
|
47
|
+
'**/LICENSE*',
|
|
48
|
+
'**/__snapshots__',
|
|
49
|
+
'**/auto-import?(s).d.ts',
|
|
50
|
+
'**/components.d.ts'
|
|
51
|
+
];
|
|
52
|
+
const ignores = (extra = [])=>[
|
|
53
|
+
{
|
|
54
|
+
...globalIgnores([
|
|
55
|
+
...GLOB_EXCLUDE,
|
|
56
|
+
...extra
|
|
57
|
+
]),
|
|
58
|
+
name: 'heyq02/global-ignores'
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const imports = (options = {})=>[
|
|
62
|
+
{
|
|
63
|
+
...importPlugin.configs.recommended,
|
|
64
|
+
files: [
|
|
65
|
+
GLOB_SRC
|
|
66
|
+
],
|
|
67
|
+
name: 'heyq02/imports/recommended'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
files: [
|
|
71
|
+
GLOB_SRC
|
|
72
|
+
],
|
|
73
|
+
name: 'heyq02/imports',
|
|
74
|
+
rules: {
|
|
75
|
+
'import/first': 'error',
|
|
76
|
+
'import/no-default-export': 'error',
|
|
77
|
+
'import/no-duplicates': [
|
|
78
|
+
'error',
|
|
79
|
+
{
|
|
80
|
+
'prefer-inline': true
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
'import/no-mutable-exports': 'error',
|
|
84
|
+
'import/no-named-default': 'error',
|
|
85
|
+
...options.typescript ? {
|
|
86
|
+
'import/default': 'off',
|
|
87
|
+
'import/named': 'off',
|
|
88
|
+
'import/namespace': 'off',
|
|
89
|
+
'import/no-unresolved': 'off'
|
|
90
|
+
} : {}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
const restrictedSyntaxJs = [
|
|
95
|
+
'ForInStatement',
|
|
96
|
+
'LabeledStatement'
|
|
97
|
+
];
|
|
98
|
+
const javascript = ()=>[
|
|
99
|
+
{
|
|
100
|
+
...js.configs.recommended,
|
|
101
|
+
name: 'heyq02/js/recommended'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
files: [
|
|
105
|
+
GLOB_SRC
|
|
106
|
+
],
|
|
107
|
+
languageOptions: {
|
|
108
|
+
ecmaVersion: 'latest',
|
|
109
|
+
globals: {
|
|
110
|
+
...globals.browser,
|
|
111
|
+
...globals.es2026,
|
|
112
|
+
...globals.nodeBuiltin
|
|
113
|
+
},
|
|
114
|
+
sourceType: 'module'
|
|
115
|
+
},
|
|
116
|
+
name: 'heyq02/js',
|
|
117
|
+
rules: {
|
|
118
|
+
'array-callback-return': 'error',
|
|
119
|
+
'block-scoped-var': 'error',
|
|
120
|
+
'dot-notation': 'warn',
|
|
121
|
+
eqeqeq: [
|
|
122
|
+
'error',
|
|
123
|
+
'smart'
|
|
124
|
+
],
|
|
125
|
+
'no-alert': 'warn',
|
|
126
|
+
'no-console': [
|
|
127
|
+
'warn',
|
|
128
|
+
{
|
|
129
|
+
allow: [
|
|
130
|
+
'warn',
|
|
131
|
+
'error',
|
|
132
|
+
'info',
|
|
133
|
+
'clear'
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
'no-debugger': 'warn',
|
|
138
|
+
'no-duplicate-imports': 'error',
|
|
139
|
+
'no-empty': [
|
|
140
|
+
'error',
|
|
141
|
+
{
|
|
142
|
+
allowEmptyCatch: true
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
'no-fallthrough': [
|
|
146
|
+
'warn',
|
|
147
|
+
{
|
|
148
|
+
commentPattern: String.raw`break[\s\w]*omitted`
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
'no-inner-declarations': 'error',
|
|
152
|
+
'no-lonely-if': 'error',
|
|
153
|
+
'no-multi-str': 'error',
|
|
154
|
+
'no-restricted-syntax': [
|
|
155
|
+
'error',
|
|
156
|
+
...restrictedSyntaxJs
|
|
157
|
+
],
|
|
158
|
+
'no-unused-expressions': [
|
|
159
|
+
'error',
|
|
160
|
+
{
|
|
161
|
+
allowShortCircuit: true,
|
|
162
|
+
allowTaggedTemplates: true,
|
|
163
|
+
allowTernary: true
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
'no-unused-vars': [
|
|
167
|
+
'error',
|
|
168
|
+
{
|
|
169
|
+
args: 'after-used',
|
|
170
|
+
argsIgnorePattern: '^_',
|
|
171
|
+
ignoreRestSiblings: true,
|
|
172
|
+
varsIgnorePattern: '^_'
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
'no-useless-call': 'error',
|
|
176
|
+
'no-useless-computed-key': 'error',
|
|
177
|
+
'no-useless-constructor': 'error',
|
|
178
|
+
'no-useless-rename': 'error',
|
|
179
|
+
'no-var': 'error',
|
|
180
|
+
'no-void': 'error',
|
|
181
|
+
'object-shorthand': [
|
|
182
|
+
'error',
|
|
183
|
+
'always',
|
|
184
|
+
{
|
|
185
|
+
avoidQuotes: true,
|
|
186
|
+
ignoreConstructors: false
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
'one-var': [
|
|
190
|
+
'error',
|
|
191
|
+
{
|
|
192
|
+
initialized: 'never'
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
'prefer-arrow-callback': [
|
|
196
|
+
'error',
|
|
197
|
+
{
|
|
198
|
+
allowNamedFunctions: false,
|
|
199
|
+
allowUnboundThis: true
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
'prefer-const': [
|
|
203
|
+
'warn',
|
|
204
|
+
{
|
|
205
|
+
destructuring: 'all',
|
|
206
|
+
ignoreReadBeforeAssign: true
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
'prefer-exponentiation-operator': 'error',
|
|
210
|
+
'prefer-regex-literals': [
|
|
211
|
+
'error',
|
|
212
|
+
{
|
|
213
|
+
disallowRedundantWrapping: true
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
'prefer-rest-params': 'error',
|
|
217
|
+
'prefer-spread': 'error',
|
|
218
|
+
'prefer-template': 'error',
|
|
219
|
+
'require-await': 'error',
|
|
220
|
+
'unicode-bom': [
|
|
221
|
+
'error',
|
|
222
|
+
'never'
|
|
223
|
+
],
|
|
224
|
+
'use-isnan': [
|
|
225
|
+
'error',
|
|
226
|
+
{
|
|
227
|
+
enforceForIndexOf: true,
|
|
228
|
+
enforceForSwitchCase: true
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
'valid-typeof': [
|
|
232
|
+
'error',
|
|
233
|
+
{
|
|
234
|
+
requireStringLiterals: true
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
'vars-on-top': 'error'
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
const jest = ()=>[
|
|
242
|
+
{
|
|
243
|
+
...jestPlugin.configs.recommended,
|
|
244
|
+
files: [
|
|
245
|
+
...GLOB_TESTS
|
|
246
|
+
],
|
|
247
|
+
name: 'heyq02/jest/recommended'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
...jestPlugin.configs.style,
|
|
251
|
+
files: [
|
|
252
|
+
...GLOB_TESTS
|
|
253
|
+
],
|
|
254
|
+
name: 'heyq02/jest/style'
|
|
255
|
+
}
|
|
256
|
+
];
|
|
257
|
+
const node = (preset = 'module')=>{
|
|
258
|
+
if ('mixed' === preset) return nodePlugin.configs.recommended.map((entry, index)=>({
|
|
259
|
+
...entry,
|
|
260
|
+
name: entry.name ?? `heyq02/node/recommended-${index}`
|
|
261
|
+
}));
|
|
262
|
+
if ("script" === preset) return [
|
|
263
|
+
{
|
|
264
|
+
...nodePlugin.configs.recommendedScript,
|
|
265
|
+
files: [
|
|
266
|
+
GLOB_SRC
|
|
267
|
+
],
|
|
268
|
+
name: "heyq02/node/recommended-script"
|
|
269
|
+
}
|
|
270
|
+
];
|
|
271
|
+
return [
|
|
272
|
+
{
|
|
273
|
+
...nodePlugin.configs.recommendedModule,
|
|
274
|
+
files: [
|
|
275
|
+
GLOB_SRC
|
|
276
|
+
],
|
|
277
|
+
name: 'heyq02/node/recommended-module'
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
files: [
|
|
281
|
+
GLOB_SRC
|
|
282
|
+
],
|
|
283
|
+
name: 'heyq02/node',
|
|
284
|
+
plugins: [
|
|
285
|
+
'node'
|
|
286
|
+
],
|
|
287
|
+
rules: {
|
|
288
|
+
'node/handle-callback-err': [
|
|
289
|
+
'error',
|
|
290
|
+
'^(err|error)$'
|
|
291
|
+
],
|
|
292
|
+
'node/no-deprecated-api': 'error',
|
|
293
|
+
'node/no-exports-assign': 'error',
|
|
294
|
+
'node/no-new-require': 'error',
|
|
295
|
+
'node/no-path-concat': 'error',
|
|
296
|
+
'node/prefer-global/buffer': [
|
|
297
|
+
'error',
|
|
298
|
+
'never'
|
|
299
|
+
],
|
|
300
|
+
'node/prefer-global/process': [
|
|
301
|
+
'error',
|
|
302
|
+
'never'
|
|
303
|
+
],
|
|
304
|
+
'node/process-exit-as-throw': 'error'
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
];
|
|
308
|
+
};
|
|
309
|
+
const promise = ()=>[
|
|
310
|
+
{
|
|
311
|
+
...promisePlugin.configs.recommended,
|
|
312
|
+
files: [
|
|
313
|
+
GLOB_SRC
|
|
314
|
+
],
|
|
315
|
+
name: 'heyq02/promise/recommended'
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
files: [
|
|
319
|
+
GLOB_SRC
|
|
320
|
+
],
|
|
321
|
+
name: 'heyq02/promise',
|
|
322
|
+
rules: {
|
|
323
|
+
'promise/always-return': 'off',
|
|
324
|
+
'promise/catch-or-return': 'off',
|
|
325
|
+
'promise/no-nesting': 'off'
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
const reactFiles = [
|
|
330
|
+
GLOB_JSX,
|
|
331
|
+
GLOB_TSX,
|
|
332
|
+
'**/*.{jsx,tsx}'
|
|
333
|
+
];
|
|
334
|
+
const jsxA11y = ()=>[
|
|
335
|
+
{
|
|
336
|
+
...jsxA11yPlugin.configs.recommended,
|
|
337
|
+
files: reactFiles,
|
|
338
|
+
name: 'heyq02/jsx-a11y/recommended'
|
|
339
|
+
}
|
|
340
|
+
];
|
|
341
|
+
const react = (options = {})=>{
|
|
342
|
+
const configs = [
|
|
343
|
+
{
|
|
344
|
+
...reactPlugin.configs.recommended,
|
|
345
|
+
files: reactFiles,
|
|
346
|
+
name: 'heyq02/react/recommended'
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
...reactHooksPlugin.configs.recommended,
|
|
350
|
+
files: reactFiles,
|
|
351
|
+
name: 'heyq02/react-hooks/recommended'
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
if (false !== options.jsxA11y) configs.push(...jsxA11y());
|
|
355
|
+
return configs;
|
|
356
|
+
};
|
|
357
|
+
const rstest = ()=>[
|
|
358
|
+
{
|
|
359
|
+
...rstestPlugin.configs.recommended,
|
|
360
|
+
files: [
|
|
361
|
+
...GLOB_TESTS
|
|
362
|
+
],
|
|
363
|
+
name: 'heyq02/rstest/recommended'
|
|
364
|
+
}
|
|
365
|
+
];
|
|
366
|
+
const specialCases = ()=>[
|
|
367
|
+
{
|
|
368
|
+
files: [
|
|
369
|
+
"**/scripts/*",
|
|
370
|
+
'**/cli.*',
|
|
371
|
+
'**/bin/**'
|
|
372
|
+
],
|
|
373
|
+
name: 'heyq02/special/cli',
|
|
374
|
+
rules: {
|
|
375
|
+
'no-console': 'off'
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
files: [
|
|
380
|
+
`**/*.{test,spec}.${GLOB_SRC_EXT}`
|
|
381
|
+
],
|
|
382
|
+
name: 'heyq02/special/tests',
|
|
383
|
+
rules: {
|
|
384
|
+
'no-unused-expressions': 'off',
|
|
385
|
+
"@typescript-eslint/no-unused-expressions": 'off'
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
files: [
|
|
390
|
+
`**/*config*.${GLOB_SRC_EXT}`,
|
|
391
|
+
`**/{views,pages,routes,middleware,plugins,api,modules}/${GLOB_SRC}`,
|
|
392
|
+
`**/{index,vite,esbuild,rollup,rolldown,webpack,rspack,farm,unloader,nuxt,rslint}.${GLOB_SRC_EXT}`,
|
|
393
|
+
'**/*.d.ts',
|
|
394
|
+
'**/.prettierrc*'
|
|
395
|
+
],
|
|
396
|
+
name: 'heyq02/special/allow-default-export',
|
|
397
|
+
rules: {
|
|
398
|
+
'import/no-default-export': 'off'
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
files: [
|
|
403
|
+
'**/ISSUE_TEMPLATE/**'
|
|
404
|
+
],
|
|
405
|
+
name: 'heyq02/special/github',
|
|
406
|
+
rules: {
|
|
407
|
+
'unicorn/filename-case': 'off'
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
files: [
|
|
412
|
+
GLOB_JSX,
|
|
413
|
+
GLOB_TSX
|
|
414
|
+
],
|
|
415
|
+
name: 'heyq02/special/components',
|
|
416
|
+
rules: {
|
|
417
|
+
'unicorn/no-anonymous-default-export': 'off',
|
|
418
|
+
'import/no-default-export': 'off'
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
];
|
|
422
|
+
function resolveTypeScriptOptions(options) {
|
|
423
|
+
if (true === options) return {
|
|
424
|
+
typeChecked: false,
|
|
425
|
+
strict: false,
|
|
426
|
+
stylistic: true
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
typeChecked: options.typeChecked ?? false,
|
|
430
|
+
strict: options.strict ?? false,
|
|
431
|
+
stylistic: options.stylistic ?? true,
|
|
432
|
+
projectService: options.projectService
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
const typescript = (options = true)=>{
|
|
436
|
+
const opts = resolveTypeScriptOptions(options);
|
|
437
|
+
const baseline = opts.strict && opts.typeChecked ? ts.configs.strictTypeChecked : opts.strict ? ts.configs.strict : opts.typeChecked ? ts.configs.recommendedTypeChecked : ts.configs.recommended;
|
|
438
|
+
const stylistic = opts.stylistic ? opts.typeChecked ? ts.configs.stylisticTypeChecked : ts.configs.stylistic : [];
|
|
439
|
+
const enableProjectService = opts.projectService ?? (opts.typeChecked ? true : void 0);
|
|
440
|
+
return [
|
|
441
|
+
...baseline,
|
|
442
|
+
...stylistic,
|
|
443
|
+
{
|
|
444
|
+
files: [
|
|
445
|
+
GLOB_TS,
|
|
446
|
+
GLOB_TSX
|
|
447
|
+
],
|
|
448
|
+
name: "heyq02/typescript",
|
|
449
|
+
...void 0 === enableProjectService ? {} : {
|
|
450
|
+
languageOptions: {
|
|
451
|
+
parserOptions: {
|
|
452
|
+
projectService: enableProjectService
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
rules: {
|
|
457
|
+
"@typescript-eslint/ban-ts-comment": 'off',
|
|
458
|
+
"@typescript-eslint/consistent-type-assertions": [
|
|
459
|
+
'error',
|
|
460
|
+
{
|
|
461
|
+
assertionStyle: 'as',
|
|
462
|
+
objectLiteralTypeAssertions: 'allow-as-parameter'
|
|
463
|
+
}
|
|
464
|
+
],
|
|
465
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
466
|
+
'error',
|
|
467
|
+
{
|
|
468
|
+
disallowTypeAnnotations: false,
|
|
469
|
+
fixStyle: 'inline-type-imports'
|
|
470
|
+
}
|
|
471
|
+
],
|
|
472
|
+
"@typescript-eslint/method-signature-style": [
|
|
473
|
+
'error',
|
|
474
|
+
'property'
|
|
475
|
+
],
|
|
476
|
+
"@typescript-eslint/no-empty-object-type": 'off',
|
|
477
|
+
"@typescript-eslint/no-explicit-any": 'off',
|
|
478
|
+
"@typescript-eslint/no-import-type-side-effects": 'error',
|
|
479
|
+
"@typescript-eslint/no-non-null-assertion": 'off',
|
|
480
|
+
"@typescript-eslint/no-redeclare": 'error',
|
|
481
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
482
|
+
'error',
|
|
483
|
+
{
|
|
484
|
+
allowShortCircuit: true,
|
|
485
|
+
allowTaggedTemplates: true,
|
|
486
|
+
allowTernary: true
|
|
487
|
+
}
|
|
488
|
+
],
|
|
489
|
+
"@typescript-eslint/no-unused-vars": [
|
|
490
|
+
'error',
|
|
491
|
+
{
|
|
492
|
+
args: 'after-used',
|
|
493
|
+
argsIgnorePattern: '^_',
|
|
494
|
+
ignoreRestSiblings: true,
|
|
495
|
+
varsIgnorePattern: '^_'
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
"@typescript-eslint/no-useless-constructor": 'error',
|
|
499
|
+
"@typescript-eslint/prefer-as-const": 'warn',
|
|
500
|
+
"@typescript-eslint/prefer-literal-enum-member": [
|
|
501
|
+
'error',
|
|
502
|
+
{
|
|
503
|
+
allowBitwiseExpressions: true
|
|
504
|
+
}
|
|
505
|
+
],
|
|
506
|
+
'no-restricted-syntax': [
|
|
507
|
+
'error',
|
|
508
|
+
...restrictedSyntaxJs,
|
|
509
|
+
'TSEnumDeclaration[const=true]'
|
|
510
|
+
],
|
|
511
|
+
'no-unused-vars': 'off'
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
files: [
|
|
516
|
+
'**/*.d.ts'
|
|
517
|
+
],
|
|
518
|
+
name: "heyq02/typescript/dts-rules",
|
|
519
|
+
rules: {
|
|
520
|
+
'import/no-duplicates': 'off',
|
|
521
|
+
'no-restricted-syntax': 'off'
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
files: [
|
|
526
|
+
GLOB_JS,
|
|
527
|
+
'**/*.cjs'
|
|
528
|
+
],
|
|
529
|
+
name: "heyq02/typescript/cjs-rules",
|
|
530
|
+
rules: {
|
|
531
|
+
"@typescript-eslint/no-require-imports": 'off'
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
];
|
|
535
|
+
};
|
|
536
|
+
const unicorn = ()=>[
|
|
537
|
+
{
|
|
538
|
+
...unicornPlugin.configs.recommended,
|
|
539
|
+
files: [
|
|
540
|
+
GLOB_SRC
|
|
541
|
+
],
|
|
542
|
+
name: 'heyq02/unicorn/recommended'
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
files: [
|
|
546
|
+
GLOB_SRC
|
|
547
|
+
],
|
|
548
|
+
name: 'heyq02/unicorn',
|
|
549
|
+
rules: {
|
|
550
|
+
'unicorn/filename-case': [
|
|
551
|
+
'error',
|
|
552
|
+
{
|
|
553
|
+
cases: {
|
|
554
|
+
kebabCase: true,
|
|
555
|
+
pascalCase: true
|
|
556
|
+
},
|
|
557
|
+
ignore: [
|
|
558
|
+
String.raw`^[A-Z]+\..*$`,
|
|
559
|
+
String.raw`^[a-z]{2}-[A-Z]{2}$`,
|
|
560
|
+
String.raw`import_map\.json`
|
|
561
|
+
]
|
|
562
|
+
}
|
|
563
|
+
],
|
|
564
|
+
'unicorn/no-null': 'off',
|
|
565
|
+
'unicorn/no-this-assignment': 'off',
|
|
566
|
+
'unicorn/prefer-ternary': 'off',
|
|
567
|
+
'unicorn/no-process-exit': 'off'
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
];
|
|
571
|
+
const env_require = createRequire(import.meta.url);
|
|
572
|
+
const cwd = node_process.cwd();
|
|
573
|
+
function isPackageExists(name) {
|
|
574
|
+
try {
|
|
575
|
+
env_require.resolve(name, {
|
|
576
|
+
paths: [
|
|
577
|
+
cwd
|
|
578
|
+
]
|
|
579
|
+
});
|
|
580
|
+
return true;
|
|
581
|
+
} catch {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const hasTypeScript = ()=>isPackageExists("typescript");
|
|
586
|
+
const hasReact = ()=>isPackageExists('react') || isPackageExists('react-dom') || isPackageExists('next') || isPackageExists('preact') || isPackageExists('@remix-run/react');
|
|
587
|
+
const hasJest = ()=>isPackageExists('jest') || isPackageExists('@jest/globals');
|
|
588
|
+
const hasRstest = ()=>isPackageExists('rstest') || isPackageExists('@rstest/core') || isPackageExists('@rstest/adapter');
|
|
589
|
+
function isInEditorEnv() {
|
|
590
|
+
if (node_process.env.CI) return false;
|
|
591
|
+
if (isInGitHooksOrLintStaged()) return false;
|
|
592
|
+
return !!(node_process.env.VSCODE_PID || node_process.env.VSCODE_CWD || node_process.env.JETBRAINS_IDE || node_process.env.VIM || node_process.env.NVIM);
|
|
593
|
+
}
|
|
594
|
+
function isInGitHooksOrLintStaged() {
|
|
595
|
+
return !!(node_process.env.GIT_PARAMS || node_process.env.VSCODE_GIT_COMMAND || node_process.env.npm_lifecycle_script?.startsWith('lint-staged'));
|
|
596
|
+
}
|
|
597
|
+
function flattenConfigs(...configs) {
|
|
598
|
+
const result = [];
|
|
599
|
+
for (const config of configs)if (config) {
|
|
600
|
+
if (Array.isArray(config)) {
|
|
601
|
+
result.push(...flattenConfigs(...config));
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
result.push(config);
|
|
605
|
+
}
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
function toArray(value) {
|
|
609
|
+
return Array.isArray(value) ? value : [
|
|
610
|
+
value
|
|
611
|
+
];
|
|
612
|
+
}
|
|
613
|
+
const presetJavaScript = ()=>[
|
|
614
|
+
...ignores(),
|
|
615
|
+
...javascript(),
|
|
616
|
+
...imports({
|
|
617
|
+
typescript: false
|
|
618
|
+
}),
|
|
619
|
+
...unicorn(),
|
|
620
|
+
...node(),
|
|
621
|
+
...promise()
|
|
622
|
+
];
|
|
623
|
+
const presetBasic = (typescriptOptions = true)=>[
|
|
624
|
+
...ignores(),
|
|
625
|
+
...javascript(),
|
|
626
|
+
...typescript(typescriptOptions),
|
|
627
|
+
...imports({
|
|
628
|
+
typescript: true
|
|
629
|
+
}),
|
|
630
|
+
...unicorn(),
|
|
631
|
+
...node(),
|
|
632
|
+
...promise()
|
|
633
|
+
];
|
|
634
|
+
const presetAll = ()=>heyq02({
|
|
635
|
+
typescript: true,
|
|
636
|
+
react: true,
|
|
637
|
+
jest: true,
|
|
638
|
+
rstest: true,
|
|
639
|
+
jsxA11y: true
|
|
640
|
+
});
|
|
641
|
+
function heyq02(options = {}, ...userConfigs) {
|
|
642
|
+
const { ignores: extraIgnores = [], javascript: enableJavaScript = true, typescript: enableTypeScript = hasTypeScript(), unicorn: enableUnicorn = true, imports: enableImports = true, node: enableNode = true, promise: enablePromise = true, react: enableReact = hasReact(), jsxA11y: enableJsxA11y, jest: enableJest = hasJest(), rstest: enableRstest = hasRstest() } = options;
|
|
643
|
+
const configs = [
|
|
644
|
+
...ignores(extraIgnores)
|
|
645
|
+
];
|
|
646
|
+
if (enableJavaScript) configs.push(...javascript());
|
|
647
|
+
if (enableTypeScript) configs.push(...typescript(true === enableTypeScript ? true : enableTypeScript));
|
|
648
|
+
if (enableImports) configs.push(...imports({
|
|
649
|
+
typescript: Boolean(enableTypeScript)
|
|
650
|
+
}));
|
|
651
|
+
if (enableUnicorn) configs.push(...unicorn());
|
|
652
|
+
if (enableNode) configs.push(...node(true === enableNode ? 'module' : enableNode));
|
|
653
|
+
if (enablePromise) configs.push(...promise());
|
|
654
|
+
if (enableReact) configs.push(...react({
|
|
655
|
+
jsxA11y: enableJsxA11y ?? true
|
|
656
|
+
}));
|
|
657
|
+
else if (enableJsxA11y) configs.push(...jsxA11y());
|
|
658
|
+
if (enableJest) configs.push(...jest());
|
|
659
|
+
if (enableRstest) configs.push(...rstest());
|
|
660
|
+
configs.push(...specialCases());
|
|
661
|
+
configs.push(...flattenConfigs(...userConfigs));
|
|
662
|
+
return configs;
|
|
663
|
+
}
|
|
664
|
+
const rslintConfig = heyq02;
|
|
665
|
+
export { GLOB_DIST, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_LOCKFILE, GLOB_NODE_MODULES, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TS, GLOB_TSX, flattenConfigs, hasJest, hasReact, hasRstest, hasTypeScript, heyq02, ignores, imports, isInEditorEnv, isInGitHooksOrLintStaged, javascript, jest, jsxA11y, node, presetAll, presetBasic, presetJavaScript, promise, react, restrictedSyntaxJs, rslintConfig, rstest, specialCases, toArray, typescript, unicorn };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Options, ResolvableConfig, TypeScriptOptions, TypedFlatConfig } from './types.js';
|
|
2
|
+
/** Ignore common files and include JavaScript support. */
|
|
3
|
+
export declare const presetJavaScript: () => TypedFlatConfig[];
|
|
4
|
+
/** Includes `presetJavaScript` and TypeScript support. */
|
|
5
|
+
export declare const presetBasic: (typescriptOptions?: true | TypeScriptOptions) => TypedFlatConfig[];
|
|
6
|
+
/**
|
|
7
|
+
* Full opinionated preset:
|
|
8
|
+
* - JS + TS
|
|
9
|
+
* - Unicorn / import / node / promise
|
|
10
|
+
* - React / Jest / Rstest when detected
|
|
11
|
+
* - Special-case overrides
|
|
12
|
+
*/
|
|
13
|
+
export declare const presetAll: () => TypedFlatConfig[];
|
|
14
|
+
/**
|
|
15
|
+
* `@heyq02`'s opinionated Rslint config preset.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // rslint.config.ts
|
|
20
|
+
* import { heyq02 } from '@heyq02/rslint-config'
|
|
21
|
+
*
|
|
22
|
+
* export default heyq02({
|
|
23
|
+
* typescript: { typeChecked: true, strict: true },
|
|
24
|
+
* react: true,
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function heyq02(options?: Options, ...userConfigs: ResolvableConfig[]): TypedFlatConfig[];
|
|
29
|
+
/** Alias of {@link heyq02}. */
|
|
30
|
+
export declare const rslintConfig: typeof heyq02;
|