@aiou/eslint-config 3.0.1 → 3.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.
Files changed (2) hide show
  1. package/package.json +5 -7
  2. package/dist/index.cjs +0 -1402
package/dist/index.cjs DELETED
@@ -1,1402 +0,0 @@
1
- 'use strict';
2
-
3
- var eslintFlatConfigUtils = require('eslint-flat-config-utils');
4
- var localPkg = require('local-pkg');
5
- var pluginComments = require('@eslint-community/eslint-plugin-eslint-comments');
6
- var ignoreGlobs = require('@aiou/eslint-ignore');
7
- var pluginImportNewlines = require('eslint-plugin-import-newlines');
8
- var pluginImport = require('eslint-plugin-import-x');
9
- var pluginSimpleImportSort = require('eslint-plugin-simple-import-sort');
10
- var pluginUnsedImports = require('eslint-plugin-unused-imports');
11
- var pluginN = require('eslint-plugin-n');
12
- var pluginPromise = require('eslint-plugin-promise');
13
- var globals = require('globals');
14
- var pluginJsonc = require('eslint-plugin-jsonc');
15
- var pluginMarkdown = require('@eslint/markdown');
16
- var pluginNext = require('@next/eslint-plugin-next');
17
- var pluginProgress = require('@aiou/eslint-plugin-progress');
18
- var pluginReact = require('@eslint-react/eslint-plugin');
19
- var pluginReactHooks = require('eslint-plugin-react-hooks');
20
- var pluginReactRefresh = require('eslint-plugin-react-refresh');
21
- var eslintPluginRegexp = require('eslint-plugin-regexp');
22
- var pluginStylistic = require('@stylistic/eslint-plugin');
23
- var node_module = require('node:module');
24
- var pluginToml = require('eslint-plugin-toml');
25
- var pluginTypeScript = require('@typescript-eslint/eslint-plugin');
26
- var tsParser = require('@typescript-eslint/parser');
27
- var pluginETC = require('eslint-plugin-etc');
28
- var pluginUnicorn = require('eslint-plugin-unicorn');
29
- var pluginYml = require('eslint-plugin-yml');
30
-
31
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
32
-
33
- var pluginComments__default = /*#__PURE__*/_interopDefault(pluginComments);
34
- var ignoreGlobs__default = /*#__PURE__*/_interopDefault(ignoreGlobs);
35
- var pluginImportNewlines__default = /*#__PURE__*/_interopDefault(pluginImportNewlines);
36
- var pluginImport__default = /*#__PURE__*/_interopDefault(pluginImport);
37
- var pluginSimpleImportSort__default = /*#__PURE__*/_interopDefault(pluginSimpleImportSort);
38
- var pluginUnsedImports__default = /*#__PURE__*/_interopDefault(pluginUnsedImports);
39
- var pluginN__default = /*#__PURE__*/_interopDefault(pluginN);
40
- var pluginPromise__default = /*#__PURE__*/_interopDefault(pluginPromise);
41
- var globals__default = /*#__PURE__*/_interopDefault(globals);
42
- var pluginJsonc__default = /*#__PURE__*/_interopDefault(pluginJsonc);
43
- var pluginMarkdown__default = /*#__PURE__*/_interopDefault(pluginMarkdown);
44
- var pluginNext__default = /*#__PURE__*/_interopDefault(pluginNext);
45
- var pluginProgress__default = /*#__PURE__*/_interopDefault(pluginProgress);
46
- var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
47
- var pluginReactHooks__default = /*#__PURE__*/_interopDefault(pluginReactHooks);
48
- var pluginReactRefresh__default = /*#__PURE__*/_interopDefault(pluginReactRefresh);
49
- var pluginStylistic__default = /*#__PURE__*/_interopDefault(pluginStylistic);
50
- var pluginToml__default = /*#__PURE__*/_interopDefault(pluginToml);
51
- var pluginTypeScript__default = /*#__PURE__*/_interopDefault(pluginTypeScript);
52
- var tsParser__default = /*#__PURE__*/_interopDefault(tsParser);
53
- var pluginETC__default = /*#__PURE__*/_interopDefault(pluginETC);
54
- var pluginUnicorn__default = /*#__PURE__*/_interopDefault(pluginUnicorn);
55
- var pluginYml__default = /*#__PURE__*/_interopDefault(pluginYml);
56
-
57
- const comments = () => {
58
- const config = [
59
- {
60
- plugins: {
61
- "eslint-comments": pluginComments__default.default
62
- },
63
- rules: {
64
- "eslint-comments/disable-enable-pair": "off",
65
- "eslint-comments/no-aggregating-enable": "error",
66
- "eslint-comments/no-duplicate-disable": "error",
67
- "eslint-comments/no-unlimited-disable": "error",
68
- "eslint-comments/no-unused-enable": "error"
69
- }
70
- }
71
- ];
72
- return config;
73
- };
74
-
75
- const ignores = () => {
76
- const config = [
77
- {
78
- ignores: ignoreGlobs__default.default
79
- }
80
- ];
81
- return config;
82
- };
83
-
84
- const GLOB_SCRIPT_EXT = "?([cm])[jt]s?(x)";
85
- const GLOB_TEST_SCRIPT = "**/*.{spec,test}.?([cm])[jt]s?(x)";
86
- const GLOB_TEST_DIRS = "**/{test,tests,e2e,__test__,__tests__}/**";
87
- const GLOB_PAGES_DIRS = "**/{pages,routes}/**";
88
- const GLOB_PAGES_COMPONENTS_DIRS = "**/{pages,routes}/components/**";
89
- const GLOB_DTS = "**/*.d.ts";
90
- const GLOB_TS = "**/*.?([cm])ts";
91
- const GLOB_TSX = "**/*.?([cm])tsx";
92
- const GLOB_JS = "**/*.?([cm])js";
93
- const GLOB_JSX = "**/*.?([cm])jsx";
94
- const GLOB_JSON = "**/*.json";
95
- const GLOB_JSON5 = "**/*.json5";
96
- const GLOB_JSONC = "**/*.jsonc";
97
- const GLOB_CLAUDE_JSON = "**/.claude/*.json";
98
- const GLOB_MARKDOWN = "**/*.md";
99
- const GLOB_YAML = "**/*.y?(a)ml";
100
- const GLOB_WORKFLOW_YAML = "**/.github/**/*.y?(a)ml";
101
-
102
- const imports = () => {
103
- const config = [
104
- {
105
- plugins: {
106
- import: pluginImport__default.default,
107
- "simple-import-sort": pluginSimpleImportSort__default.default,
108
- "import-newlines": pluginImportNewlines__default.default,
109
- "unused-imports": pluginUnsedImports__default.default
110
- },
111
- rules: {
112
- // import
113
- // off: controlled by import/order
114
- "import/order": "off",
115
- "sort-imports": "off",
116
- "simple-import-sort/imports": [
117
- "warn",
118
- {
119
- groups: [
120
- // Side effect imports.
121
- ["^\\u0000"],
122
- // Node.js builtins prefixed with `node:`.
123
- ["^node:"],
124
- // Packages.
125
- // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
126
- ["^@?\\w"],
127
- // Relative imports.
128
- // Absolute imports and other imports such as `@/foo` or `~/foo`.
129
- // Anything not matched in another group.
130
- ["^", "^\\.", "^@/\\w", "^~/\\w"],
131
- // Virtual modules prefixed with `virtual:` or `virtual-`, rollup & vite favor
132
- ["^virtual:", "^virtual-"],
133
- // Types
134
- ["^[^/\\.].*\0$", "^\\..*\0$"]
135
- ]
136
- }
137
- ],
138
- "simple-import-sort/exports": "off",
139
- "import/first": "error",
140
- "import/newline-after-import": "error",
141
- "import/no-duplicates": "error",
142
- "import/no-mutable-exports": "error",
143
- "import/no-unresolved": "off",
144
- "import/no-absolute-path": "off",
145
- "import/dynamic-import-chunkname": [2, {
146
- allowEmpty: true
147
- }],
148
- // Not allowed import devDependencies
149
- "import/no-extraneous-dependencies": ["error", { devDependencies: false }],
150
- // Not allow import { default as named }
151
- "import/no-named-default": "warn",
152
- "unused-imports/no-unused-imports": "error",
153
- "unused-imports/no-unused-vars": [
154
- "warn",
155
- {
156
- // https://github.com/sweepline/eslint-plugin-unused-imports/issues/105
157
- caughtErrors: "all",
158
- caughtErrorsIgnorePattern: "^_",
159
- vars: "all",
160
- varsIgnorePattern: "^_",
161
- args: "after-used",
162
- argsIgnorePattern: "^_"
163
- }
164
- ],
165
- // Enforce newlines inside named import
166
- "import-newlines/enforce": [
167
- "error",
168
- {
169
- items: 2,
170
- "max-len": 120,
171
- semi: false
172
- }
173
- ]
174
- }
175
- },
176
- {
177
- files: [GLOB_DTS],
178
- rules: {
179
- "import/no-duplicates": "off"
180
- }
181
- },
182
- {
183
- files: [GLOB_TSX, GLOB_JSX],
184
- rules: {
185
- // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
186
- // export anonymous function: ReactRefresh failed
187
- "import/no-anonymous-default-export": "error",
188
- // perfer named export
189
- "import/no-default-export": "error"
190
- }
191
- },
192
- {
193
- files: [
194
- `**/*config*.${GLOB_SCRIPT_EXT}`,
195
- `**/{app,pages,routes}/**/*.${GLOB_SCRIPT_EXT}`,
196
- `**/App*.${GLOB_SCRIPT_EXT}`,
197
- `**/Document.${GLOB_SCRIPT_EXT}`,
198
- "**/{vite,esbuild,rollup,webpack,rspack}.ts",
199
- // Allow default export in page and route file
200
- `**/{page,route}.${GLOB_SCRIPT_EXT}`,
201
- GLOB_DTS,
202
- GLOB_TEST_SCRIPT,
203
- GLOB_TEST_DIRS
204
- ],
205
- rules: {
206
- // related: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
207
- // export anonymous function: ReactRefresh failed
208
- "import/no-anonymous-default-export": "off",
209
- "import/no-default-export": "off"
210
- }
211
- },
212
- {
213
- files: [
214
- // ignore devDependencies on scripts files
215
- `**/script?(s)/**/*.${GLOB_SCRIPT_EXT}`,
216
- `**/**/script?(s).${GLOB_SCRIPT_EXT}`,
217
- `**/*config*.${GLOB_SCRIPT_EXT}`,
218
- // ignore devDependencies on test files
219
- GLOB_TEST_SCRIPT,
220
- GLOB_TEST_DIRS,
221
- // ignore require third packages in .eslintrc.* e.g. eslint-define-config
222
- `**/.eslintrc.${GLOB_SCRIPT_EXT}`,
223
- `**/**/eslint.config.${GLOB_SCRIPT_EXT}`,
224
- "**/{vite,esbuild,rollup,webpack,rspack}.ts"
225
- ],
226
- rules: {
227
- "import/no-extraneous-dependencies": "off"
228
- }
229
- }
230
- ];
231
- return config;
232
- };
233
-
234
- const javascript = () => {
235
- const config = [
236
- {
237
- languageOptions: {
238
- globals: {
239
- ...globals__default.default.browser,
240
- ...globals__default.default.es2021,
241
- ...globals__default.default.node
242
- },
243
- parserOptions: {
244
- ecmaFeatures: {
245
- jsx: true
246
- },
247
- // Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
248
- // This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
249
- ecmaVersion: "latest",
250
- sourceType: "module"
251
- },
252
- sourceType: "module"
253
- },
254
- settings: {
255
- // This will do the trick
256
- "import/parsers": {
257
- espree: [".js", ".cjs", ".mjs", ".jsx"]
258
- },
259
- "import/resolver": {
260
- node: true
261
- }
262
- },
263
- plugins: {
264
- n: pluginN__default.default,
265
- promise: pluginPromise__default.default
266
- },
267
- rules: {
268
- // from standard
269
- // "no-var": "warn",
270
- // "object-shorthand": ["warn", "properties"],
271
- "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
272
- "array-bracket-spacing": ["error", "never"],
273
- // "array-callback-return": ["error", {
274
- // "allowImplicit": false,
275
- // "checkForEach": false
276
- // }],
277
- "arrow-spacing": ["error", { before: true, after: true }],
278
- "block-spacing": ["error", "always"],
279
- "brace-style": ["error", "1tbs", { allowSingleLine: true }],
280
- // "camelcase": ["error", {
281
- // "allow": ["^UNSAFE_"],
282
- // "properties": "never",
283
- // "ignoreGlobals": true
284
- // }],
285
- "comma-dangle": ["error", {
286
- arrays: "never",
287
- objects: "never",
288
- imports: "never",
289
- exports: "never",
290
- functions: "never"
291
- }],
292
- "comma-spacing": ["error", { before: false, after: true }],
293
- "comma-style": ["error", "last"],
294
- "computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
295
- "constructor-super": "error",
296
- // "curly": ["error", "multi-line"],
297
- "default-case-last": "error",
298
- "dot-location": ["error", "property"],
299
- "dot-notation": ["error", { allowKeywords: true }],
300
- "eol-last": "error",
301
- // "eqeqeq": ["error", "always", { "null": "ignore" }],
302
- "func-call-spacing": ["error", "never"],
303
- "generator-star-spacing": ["error", { before: true, after: true }],
304
- indent: "off",
305
- "key-spacing": ["error", { beforeColon: false, afterColon: true }],
306
- "keyword-spacing": ["error", { before: true, after: true }],
307
- "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
308
- "multiline-ternary": ["error", "always-multiline"],
309
- "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
310
- "new-parens": "error",
311
- "no-array-constructor": "error",
312
- "no-async-promise-executor": "error",
313
- "no-caller": "error",
314
- // "no-case-declarations": "error",
315
- "no-class-assign": "error",
316
- "no-compare-neg-zero": "error",
317
- // "no-cond-assign": "error",
318
- "no-const-assign": "error",
319
- // "no-constant-condition": ["error", { "checkLoops": false }],
320
- "no-control-regex": "error",
321
- // "no-debugger": "error",
322
- "no-delete-var": "error",
323
- "no-dupe-args": "error",
324
- "no-dupe-class-members": "error",
325
- "no-dupe-keys": "error",
326
- "no-duplicate-case": "error",
327
- "no-useless-backreference": "error",
328
- "no-empty": ["error", { allowEmptyCatch: true }],
329
- "no-empty-character-class": "error",
330
- "no-empty-pattern": "error",
331
- "no-eval": "error",
332
- "no-ex-assign": "error",
333
- "no-extend-native": "error",
334
- "no-extra-bind": "error",
335
- "no-extra-boolean-cast": "error",
336
- "no-extra-parens": ["error", "functions"],
337
- "no-fallthrough": "error",
338
- "no-floating-decimal": "error",
339
- "no-func-assign": "error",
340
- "no-global-assign": "error",
341
- "no-implied-eval": "error",
342
- "no-import-assign": "error",
343
- "no-invalid-regexp": "error",
344
- "no-irregular-whitespace": "error",
345
- "no-iterator": "error",
346
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
347
- "no-lone-blocks": "error",
348
- "no-loss-of-precision": "error",
349
- "no-misleading-character-class": "error",
350
- "no-prototype-builtins": "error",
351
- "no-useless-catch": "error",
352
- "no-mixed-operators": ["error", {
353
- groups: [
354
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
355
- ["&&", "||"],
356
- ["in", "instanceof"]
357
- ],
358
- allowSamePrecedence: true
359
- }],
360
- "no-mixed-spaces-and-tabs": "error",
361
- "no-multi-spaces": "error",
362
- // "no-multi-str": "error",
363
- "no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
364
- "no-new": "error",
365
- "no-new-func": "error",
366
- "no-new-object": "error",
367
- "no-new-symbol": "error",
368
- "no-new-wrappers": "error",
369
- "no-obj-calls": "error",
370
- "no-octal": "error",
371
- "no-octal-escape": "error",
372
- "no-proto": "error",
373
- "no-redeclare": ["error", { builtinGlobals: false }],
374
- "no-regex-spaces": "error",
375
- // "no-return-assign": ["error", "except-parens"],
376
- "no-self-assign": ["error", { props: true }],
377
- "no-self-compare": "error",
378
- "no-sequences": "error",
379
- "no-shadow-restricted-names": "error",
380
- "no-sparse-arrays": "error",
381
- "no-tabs": "error",
382
- "no-template-curly-in-string": "error",
383
- "no-this-before-super": "error",
384
- "no-throw-literal": "error",
385
- "no-trailing-spaces": "error",
386
- "no-undef": "error",
387
- "no-undef-init": "error",
388
- "no-unexpected-multiline": "error",
389
- "no-unmodified-loop-condition": "error",
390
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
391
- "no-unreachable": "error",
392
- "no-unreachable-loop": "error",
393
- "no-unsafe-finally": "error",
394
- "no-unsafe-negation": "error",
395
- "no-unused-expressions": ["error", {
396
- allowShortCircuit: true,
397
- allowTernary: true,
398
- allowTaggedTemplates: true
399
- }],
400
- // "no-unused-vars": ["error", {
401
- // "args": "none",
402
- // "caughtErrors": "none",
403
- // "ignoreRestSiblings": true,
404
- // "vars": "all"
405
- // }],
406
- "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
407
- "no-useless-call": "error",
408
- "no-useless-computed-key": "error",
409
- "no-useless-constructor": "error",
410
- // "no-useless-escape": "error",
411
- "no-useless-rename": "error",
412
- "no-useless-return": "error",
413
- // "no-void": "error",
414
- "no-whitespace-before-property": "error",
415
- "no-with": "error",
416
- "object-curly-newline": ["error", { multiline: true, consistent: true }],
417
- "object-curly-spacing": ["error", "always"],
418
- "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
419
- "one-var": ["error", { initialized: "never" }],
420
- "operator-linebreak": ["error", "after", { overrides: { "?": "before", ":": "before", "|>": "before" } }],
421
- "padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
422
- // "prefer-const": ["error", {"destructuring": "all"}],
423
- "prefer-promise-reject-errors": "error",
424
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
425
- "quote-props": ["error", "as-needed"],
426
- quotes: ["error", "single", { avoidEscape: true, allowTemplateLiterals: false }],
427
- "rest-spread-spacing": ["error", "never"],
428
- semi: ["error", "never"],
429
- "semi-spacing": ["error", { before: false, after: true }],
430
- "space-before-blocks": ["error", "always"],
431
- "space-before-function-paren": ["error", "always"],
432
- "space-in-parens": ["error", "never"],
433
- "space-infix-ops": "error",
434
- "space-unary-ops": ["error", { words: true, nonwords: false }],
435
- "spaced-comment": ["error", "always", {
436
- line: { markers: ["*package", "!", "/", ",", "="] },
437
- block: { balanced: true, markers: ["*package", "!", ",", ":", "::", "flow-include"], exceptions: ["*"] }
438
- }],
439
- "symbol-description": "error",
440
- "template-curly-spacing": ["error", "never"],
441
- "template-tag-spacing": ["error", "never"],
442
- "unicode-bom": ["error", "never"],
443
- "use-isnan": ["error", {
444
- enforceForSwitchCase: true,
445
- enforceForIndexOf: true
446
- }],
447
- "valid-typeof": ["error", { requireStringLiterals: true }],
448
- "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
449
- "yield-star-spacing": ["error", "both"],
450
- yoda: ["error", "never"],
451
- "import/export": "error",
452
- "import/first": "error",
453
- "import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
454
- "import/no-duplicates": "error",
455
- "import/no-named-default": "error",
456
- "import/no-webpack-loader-syntax": "error",
457
- "n/handle-callback-err": ["error", "^(err|error)$"],
458
- "n/no-callback-literal": "error",
459
- "n/no-deprecated-api": "error",
460
- "n/no-exports-assign": "error",
461
- "n/no-new-require": "error",
462
- "n/no-path-concat": "error",
463
- "n/process-exit-as-throw": "error",
464
- "promise/param-names": "error",
465
- "promise/no-new-statics": "error",
466
- "promise/no-multiple-resolved": "error",
467
- "promise/prefer-await-to-then": "off",
468
- // override
469
- curly: ["error", "all"],
470
- "no-unused-vars": "warn",
471
- "no-param-reassign": "off",
472
- camelcase: "off",
473
- "no-constant-condition": "warn",
474
- "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
475
- "no-console": process.env.NODE_ENV === "production" ? ["error", { allow: ["debug", "error", "warn"] }] : "off",
476
- "no-cond-assign": ["error", "always"],
477
- "no-restricted-syntax": [
478
- "error",
479
- "DebuggerStatement",
480
- "LabeledStatement",
481
- "WithStatement"
482
- ],
483
- "no-return-await": "off",
484
- // es6
485
- "no-var": "error",
486
- "prefer-const": [
487
- "error",
488
- {
489
- destructuring: "any",
490
- ignoreReadBeforeAssign: true
491
- }
492
- ],
493
- "prefer-arrow-callback": [
494
- "error",
495
- {
496
- allowNamedFunctions: false,
497
- allowUnboundThis: true
498
- }
499
- ],
500
- "object-shorthand": [
501
- "error",
502
- "always",
503
- {
504
- ignoreConstructors: false,
505
- avoidQuotes: true
506
- }
507
- ],
508
- "prefer-exponentiation-operator": "error",
509
- "prefer-rest-params": "error",
510
- "prefer-spread": "error",
511
- "prefer-template": "error",
512
- "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
513
- // best-practice
514
- "array-callback-return": "error",
515
- "block-scoped-var": "error",
516
- "consistent-return": "off",
517
- complexity: ["off", 11],
518
- eqeqeq: ["error", "allow-null"],
519
- "no-alert": "warn",
520
- "no-case-declarations": "error",
521
- "no-multi-str": "error",
522
- // 'no-with': 'error',
523
- "no-void": "error",
524
- "no-useless-escape": "off",
525
- "vars-on-top": "error",
526
- "require-await": "off",
527
- "no-return-assign": "off"
528
- }
529
- }
530
- ];
531
- return config;
532
- };
533
-
534
- const jsonc = () => {
535
- const config = [
536
- ...pluginJsonc__default.default.configs["recommended-with-jsonc"],
537
- {
538
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
539
- ignores: [GLOB_CLAUDE_JSON],
540
- rules: {
541
- "jsonc/array-bracket-newline": [
542
- "error",
543
- {
544
- multiline: true,
545
- minItems: null
546
- }
547
- ],
548
- "jsonc/array-bracket-spacing": ["error", "never"],
549
- "jsonc/comma-dangle": ["error", "never"],
550
- "jsonc/comma-style": ["error", "last"],
551
- "jsonc/indent": ["error", 2, {}],
552
- "jsonc/key-spacing": [
553
- "error",
554
- {
555
- beforeColon: false,
556
- afterColon: true,
557
- mode: "strict"
558
- }
559
- ],
560
- "jsonc/no-octal-escape": "error",
561
- "jsonc/object-curly-newline": ["error", { multiline: true, consistent: true }],
562
- "jsonc/object-curly-spacing": ["error", "always"]
563
- }
564
- },
565
- {
566
- files: ["**/package.json"],
567
- rules: {
568
- "jsonc/sort-keys": [
569
- "error",
570
- {
571
- pathPattern: "^$",
572
- order: [
573
- "name",
574
- "version",
575
- "type",
576
- "private",
577
- "packageManager",
578
- "description",
579
- "keywords",
580
- "license",
581
- "engines",
582
- "homepage",
583
- "repository",
584
- "bugs",
585
- "funding",
586
- "author",
587
- "sideEffects",
588
- "files",
589
- "bin",
590
- "exports",
591
- "main",
592
- "module",
593
- "browser",
594
- "typings",
595
- "types",
596
- "typeVersions",
597
- "unpkg",
598
- "scripts",
599
- "husky",
600
- "lint-staged",
601
- "peerDependencies",
602
- "peerDependenciesMeta",
603
- "dependencies",
604
- "optionalDependencies",
605
- "devDependencies",
606
- "pnpm",
607
- "overrides",
608
- "resolutions",
609
- "eslintConfig",
610
- "config"
611
- ]
612
- },
613
- {
614
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$",
615
- order: { type: "asc" }
616
- },
617
- {
618
- pathPattern: "^exports.*$",
619
- order: ["types", "import", "require", "node", "browser", "default"]
620
- },
621
- {
622
- order: { type: "asc" },
623
- pathPattern: "^resolutions$"
624
- },
625
- {
626
- order: { type: "asc" },
627
- pathPattern: "^pnpm.overrides$"
628
- }
629
- ]
630
- }
631
- },
632
- {
633
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
634
- rules: {
635
- "jsonc/sort-keys": [
636
- "error",
637
- {
638
- order: [
639
- "extends",
640
- "compilerOptions",
641
- "references",
642
- "files",
643
- "include",
644
- "exclude"
645
- ],
646
- pathPattern: "^$"
647
- },
648
- {
649
- order: [
650
- /* Projects */
651
- "incremental",
652
- "composite",
653
- "tsBuildInfoFile",
654
- "disableSourceOfProjectReferenceRedirect",
655
- "disableSolutionSearching",
656
- "disableReferencedProjectLoad",
657
- /* Language and Environment */
658
- "target",
659
- "jsx",
660
- "jsxFactory",
661
- "jsxFragmentFactory",
662
- "jsxImportSource",
663
- "lib",
664
- "moduleDetection",
665
- "noLib",
666
- "reactNamespace",
667
- "useDefineForClassFields",
668
- "emitDecoratorMetadata",
669
- "experimentalDecorators",
670
- /* Modules */
671
- "baseUrl",
672
- "rootDir",
673
- "rootDirs",
674
- "customConditions",
675
- "module",
676
- "moduleResolution",
677
- "moduleSuffixes",
678
- "noResolve",
679
- "paths",
680
- "resolveJsonModule",
681
- "resolvePackageJsonExports",
682
- "resolvePackageJsonImports",
683
- "typeRoots",
684
- "types",
685
- "allowArbitraryExtensions",
686
- "allowImportingTsExtensions",
687
- "allowUmdGlobalAccess",
688
- /* JavaScript Support */
689
- "allowJs",
690
- "checkJs",
691
- "maxNodeModuleJsDepth",
692
- /* Type Checking */
693
- "strict",
694
- "strictBindCallApply",
695
- "strictFunctionTypes",
696
- "strictNullChecks",
697
- "strictPropertyInitialization",
698
- "allowUnreachableCode",
699
- "allowUnusedLabels",
700
- "alwaysStrict",
701
- "exactOptionalPropertyTypes",
702
- "noFallthroughCasesInSwitch",
703
- "noImplicitAny",
704
- "noImplicitOverride",
705
- "noImplicitReturns",
706
- "noImplicitThis",
707
- "noPropertyAccessFromIndexSignature",
708
- "noUncheckedIndexedAccess",
709
- "noUnusedLocals",
710
- "noUnusedParameters",
711
- "useUnknownInCatchVariables",
712
- /* Emit */
713
- "declaration",
714
- "declarationDir",
715
- "declarationMap",
716
- "downlevelIteration",
717
- "emitBOM",
718
- "emitDeclarationOnly",
719
- "importHelpers",
720
- "importsNotUsedAsValues",
721
- "inlineSourceMap",
722
- "inlineSources",
723
- "mapRoot",
724
- "newLine",
725
- "noEmit",
726
- "noEmitHelpers",
727
- "noEmitOnError",
728
- "outDir",
729
- "outFile",
730
- "preserveConstEnums",
731
- "preserveValueImports",
732
- "removeComments",
733
- "sourceMap",
734
- "sourceRoot",
735
- "stripInternal",
736
- /* Interop Constraints */
737
- "allowSyntheticDefaultImports",
738
- "esModuleInterop",
739
- "forceConsistentCasingInFileNames",
740
- "isolatedModules",
741
- "preserveSymlinks",
742
- "verbatimModuleSyntax",
743
- /* Completeness */
744
- "skipDefaultLibCheck",
745
- "skipLibCheck"
746
- ],
747
- pathPattern: "^compilerOptions$"
748
- }
749
- ]
750
- }
751
- }
752
- ];
753
- return config;
754
- };
755
-
756
- const markdown = () => {
757
- const config = [
758
- ...pluginMarkdown__default.default.configs.processor,
759
- {
760
- files: [`${GLOB_MARKDOWN}/*.${GLOB_SCRIPT_EXT}`],
761
- rules: {
762
- "react/no-missing-component-display-name": "off",
763
- "@typescript-eslint/no-redeclare": "off",
764
- "@typescript-eslint/no-unused-vars": "off",
765
- "@typescript-eslint/no-use-before-define": "off",
766
- "@typescript-eslint/no-var-requires": "off",
767
- "@typescript-eslint/consistent-type-imports": "off",
768
- "@typescript-eslint/no-namespace": "off",
769
- "@typescript-eslint/no-require-imports": "off",
770
- "import/no-unresolved": "off",
771
- "unused-imports/no-unused-imports": "off",
772
- "unused-imports/no-unused-vars": "off",
773
- "no-alert": "off",
774
- "no-console": "off",
775
- "no-restricted-imports": "off",
776
- "no-undef": "off",
777
- "no-unused-expressions": "off",
778
- "no-unused-vars": "off",
779
- "import/no-extraneous-dependencies": "off",
780
- "import/no-default-export": "off",
781
- "import/no-anonymous-default-export": "off",
782
- "react-refresh/only-export-components": "off",
783
- "react/jsx-no-undef": "off"
784
- }
785
- }
786
- ];
787
- return config;
788
- };
789
-
790
- const next = () => {
791
- const config = [
792
- {
793
- files: [GLOB_JSX, GLOB_TSX],
794
- plugins: {
795
- "@next/next": pluginNext__default.default
796
- },
797
- rules: {
798
- ...pluginNext__default.default.configs.recommended.rules
799
- }
800
- }
801
- ];
802
- return config;
803
- };
804
-
805
- const progress = () => {
806
- const config = [
807
- {
808
- plugins: {
809
- progress: pluginProgress__default.default
810
- },
811
- rules: {
812
- "progress/activate": 1
813
- }
814
- }
815
- ];
816
- return config;
817
- };
818
-
819
- function renameRules(rules, map) {
820
- return Object.fromEntries(
821
- Object.entries(rules).map(([key, value]) => {
822
- for (const [from, to] of Object.entries(map)) {
823
- if (key.startsWith(`${from}/`)) {
824
- return [to + key.slice(from.length), value];
825
- }
826
- }
827
- return [key, value];
828
- })
829
- );
830
- }
831
-
832
- const react = () => {
833
- const config = [
834
- {
835
- files: [GLOB_JSX, GLOB_TSX],
836
- languageOptions: {
837
- parserOptions: {
838
- ecmaFeatures: {
839
- jsx: true
840
- }
841
- },
842
- sourceType: "module"
843
- },
844
- settings: {
845
- "react-x": {
846
- version: "18.0"
847
- }
848
- },
849
- plugins: {
850
- react: pluginReact__default.default,
851
- "react-dom": pluginReact__default.default,
852
- "react-hooks": pluginReactHooks__default.default,
853
- "react-hooks-extra": pluginReact__default.default,
854
- "react-naming-convention": pluginReact__default.default,
855
- "react-refresh": pluginReactRefresh__default.default,
856
- "react-web-api": pluginReact__default.default
857
- },
858
- rules: {
859
- ...renameRules(pluginReact__default.default.configs["recommended-typescript"].rules, { "@eslint-react": "react" }),
860
- ...renameRules(pluginReact__default.default.configs["dom"].rules, { "@eslint-react": "react-dom" }),
861
- ...renameRules(pluginReact__default.default.configs["x"].rules, { "@eslint-react": "react-hooks-extra" }),
862
- ...renameRules(pluginReact__default.default.configs["x"].rules, { "@eslint-react": "react-naming-convention" }),
863
- ...renameRules(pluginReact__default.default.configs["web-api"].rules, { "@eslint-react": "react-web-api" }),
864
- ...pluginReactHooks__default.default.configs.flat.recommended.rules,
865
- "react/no-nested-component-definitions": "warn",
866
- "react-dom/no-unknown-property": "off",
867
- "react-refresh/only-export-components": "warn"
868
- }
869
- },
870
- {
871
- files: ["src/components/**/*.{ts,tsx}"],
872
- rules: {
873
- "react-naming-convention/filename": ["warn", { rule: "PascalCase" }]
874
- }
875
- },
876
- {
877
- files: ["src/hooks/**/use*.{ts,tsx}"],
878
- rules: {
879
- "react-naming-convention/filename": ["warn", { rule: "kebab-case" }]
880
- }
881
- },
882
- {
883
- files: [
884
- `**/*config*.${GLOB_SCRIPT_EXT}`,
885
- `**/*{-entry,entry.}*.${GLOB_SCRIPT_EXT}`,
886
- GLOB_TEST_SCRIPT,
887
- GLOB_TEST_DIRS,
888
- GLOB_PAGES_DIRS
889
- ],
890
- ignores: [
891
- GLOB_PAGES_COMPONENTS_DIRS
892
- ],
893
- rules: {
894
- "react-refresh/only-export-components": "off"
895
- }
896
- }
897
- ];
898
- return config;
899
- };
900
- const ssrReact = () => {
901
- const config = [
902
- {
903
- files: [GLOB_JSX, GLOB_TSX],
904
- languageOptions: {
905
- parserOptions: {
906
- ecmaFeatures: {
907
- jsx: true
908
- }
909
- },
910
- sourceType: "module"
911
- },
912
- settings: {
913
- "react-x": {
914
- version: "18.0"
915
- }
916
- },
917
- rules: {
918
- "no-restricted-syntax": [
919
- "error",
920
- "DebuggerStatement",
921
- "LabeledStatement",
922
- "WithStatement",
923
- {
924
- selector: "TSEnumDeclaration",
925
- message: "Don't declare enums"
926
- },
927
- {
928
- selector: "MemberExpression[object.name='window']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='window'])",
929
- message: `Use 'typeof window !== "undefined" && window.xxx' for safe DOM access`
930
- },
931
- {
932
- selector: "Identifier[name='window']:not(UnaryExpression[operator='typeof'] > Identifier)",
933
- message: `Direct window access not allowed. Use 'typeof window !== "undefined"' check first`
934
- },
935
- // Document
936
- {
937
- selector: "MemberExpression[object.name='document']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='document'])",
938
- message: `Use 'typeof document !== "undefined" && document.xxx' for safe DOM access`
939
- },
940
- {
941
- selector: "Identifier[name='document']:not(UnaryExpression[operator='typeof'] > Identifier)",
942
- message: `Direct document access not allowed. Use 'typeof document !== "undefined"' check first`
943
- },
944
- // Navigator
945
- {
946
- selector: "MemberExpression[object.name='navigator']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='navigator'])",
947
- message: `Use 'typeof navigator !== "undefined" && navigator.xxx' for safe DOM access`
948
- },
949
- // Location
950
- {
951
- selector: "MemberExpression[object.name='location']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='location'])",
952
- message: `Use 'typeof location !== "undefined" && location.xxx' for safe DOM access`
953
- },
954
- // History
955
- {
956
- selector: "MemberExpression[object.name='history']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='history'])",
957
- message: `Use 'typeof history !== "undefined" && history.xxx' for safe DOM access`
958
- },
959
- // Storage
960
- {
961
- selector: "MemberExpression[object.name='localStorage']:not(LogicalExpression[right=MemberExpression] > MemberExpression[object.name='localStorage'])",
962
- message: `Use 'typeof localStorage !== "undefined" && localStorage.xxx' for safe DOM access`
963
- },
964
- {
965
- selector: "TSEnumDeclaration",
966
- message: "Don't declare enums"
967
- }
968
- ]
969
- }
970
- },
971
- {
972
- files: [
973
- `**/*config*.${GLOB_SCRIPT_EXT}`,
974
- `**/*{client-entry,entry.client}*.${GLOB_SCRIPT_EXT}`,
975
- GLOB_TEST_SCRIPT,
976
- GLOB_TEST_DIRS
977
- ],
978
- rules: {
979
- "no-restricted-syntax": [
980
- "error",
981
- "DebuggerStatement",
982
- "LabeledStatement",
983
- "WithStatement",
984
- {
985
- selector: "TSEnumDeclaration",
986
- message: "Don't declare enums"
987
- }
988
- ]
989
- }
990
- }
991
- ];
992
- return config;
993
- };
994
-
995
- const regexp = () => {
996
- const config = [
997
- {
998
- ...eslintPluginRegexp.configs.recommended
999
- }
1000
- ];
1001
- return config;
1002
- };
1003
-
1004
- const stylistic = () => {
1005
- const config = pluginStylistic__default.default.configs.customize({
1006
- indent: 2,
1007
- jsx: true,
1008
- quotes: "single",
1009
- semi: false
1010
- });
1011
- const off = {};
1012
- for (const key of Object.keys(config.rules ?? {})) {
1013
- const bare = key.replace("@stylistic/", "");
1014
- if (bare === "function-call-spacing") {
1015
- continue;
1016
- }
1017
- off[bare] = "off";
1018
- }
1019
- const configs = [
1020
- {
1021
- files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
1022
- plugins: {
1023
- ...config.plugins
1024
- },
1025
- rules: {
1026
- ...off,
1027
- ...config.rules,
1028
- "@stylistic/quotes": ["error", "single", { avoidEscape: true }],
1029
- "@stylistic/quote-props": ["error", "as-needed"],
1030
- "@stylistic/array-bracket-spacing": ["error", "never"],
1031
- "@stylistic/brace-style": ["error", "1tbs"],
1032
- "@stylistic/block-spacing": ["error", "always"],
1033
- "@stylistic/comma-spacing": ["error", { before: false, after: true }],
1034
- "@stylistic/comma-style": ["error", "last"],
1035
- "comma-dangle": "off",
1036
- "@stylistic/comma-dangle": ["error", "always-multiline"],
1037
- "@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
1038
- "@stylistic/multiline-ternary": ["error", "always-multiline"],
1039
- "@stylistic/indent": ["error", 2, {
1040
- SwitchCase: 1,
1041
- VariableDeclarator: 1,
1042
- outerIIFEBody: 1,
1043
- MemberExpression: 1,
1044
- FunctionDeclaration: { parameters: 1, body: 1 },
1045
- FunctionExpression: { parameters: 1, body: 1 },
1046
- CallExpression: { arguments: 1 },
1047
- ArrayExpression: 1,
1048
- ObjectExpression: 1,
1049
- ImportDeclaration: 1,
1050
- flatTernaryExpressions: true,
1051
- ignoreComments: false,
1052
- ignoredNodes: [
1053
- "TemplateLiteral *",
1054
- "JSXElement",
1055
- "JSXElement > *",
1056
- "JSXAttribute",
1057
- "JSXIdentifier",
1058
- "JSXNamespacedName",
1059
- "JSXMemberExpression",
1060
- "JSXSpreadAttribute",
1061
- "JSXExpressionContainer",
1062
- "JSXOpeningElement",
1063
- "JSXClosingElement",
1064
- "JSXFragment",
1065
- "JSXOpeningFragment",
1066
- "JSXClosingFragment",
1067
- "JSXText",
1068
- "JSXEmptyExpression",
1069
- "JSXSpreadChild",
1070
- "TSTypeParameterInstantiation",
1071
- "FunctionExpression > .params[decorators.length > 0]",
1072
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
1073
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
1074
- ],
1075
- offsetTernaryExpressions: true
1076
- }],
1077
- "@stylistic/object-curly-spacing": ["error", "always"],
1078
- "@stylistic/template-curly-spacing": "error",
1079
- "@stylistic/generator-star-spacing": "off",
1080
- "@stylistic/no-multi-spaces": "error",
1081
- "@stylistic/operator-linebreak": ["error", "before"],
1082
- "@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
1083
- "@stylistic/type-annotation-spacing": ["error", {}],
1084
- "@stylistic/function-call-spacing": ["error", "never"],
1085
- "@stylistic/semi": ["error", "never"],
1086
- "@stylistic/space-before-blocks": ["error", "always"],
1087
- "@stylistic/space-before-function-paren": [
1088
- "error",
1089
- {
1090
- anonymous: "always",
1091
- named: "never",
1092
- asyncArrow: "always"
1093
- }
1094
- ],
1095
- "@stylistic/space-infix-ops": "error",
1096
- "@stylistic/keyword-spacing": ["error", { before: true, after: true }],
1097
- "@stylistic/no-extra-parens": ["error", "functions"],
1098
- "@stylistic/lines-between-class-members": [
1099
- "error",
1100
- "always",
1101
- { exceptAfterSingleLine: true }
1102
- ],
1103
- "@stylistic/jsx-quotes": ["error", "prefer-double"],
1104
- "@stylistic/jsx-wrap-multilines": [
1105
- "warn",
1106
- {
1107
- declaration: "parens-new-line",
1108
- assignment: "parens-new-line",
1109
- return: "parens-new-line",
1110
- arrow: "parens-new-line",
1111
- condition: "parens-new-line",
1112
- logical: "parens-new-line",
1113
- prop: "parens-new-line"
1114
- }
1115
- ],
1116
- "@stylistic/jsx-closing-tag-location": "error",
1117
- "@stylistic/jsx-tag-spacing": ["error", { closingSlash: "never", beforeSelfClosing: "always", afterOpening: "never", beforeClosing: "allow" }],
1118
- "@stylistic/jsx-max-props-per-line": ["warn", { maximum: 1, when: "multiline" }],
1119
- "@stylistic/jsx-indent-props": ["warn", 2],
1120
- "@stylistic/jsx-closing-bracket-location": ["warn", "tag-aligned"],
1121
- "@stylistic/jsx-first-prop-new-line": ["warn", "multiline-multiprop"],
1122
- "@stylistic/jsx-one-expression-per-line": "off"
1123
- }
1124
- }
1125
- ];
1126
- return configs;
1127
- };
1128
-
1129
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
1130
- const tailwindcss = () => {
1131
- const pluginTailwindcss = require$1("eslint-plugin-tailwindcss");
1132
- const config = [
1133
- ...pluginTailwindcss.configs["flat/recommended"],
1134
- {
1135
- rules: {
1136
- ...pluginTailwindcss.configs.recommended.rules,
1137
- "tailwindcss/no-custom-classname": "off"
1138
- }
1139
- }
1140
- ];
1141
- return config;
1142
- };
1143
-
1144
- const toml = () => {
1145
- const config = [
1146
- ...pluginToml__default.default.configs.recommended,
1147
- {
1148
- rules: {
1149
- "toml/comma-style": "error",
1150
- "toml/keys-order": "error",
1151
- "toml/no-space-dots": "error",
1152
- "toml/no-unreadable-number-separator": "error",
1153
- "toml/precision-of-fractional-seconds": "error",
1154
- "toml/precision-of-integer": "error",
1155
- "toml/tables-order": "error",
1156
- "toml/array-bracket-newline": "error",
1157
- "toml/array-bracket-spacing": "error",
1158
- "toml/array-element-newline": "error",
1159
- "toml/indent": ["error", 4],
1160
- "toml/inline-table-curly-spacing": "error",
1161
- "toml/key-spacing": "error",
1162
- "toml/padding-line-between-pairs": "error",
1163
- "toml/padding-line-between-tables": "error",
1164
- "toml/quoted-keys": "error",
1165
- "toml/spaced-comment": "error",
1166
- "toml/table-bracket-spacing": "error"
1167
- }
1168
- }
1169
- ];
1170
- return config;
1171
- };
1172
-
1173
- const typescript = () => {
1174
- const config = [
1175
- {
1176
- files: [GLOB_TSX, GLOB_TS, GLOB_TEST_SCRIPT],
1177
- languageOptions: {
1178
- parser: tsParser__default.default,
1179
- parserOptions: {
1180
- sourceType: "module"
1181
- }
1182
- },
1183
- settings: {
1184
- "import/resolver": {
1185
- node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] }
1186
- }
1187
- },
1188
- plugins: {
1189
- "@typescript-eslint": pluginTypeScript__default.default,
1190
- etc: pluginETC__default.default
1191
- },
1192
- rules: {
1193
- ...pluginTypeScript__default.default.configs.recommended.rules,
1194
- // https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/troubleshooting/Performance.md#eslint-plugin-import
1195
- "import/named": "off",
1196
- "import/namespace": "off",
1197
- "import/default": "off",
1198
- "import/no-named-as-default-member": "off",
1199
- "import/no-named-as-default": "off",
1200
- // TS
1201
- "no-var": "error",
1202
- "no-useless-constructor": "off",
1203
- "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1204
- "@typescript-eslint/consistent-type-imports": [
1205
- "error",
1206
- { prefer: "type-imports", disallowTypeAnnotations: false, fixStyle: "separate-type-imports" }
1207
- ],
1208
- // Limit `interface` define object types, users could override with *.d.ts declare
1209
- "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
1210
- "@typescript-eslint/prefer-ts-expect-error": "warn",
1211
- "@typescript-eslint/default-param-last": "error",
1212
- // Sort type S = A | B
1213
- "@typescript-eslint/sort-type-constituents": "error",
1214
- "@typescript-eslint/unbound-method": "off",
1215
- "@typescript-eslint/prefer-for-of": "error",
1216
- // When .ts files compiled to .mjs, will throw require is not found
1217
- // use createRequire instead
1218
- "@typescript-eslint/no-require-imports": "error",
1219
- "@typescript-eslint/no-empty-object-type": "off",
1220
- /**
1221
- * refs:
1222
- * 1. https://ncjamieson.com/dont-export-const-enums/
1223
- * 2. https://www.huy.rocks/everyday/02-24-2022-typescript-enums-at-runtime-and-tree-shaking
1224
- */
1225
- "no-restricted-syntax": [
1226
- "error",
1227
- "DebuggerStatement",
1228
- "LabeledStatement",
1229
- "WithStatement",
1230
- {
1231
- selector: "TSEnumDeclaration",
1232
- message: "Don't declare enums"
1233
- }
1234
- ],
1235
- "@typescript-eslint/method-signature-style": ["error", "property"],
1236
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful,
1237
- "@typescript-eslint/no-import-type-side-effects": "error",
1238
- "@typescript-eslint/no-wrapper-object-types": "error",
1239
- // https://www.npmjs.com/package/eslint-plugin-etc
1240
- "etc/no-t": "error",
1241
- // required tsconfig.json
1242
- // 'etc/no-misused-generics'f: 'error',
1243
- // Overrides JS
1244
- // original no-undef not compatiable with typescript
1245
- // refs: https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
1246
- "no-undef": "off",
1247
- "no-unused-vars": "off",
1248
- "no-redeclare": "off",
1249
- "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
1250
- "no-dupe-class-members": "off",
1251
- "@typescript-eslint/no-dupe-class-members": "error",
1252
- "no-use-before-define": "off",
1253
- "@typescript-eslint/no-use-before-define": [
1254
- "error",
1255
- { functions: false, classes: false, variables: true }
1256
- ],
1257
- "no-loss-of-precision": "off",
1258
- "@typescript-eslint/no-loss-of-precision": "error",
1259
- "no-unused-expressions": "off",
1260
- "@typescript-eslint/no-unused-expressions": ["error", {
1261
- allowShortCircuit: true,
1262
- allowTernary: true,
1263
- allowTaggedTemplates: true
1264
- }],
1265
- // off
1266
- "@typescript-eslint/camelcase": "off",
1267
- "@typescript-eslint/explicit-function-return-type": "off",
1268
- "@typescript-eslint/explicit-member-accessibility": "off",
1269
- "@typescript-eslint/no-explicit-any": "off",
1270
- "@typescript-eslint/no-parameter-properties": "off",
1271
- "@typescript-eslint/no-empty-interface": "off",
1272
- "@typescript-eslint/ban-ts-ignore": "off",
1273
- "@typescript-eslint/no-empty-function": "off",
1274
- "@typescript-eslint/no-non-null-assertion": "off",
1275
- "@typescript-eslint/explicit-module-boundary-types": "off",
1276
- "@typescript-eslint/ban-types": "off",
1277
- "@typescript-eslint/no-namespace": "off",
1278
- "@typescript-eslint/no-var-requires": "off",
1279
- // https://www.npmjs.com/package/eslint-plugin-unused-imports
1280
- "@typescript-eslint/no-unused-vars": "off",
1281
- "no-void": ["error", { allowAsStatement: true }],
1282
- "@typescript-eslint/no-dynamic-delete": "off",
1283
- "@typescript-eslint/no-extraneous-class": "off",
1284
- "@typescript-eslint/no-useless-constructor": "off",
1285
- "@typescript-eslint/triple-slash-reference": "off"
1286
- }
1287
- },
1288
- {
1289
- files: [GLOB_TEST_SCRIPT, GLOB_TEST_DIRS],
1290
- rules: {
1291
- "no-unused-expressions": "off",
1292
- "@typescript-eslint/no-unused-vars": "off"
1293
- }
1294
- }
1295
- ];
1296
- return config;
1297
- };
1298
-
1299
- const unicorn = () => {
1300
- const config = [
1301
- {
1302
- plugins: {
1303
- unicorn: pluginUnicorn__default.default
1304
- },
1305
- rules: {
1306
- ...pluginUnicorn__default.default.configs.recommended.rules,
1307
- "unicorn/consistent-empty-array-spread": "error",
1308
- "unicorn/error-message": "error",
1309
- "unicorn/escape-case": "error",
1310
- "unicorn/new-for-builtins": "error",
1311
- "unicorn/no-instanceof-builtins": "error",
1312
- "unicorn/no-new-array": "error",
1313
- "unicorn/no-new-buffer": "error",
1314
- "unicorn/number-literal-case": "error",
1315
- "unicorn/prefer-dom-node-text-content": "error",
1316
- "unicorn/prefer-includes": "error",
1317
- "unicorn/prefer-node-protocol": "error",
1318
- "unicorn/prefer-number-properties": "error",
1319
- "unicorn/prefer-string-starts-ends-with": "error",
1320
- "unicorn/prefer-type-error": "error",
1321
- "unicorn/throw-new-error": "error"
1322
- }
1323
- }
1324
- ];
1325
- return config;
1326
- };
1327
-
1328
- const yml = () => {
1329
- const config = [
1330
- ...pluginYml__default.default.configs.standard,
1331
- {
1332
- files: [GLOB_YAML],
1333
- rules: {
1334
- "spaced-comment": "off",
1335
- "yml/quotes": ["error", { prefer: "double", avoidEscape: false }],
1336
- "yml/no-empty-document": "off"
1337
- }
1338
- },
1339
- {
1340
- files: [GLOB_WORKFLOW_YAML],
1341
- rules: {
1342
- "yml/no-empty-mapping-value": "off"
1343
- }
1344
- }
1345
- ];
1346
- return config;
1347
- };
1348
-
1349
- const presetJavascript = [
1350
- ...ignores(),
1351
- ...javascript(),
1352
- ...comments(),
1353
- ...imports(),
1354
- ...unicorn()
1355
- ];
1356
- const presetTypescript = [
1357
- ...presetJavascript,
1358
- ...typescript()
1359
- ];
1360
- const presetLangsExtensions = [
1361
- ...yml(),
1362
- ...markdown(),
1363
- ...jsonc(),
1364
- ...toml()
1365
- ];
1366
- const presetDefault = [
1367
- ...presetTypescript,
1368
- ...react(),
1369
- ...stylistic(),
1370
- ...presetLangsExtensions,
1371
- ...progress()
1372
- ];
1373
- const all = [
1374
- ...presetDefault,
1375
- ...tailwindcss(),
1376
- ...next(),
1377
- ...ssrReact(),
1378
- ...regexp()
1379
- ];
1380
- const aiou = ({ ssr = true, regexp: regexp$1 = true } = { ssr: true, regexp: true }, ...userConfigs) => {
1381
- const configs = [...presetDefault];
1382
- if (localPkg.isPackageExists("tailwindcss")) {
1383
- configs.push(...tailwindcss());
1384
- }
1385
- if (localPkg.isPackageExists("next")) {
1386
- configs.push(...next());
1387
- }
1388
- if (ssr) {
1389
- configs.push(...ssrReact());
1390
- }
1391
- if (regexp$1) {
1392
- configs.push(...regexp());
1393
- }
1394
- const composer = new eslintFlatConfigUtils.FlatConfigComposer(
1395
- ...configs,
1396
- ...userConfigs
1397
- );
1398
- return composer;
1399
- };
1400
-
1401
- exports.aiou = aiou;
1402
- exports.all = all;