@so1ve/eslint-config 1.0.0-alpha.1 → 1.0.0-alpha.11

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/dist/index.mjs CHANGED
@@ -1,94 +1,1589 @@
1
- import jiti from "file:///C:/Data/Workspace/eslint-prettier-config/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/lib/index.js";
2
-
3
- /** @type {import("C:/Data/Workspace/eslint-prettier-config/packages/eslint-config/src/index")} */
4
- const _module = jiti(null, {
5
- "esmResolve": true,
6
- "interopDefault": true,
7
- "alias": {
8
- "@so1ve/eslint-config": "C:/Data/Workspace/eslint-prettier-config/packages/eslint-config"
9
- }
10
- })("C:/Data/Workspace/eslint-prettier-config/packages/eslint-config/src/index.ts");
11
-
12
- export const so1ve = _module.so1ve;
13
- export const comments = _module.comments;
14
- export const html = _module.html;
15
- export const ignores = _module.ignores;
16
- export const imports = _module.imports;
17
- export const javascript = _module.javascript;
18
- export const jsonc = _module.jsonc;
19
- export const mdx = _module.mdx;
20
- export const node = _module.node;
21
- export const onlyError = _module.onlyError;
22
- export const promise = _module.promise;
23
- export const solid = _module.solid;
24
- export const sortImports = _module.sortImports;
25
- export const test = _module.test;
26
- export const toml = _module.toml;
27
- export const typescript = _module.typescript;
28
- export const typescriptWithTypes = _module.typescriptWithTypes;
29
- export const unicorn = _module.unicorn;
30
- export const vue = _module.vue;
31
- export const yaml = _module.yaml;
32
- export const pluginComments = _module.pluginComments;
33
- export const pluginSo1ve = _module.pluginSo1ve;
34
- export const pluginSortImports = _module.pluginSortImports;
35
- export const pluginTs = _module.pluginTs;
36
- export const parserTs = _module.parserTs;
37
- export const pluginHtml_ = _module.pluginHtml_;
38
- export const pluginHtml = _module.pluginHtml;
39
- export const parserHtml = _module.parserHtml;
40
- export const pluginOnlyError = _module.pluginOnlyError;
41
- export const pluginJestFormatting = _module.pluginJestFormatting;
42
- export const pluginJsdoc = _module.pluginJsdoc;
43
- export const pluginJsonc = _module.pluginJsonc;
44
- export const pluginMdx = _module.pluginMdx;
45
- export const pluginNode = _module.pluginNode;
46
- export const pluginPromise = _module.pluginPromise;
47
- export const pluginNoOnlyTests = _module.pluginNoOnlyTests;
48
- export const pluginUnicorn = _module.pluginUnicorn;
49
- export const pluginUnusedImports = _module.pluginUnusedImports;
50
- export const pluginArrayFunc = _module.pluginArrayFunc;
51
- export const pluginJsonSchemaValidator = _module.pluginJsonSchemaValidator;
52
- export const pluginRegexp = _module.pluginRegexp;
53
- export const pluginVitest = _module.pluginVitest;
54
- export const pluginVue = _module.pluginVue;
55
- export const pluginYaml = _module.pluginYaml;
56
- export const pluginToml = _module.pluginToml;
57
- export const pluginSolid = _module.pluginSolid;
58
- export const pluginEtc = _module.pluginEtc;
59
- export const parserJsonc = _module.parserJsonc;
60
- export const parserVue = _module.parserVue;
61
- export const parserYaml = _module.parserYaml;
62
- export const parserToml = _module.parserToml;
63
- export const parserMdx = _module.parserMdx;
64
- export const pluginImport = _module.pluginImport;
65
- export const combine = _module.combine;
66
- export const renameRules = _module.renameRules;
67
- export const recordRulesStateConfigs = _module.recordRulesStateConfigs;
68
- export const recordRulesState = _module.recordRulesState;
69
- export const warnUnnecessaryOffRules = _module.warnUnnecessaryOffRules;
70
- export const GLOB_SRC_EXT = _module.GLOB_SRC_EXT;
71
- export const GLOB_SRC = _module.GLOB_SRC;
72
- export const GLOB_JS = _module.GLOB_JS;
73
- export const GLOB_JSX = _module.GLOB_JSX;
74
- export const GLOB_TS = _module.GLOB_TS;
75
- export const GLOB_TSX = _module.GLOB_TSX;
76
- export const GLOB_DTS = _module.GLOB_DTS;
77
- export const GLOB_STYLE = _module.GLOB_STYLE;
78
- export const GLOB_CSS = _module.GLOB_CSS;
79
- export const GLOB_LESS = _module.GLOB_LESS;
80
- export const GLOB_SCSS = _module.GLOB_SCSS;
81
- export const GLOB_JSON = _module.GLOB_JSON;
82
- export const GLOB_JSON5 = _module.GLOB_JSON5;
83
- export const GLOB_JSONC = _module.GLOB_JSONC;
84
- export const GLOB_ESLINTRC = _module.GLOB_ESLINTRC;
85
- export const GLOB_MARKDOWN = _module.GLOB_MARKDOWN;
86
- export const GLOB_VUE = _module.GLOB_VUE;
87
- export const GLOB_YAML = _module.GLOB_YAML;
88
- export const GLOB_TOML = _module.GLOB_TOML;
89
- export const GLOB_HTML = _module.GLOB_HTML;
90
- export const GLOB_PACKAGEJSON = _module.GLOB_PACKAGEJSON;
91
- export const GLOB_MARKDOWN_CODE = _module.GLOB_MARKDOWN_CODE;
92
- export const GLOB_TESTS = _module.GLOB_TESTS;
93
- export const GLOB_ALL_SRC = _module.GLOB_ALL_SRC;
94
- export const GLOB_EXCLUDE = _module.GLOB_EXCLUDE;
1
+ import pluginComments from '@eslint-community/eslint-plugin-eslint-comments';
2
+ export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
3
+ import pluginHtml from '@html-eslint/eslint-plugin';
4
+ export { default as pluginHtml } from '@html-eslint/eslint-plugin';
5
+ import parserHtml from '@html-eslint/parser';
6
+ export { default as parserHtml } from '@html-eslint/parser';
7
+ import pluginSo1ve from '@so1ve/eslint-plugin';
8
+ export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
9
+ import pluginSortImports from '@so1ve/eslint-plugin-sort-imports';
10
+ export { default as pluginSortImports } from '@so1ve/eslint-plugin-sort-imports';
11
+ import pluginTs from '@typescript-eslint/eslint-plugin';
12
+ export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
13
+ import parserTs from '@typescript-eslint/parser';
14
+ export { default as parserTs } from '@typescript-eslint/parser';
15
+ export { default as parserMdx } from 'eslint-mdx';
16
+ import pluginArrayFunc from 'eslint-plugin-array-func';
17
+ export { default as pluginArrayFunc } from 'eslint-plugin-array-func';
18
+ import pluginEtc from 'eslint-plugin-etc';
19
+ export { default as pluginEtc } from 'eslint-plugin-etc';
20
+ import pluginHtmlJsSupport from 'eslint-plugin-html';
21
+ export { default as pluginHtmlJsSupport } from 'eslint-plugin-html';
22
+ import pluginImport from 'eslint-plugin-i';
23
+ export { default as pluginImport } from 'eslint-plugin-i';
24
+ import pluginJestFormatting from 'eslint-plugin-jest-formatting';
25
+ export { default as pluginJestFormatting } from 'eslint-plugin-jest-formatting';
26
+ import pluginJsonSchemaValidator from 'eslint-plugin-json-schema-validator';
27
+ export { default as pluginJsonSchemaValidator } from 'eslint-plugin-json-schema-validator';
28
+ import pluginJsonc from 'eslint-plugin-jsonc';
29
+ export { default as pluginJsonc } from 'eslint-plugin-jsonc';
30
+ import pluginMdx from 'eslint-plugin-mdx';
31
+ export { default as pluginMdx } from 'eslint-plugin-mdx';
32
+ import pluginNode from 'eslint-plugin-n';
33
+ export { default as pluginNode } from 'eslint-plugin-n';
34
+ import pluginNoOnlyTests from 'eslint-plugin-no-only-tests';
35
+ export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
36
+ import pluginOnlyError from 'eslint-plugin-only-error';
37
+ export { default as pluginOnlyError } from 'eslint-plugin-only-error';
38
+ import pluginPromise from 'eslint-plugin-promise';
39
+ export { default as pluginPromise } from 'eslint-plugin-promise';
40
+ import pluginRegexp from 'eslint-plugin-regexp';
41
+ export { default as pluginRegexp } from 'eslint-plugin-regexp';
42
+ import pluginSolid from 'eslint-plugin-solid';
43
+ export { default as pluginSolid } from 'eslint-plugin-solid';
44
+ import pluginToml from 'eslint-plugin-toml';
45
+ export { default as pluginToml } from 'eslint-plugin-toml';
46
+ import pluginUnicorn from 'eslint-plugin-unicorn';
47
+ export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
48
+ import pluginUnusedImports from 'eslint-plugin-unused-imports';
49
+ export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
50
+ import pluginVitest from 'eslint-plugin-vitest';
51
+ export { default as pluginVitest } from 'eslint-plugin-vitest';
52
+ import pluginVue from 'eslint-plugin-vue';
53
+ export { default as pluginVue } from 'eslint-plugin-vue';
54
+ import pluginYaml from 'eslint-plugin-yml';
55
+ export { default as pluginYaml } from 'eslint-plugin-yml';
56
+ import parserJsonc from 'jsonc-eslint-parser';
57
+ export { default as parserJsonc } from 'jsonc-eslint-parser';
58
+ import parserToml from 'toml-eslint-parser';
59
+ export { default as parserToml } from 'toml-eslint-parser';
60
+ import parserVue from 'vue-eslint-parser';
61
+ export { default as parserVue } from 'vue-eslint-parser';
62
+ import parserYaml from 'yaml-eslint-parser';
63
+ export { default as parserYaml } from 'yaml-eslint-parser';
64
+ import globals from 'globals';
65
+ import fs from 'node:fs';
66
+ import gitignore from 'eslint-config-flat-gitignore';
67
+ import { isPackageExists } from 'local-pkg';
68
+
69
+ const comments = () => [
70
+ {
71
+ plugins: {
72
+ "eslint-comments": pluginComments
73
+ }
74
+ },
75
+ {
76
+ rules: {
77
+ "eslint-comments/no-aggregating-enable": "error",
78
+ "eslint-comments/no-duplicate-disable": "error",
79
+ "eslint-comments/no-unused-enable": "error",
80
+ "eslint-comments/disable-enable-pair": "off",
81
+ "eslint-comments/no-unlimited-disable": "off"
82
+ }
83
+ }
84
+ ];
85
+
86
+ const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
87
+ const GLOB_SRC = `**/*.${GLOB_SRC_EXT}`;
88
+ const GLOB_JS = "**/*.?([cm])js";
89
+ const GLOB_JSX = "**/*.?([cm])jsx";
90
+ const GLOB_TS = "**/*.?([cm])ts";
91
+ const GLOB_TSX = "**/*.?([cm])tsx";
92
+ const GLOB_DTS = "**/*.d.?([cm])tsx";
93
+ const GLOB_STYLE = "**/*.{c,le,sc}ss";
94
+ const GLOB_CSS = "**/*.css";
95
+ const GLOB_LESS = "**/*.less";
96
+ const GLOB_SCSS = "**/*.scss";
97
+ const GLOB_JSON = "**/*.json";
98
+ const GLOB_JSON5 = "**/*.json5";
99
+ const GLOB_JSONC = "**/*.jsonc";
100
+ const GLOB_ESLINTRC = "**/.eslintrc";
101
+ const GLOB_MARKDOWN = "**/*.md?(x)";
102
+ const GLOB_VUE = "**/*.vue";
103
+ const GLOB_YAML = "**/*.y?(a)ml";
104
+ const GLOB_TOML = "**/*.toml";
105
+ const GLOB_HTML = "**/*.htm?(l)";
106
+ const GLOB_PACKAGEJSON = "**/package.json";
107
+ const GLOB_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
108
+ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
109
+ const GLOB_TESTS = [
110
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
111
+ `**/*.spec.${GLOB_SRC_EXT}`,
112
+ `**/*.test.${GLOB_SRC_EXT}`,
113
+ `**/*.bench.${GLOB_SRC_EXT}`,
114
+ `**/*.benchmark.${GLOB_SRC_EXT}`
115
+ ];
116
+ const GLOB_ALL_SRC = [
117
+ GLOB_SRC,
118
+ GLOB_STYLE,
119
+ GLOB_JSON,
120
+ GLOB_JSON5,
121
+ GLOB_ESLINTRC,
122
+ GLOB_MARKDOWN,
123
+ GLOB_VUE,
124
+ GLOB_YAML,
125
+ GLOB_HTML
126
+ ];
127
+ const GLOB_EXCLUDE = [
128
+ "**/node_modules",
129
+ "**/dist",
130
+ "**/out",
131
+ "**/output",
132
+ "**/package-lock.json",
133
+ "**/yarn.lock",
134
+ "**/pnpm-lock.yaml",
135
+ "**/bun.lockb",
136
+ "**/coverage",
137
+ "**/temp",
138
+ "**/.vitepress/cache",
139
+ "**/.nuxt",
140
+ "**/.nitro",
141
+ "**/.vercel",
142
+ "**/.netlify",
143
+ "**/.output",
144
+ "**/.vercel",
145
+ "**/.changeset",
146
+ "**/.idea",
147
+ "**/.vite-inspect",
148
+ "**/.yarn",
149
+ "**/CHANGELOG*.md",
150
+ "**/*.min.*",
151
+ "**/LICENSE*",
152
+ "**/__snapshots__",
153
+ "**/auto-import?(s).d.ts",
154
+ "**/components.d.ts",
155
+ // Volar
156
+ "**/*.vue.js",
157
+ "**/*.vue.jsx",
158
+ "**/*.vue.ts",
159
+ "**/*.vue.tsx"
160
+ ];
161
+
162
+ const formatting = (options) => {
163
+ var _a, _b;
164
+ return [
165
+ {
166
+ rules: {
167
+ "so1ve/no-useless-template-string": "error",
168
+ "so1ve/no-negated-comparison": "error",
169
+ "so1ve/no-import-promises-as": "error",
170
+ "so1ve/pad-after-last-import": "error",
171
+ "so1ve/function-style": "error",
172
+ "quote-props": ["error", "consistent-as-needed"],
173
+ "padding-line-between-statements": [
174
+ "error",
175
+ { blankLine: "always", prev: "*", next: "return" }
176
+ ]
177
+ }
178
+ },
179
+ ((_a = options.jsonc) != null ? _a : true) && [
180
+ {
181
+ files: [GLOB_PACKAGEJSON],
182
+ rules: {
183
+ "jsonc/sort-keys": [
184
+ "error",
185
+ {
186
+ pathPattern: "^exports$",
187
+ order: { type: "asc" }
188
+ },
189
+ {
190
+ pathPattern: "^exports.*$",
191
+ order: ["types", "require", "import", "default"]
192
+ }
193
+ ]
194
+ }
195
+ },
196
+ {
197
+ files: GLOB_TSCONFIG,
198
+ rules: {
199
+ "jsonc/sort-keys": [
200
+ "error",
201
+ {
202
+ order: [
203
+ "extends",
204
+ "compilerOptions",
205
+ "references",
206
+ "files",
207
+ "include",
208
+ "exclude"
209
+ ],
210
+ pathPattern: "^$"
211
+ },
212
+ {
213
+ order: [
214
+ /* Projects */
215
+ "incremental",
216
+ "composite",
217
+ "tsBuildInfoFile",
218
+ "disableSourceOfProjectReferenceRedirect",
219
+ "disableSolutionSearching",
220
+ "disableReferencedProjectLoad",
221
+ /* Language and Environment */
222
+ "target",
223
+ "jsx",
224
+ "jsxFactory",
225
+ "jsxFragmentFactory",
226
+ "jsxImportSource",
227
+ "lib",
228
+ "moduleDetection",
229
+ "noLib",
230
+ "reactNamespace",
231
+ "useDefineForClassFields",
232
+ "emitDecoratorMetadata",
233
+ "experimentalDecorators",
234
+ /* Modules */
235
+ "baseUrl",
236
+ "rootDir",
237
+ "rootDirs",
238
+ "customConditions",
239
+ "module",
240
+ "moduleResolution",
241
+ "moduleSuffixes",
242
+ "noResolve",
243
+ "paths",
244
+ "resolveJsonModule",
245
+ "resolvePackageJsonExports",
246
+ "resolvePackageJsonImports",
247
+ "typeRoots",
248
+ "types",
249
+ "allowArbitraryExtensions",
250
+ "allowImportingTsExtensions",
251
+ "allowUmdGlobalAccess",
252
+ /* JavaScript Support */
253
+ "allowJs",
254
+ "checkJs",
255
+ "maxNodeModuleJsDepth",
256
+ /* Type Checking */
257
+ "strict",
258
+ "strictBindCallApply",
259
+ "strictFunctionTypes",
260
+ "strictNullChecks",
261
+ "strictPropertyInitialization",
262
+ "allowUnreachableCode",
263
+ "allowUnusedLabels",
264
+ "alwaysStrict",
265
+ "exactOptionalPropertyTypes",
266
+ "noFallthroughCasesInSwitch",
267
+ "noImplicitAny",
268
+ "noImplicitOverride",
269
+ "noImplicitReturns",
270
+ "noImplicitThis",
271
+ "noPropertyAccessFromIndexSignature",
272
+ "noUncheckedIndexedAccess",
273
+ "noUnusedLocals",
274
+ "noUnusedParameters",
275
+ "useUnknownInCatchVariables",
276
+ /* Emit */
277
+ "declaration",
278
+ "declarationDir",
279
+ "declarationMap",
280
+ "downlevelIteration",
281
+ "emitBOM",
282
+ "emitDeclarationOnly",
283
+ "importHelpers",
284
+ "importsNotUsedAsValues",
285
+ "inlineSourceMap",
286
+ "inlineSources",
287
+ "mapRoot",
288
+ "newLine",
289
+ "noEmit",
290
+ "noEmitHelpers",
291
+ "noEmitOnError",
292
+ "outDir",
293
+ "outFile",
294
+ "preserveConstEnums",
295
+ "preserveValueImports",
296
+ "removeComments",
297
+ "sourceMap",
298
+ "sourceRoot",
299
+ "stripInternal",
300
+ /* Interop Constraints */
301
+ "allowSyntheticDefaultImports",
302
+ "esModuleInterop",
303
+ "forceConsistentCasingInFileNames",
304
+ "isolatedModules",
305
+ "preserveSymlinks",
306
+ "verbatimModuleSyntax",
307
+ /* Completeness */
308
+ "skipDefaultLibCheck",
309
+ "skipLibCheck"
310
+ ],
311
+ pathPattern: "^compilerOptions$"
312
+ }
313
+ ]
314
+ }
315
+ }
316
+ ],
317
+ ((_b = options.test) != null ? _b : true) && {
318
+ files: GLOB_TESTS,
319
+ rules: {
320
+ "jest-formatting/padding-around-all": "error"
321
+ }
322
+ }
323
+ ].flat().filter(Boolean);
324
+ };
325
+
326
+ const html = () => [
327
+ {
328
+ plugins: {
329
+ "html": pluginHtml,
330
+ "html-js-support": pluginHtmlJsSupport
331
+ }
332
+ },
333
+ {
334
+ languageOptions: {
335
+ parser: parserHtml
336
+ },
337
+ settings: {
338
+ "html/report-bad-indent": "off"
339
+ },
340
+ files: [GLOB_HTML],
341
+ rules: {
342
+ ...pluginHtml.configs.recommended.rules,
343
+ "html/indent": "off",
344
+ "html/no-trailing-spaces": "off",
345
+ "html/require-closing-tags": "off",
346
+ "html/no-extra-spacing-attrs": "off",
347
+ "html/quotes": "off"
348
+ }
349
+ }
350
+ ];
351
+
352
+ const ignores = () => [
353
+ { ignores: GLOB_EXCLUDE }
354
+ ];
355
+
356
+ const imports = (options = {}) => [
357
+ {
358
+ plugins: {
359
+ import: pluginImport
360
+ }
361
+ },
362
+ {
363
+ settings: {
364
+ "import/parsers": {
365
+ espree: [".js", ".cjs", ".mjs", ".jsx"]
366
+ },
367
+ "import/resolver": {
368
+ ...options.typescript ? {
369
+ node: {
370
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
371
+ },
372
+ typescript: {
373
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
374
+ }
375
+ } : {
376
+ node: { extensions: [".js", ".mjs"] }
377
+ }
378
+ }
379
+ },
380
+ rules: {
381
+ ...pluginImport.configs.recommended.rules,
382
+ "import/first": "error",
383
+ "import/no-mutable-exports": "error",
384
+ "import/no-useless-path-segments": ["error", { noUselessIndex: true }],
385
+ "import/no-unresolved": "off",
386
+ "import/no-absolute-path": "off",
387
+ "import/namespace": "off",
388
+ // Disable this for better performance
389
+ "import/export": "error",
390
+ "import/no-duplicates": "error",
391
+ "import/no-named-default": "error",
392
+ "import/no-webpack-loader-syntax": "error",
393
+ "import/no-named-as-default-member": "off"
394
+ }
395
+ },
396
+ {
397
+ files: [GLOB_DTS],
398
+ rules: {
399
+ "import/no-duplicates": "off"
400
+ }
401
+ }
402
+ ];
403
+
404
+ const javascript = ({
405
+ overrides
406
+ } = {}) => [
407
+ {
408
+ plugins: {
409
+ "so1ve": pluginSo1ve,
410
+ "unused-imports": pluginUnusedImports,
411
+ "sort-imports": pluginSortImports,
412
+ "array-func": pluginArrayFunc,
413
+ "json-schema-validator": pluginJsonSchemaValidator,
414
+ "regexp": pluginRegexp
415
+ }
416
+ },
417
+ {
418
+ languageOptions: {
419
+ ecmaVersion: 2022,
420
+ globals: {
421
+ ...globals.browser,
422
+ ...globals.es2021,
423
+ ...globals.node,
424
+ document: "readonly",
425
+ navigator: "readonly",
426
+ window: "readonly"
427
+ },
428
+ parserOptions: {
429
+ ecmaFeatures: {
430
+ jsx: true
431
+ },
432
+ ecmaVersion: 2022,
433
+ sourceType: "module"
434
+ },
435
+ sourceType: "module"
436
+ },
437
+ rules: {
438
+ // Common
439
+ "array-bracket-newline": "off",
440
+ "array-element-newline": "off",
441
+ "arrow-body-style": "off",
442
+ "arrow-parens": "off",
443
+ "dot-notation": ["error", { allowKeywords: true }],
444
+ "function-call-argument-newline": "off",
445
+ "function-paren-newline": "off",
446
+ "generator-star": "off",
447
+ "implicit-arrow-linebreak": "off",
448
+ "indent": "off",
449
+ "indent-legacy": "off",
450
+ "jsx-quotes": "off",
451
+ "linebreak-style": "off",
452
+ "newline-per-chained-call": "off",
453
+ "no-arrow-condition": "off",
454
+ "no-comma-dangle": "off",
455
+ "no-confusing-arrow": "off",
456
+ "no-extra-semi": "off",
457
+ "no-reserved-keys": "off",
458
+ "no-spaced-func": "off",
459
+ "no-space-before-semi": "off",
460
+ "no-wrap-func": "off",
461
+ "nonblock-statement-body-position": "off",
462
+ "one-var-declaration-per-line": "off",
463
+ "switch-colon-spacing": "off",
464
+ "symbol-description": "off",
465
+ "wrap-regex": "off",
466
+ "unused-imports/no-unused-imports": "error",
467
+ "unused-imports/no-unused-vars": [
468
+ "error",
469
+ {
470
+ vars: "all",
471
+ varsIgnorePattern: "^_",
472
+ args: "after-used",
473
+ argsIgnorePattern: "^_"
474
+ }
475
+ ],
476
+ "accessor-pairs": [
477
+ "error",
478
+ { setWithoutGet: true, enforceForClassMembers: true }
479
+ ],
480
+ "constructor-super": "error",
481
+ "default-case-last": "error",
482
+ "lines-between-class-members": [
483
+ "error",
484
+ "always",
485
+ { exceptAfterSingleLine: true }
486
+ ],
487
+ "new-cap": [
488
+ "error",
489
+ { newIsCap: true, capIsNew: false, properties: true }
490
+ ],
491
+ "no-array-constructor": "error",
492
+ "no-async-promise-executor": "error",
493
+ "no-caller": "error",
494
+ "no-class-assign": "error",
495
+ "no-compare-neg-zero": "error",
496
+ "no-const-assign": "error",
497
+ "no-control-regex": "error",
498
+ "no-delete-var": "error",
499
+ "no-dupe-args": "error",
500
+ "no-dupe-class-members": "error",
501
+ "no-dupe-keys": "error",
502
+ "no-duplicate-case": "error",
503
+ "no-useless-backreference": "error",
504
+ "no-useless-call": "error",
505
+ "no-useless-computed-key": "error",
506
+ "no-useless-constructor": "error",
507
+ "no-useless-rename": "error",
508
+ "no-useless-return": "error",
509
+ "no-void": "error",
510
+ "no-empty": ["error", { allowEmptyCatch: true }],
511
+ "no-empty-character-class": "error",
512
+ "no-empty-pattern": "error",
513
+ "no-eval": "error",
514
+ "no-ex-assign": "error",
515
+ "no-extend-native": "error",
516
+ "no-extra-bind": "error",
517
+ "no-extra-boolean-cast": "error",
518
+ "no-extra-parens": ["error", "functions"],
519
+ "no-fallthrough": "error",
520
+ "no-func-assign": "error",
521
+ "no-global-assign": "error",
522
+ "no-implied-eval": "error",
523
+ "no-import-assign": "error",
524
+ "no-invalid-regexp": "error",
525
+ "no-irregular-whitespace": "error",
526
+ "no-iterator": "error",
527
+ "no-labels": ["error", { allowLoop: true, allowSwitch: false }],
528
+ "no-lone-blocks": "error",
529
+ "no-loss-of-precision": "error",
530
+ "no-misleading-character-class": "error",
531
+ "no-new-func": "error",
532
+ "no-new-object": "error",
533
+ "no-new-symbol": "error",
534
+ "no-new-wrappers": "error",
535
+ "no-prototype-builtins": "error",
536
+ "no-useless-catch": "error",
537
+ "no-param-reassign": "off",
538
+ "no-constant-condition": "error",
539
+ "no-debugger": "error",
540
+ "no-console": ["error", { allow: ["error", "warn", "table", "time"] }],
541
+ "no-cond-assign": ["error", "always"],
542
+ "no-restricted-syntax": [
543
+ "error",
544
+ "DebuggerStatement",
545
+ "LabeledStatement",
546
+ "WithStatement"
547
+ ],
548
+ "no-restricted-globals": [
549
+ "error",
550
+ { name: "global", message: "Use `globalThis` instead." },
551
+ { name: "self", message: "Use `globalThis` instead." },
552
+ { name: "isNaN", message: "Use `Number.isNaN` instead" },
553
+ { name: "isFinite", message: "Use `Number.isFinite` instead" },
554
+ { name: "parseFloat", message: "Use `Number.parseFloat` instead" },
555
+ { name: "parseInt", message: "Use `Number.parseInt` instead" }
556
+ ],
557
+ "no-restricted-properties": [
558
+ "error",
559
+ {
560
+ object: "globalThis",
561
+ property: "isNaN",
562
+ message: "Use `Number.isNaN` instead"
563
+ },
564
+ {
565
+ object: "globalThis",
566
+ property: "isFinite",
567
+ message: "Use `Number.isFinite` instead"
568
+ },
569
+ {
570
+ object: "globalThis",
571
+ property: "parseFloat",
572
+ message: "Use `Number.parseFloat` instead"
573
+ },
574
+ {
575
+ object: "globalThis",
576
+ property: "parseInt",
577
+ message: "Use `Number.parseInt` instead"
578
+ },
579
+ {
580
+ object: "window",
581
+ property: "isNaN",
582
+ message: "Use `Number.isNaN` instead"
583
+ },
584
+ {
585
+ object: "window",
586
+ property: "isFinite",
587
+ message: "Use `Number.isFinite` instead"
588
+ },
589
+ {
590
+ object: "window",
591
+ property: "parseFloat",
592
+ message: "Use `Number.parseFloat` instead"
593
+ },
594
+ {
595
+ object: "window",
596
+ property: "parseInt",
597
+ message: "Use `Number.parseInt` instead"
598
+ }
599
+ ],
600
+ "no-obj-calls": "error",
601
+ "no-octal": "error",
602
+ "no-octal-escape": "error",
603
+ "no-proto": "error",
604
+ "no-redeclare": ["error", { builtinGlobals: false }],
605
+ "no-regex-spaces": "error",
606
+ "no-self-assign": ["error", { props: true }],
607
+ "no-self-compare": "error",
608
+ "no-sequences": "error",
609
+ "no-shadow-restricted-names": "error",
610
+ "no-template-curly-in-string": "error",
611
+ "no-this-before-super": "error",
612
+ "no-throw-literal": "error",
613
+ "no-undef": "error",
614
+ "no-undef-init": "error",
615
+ "no-unexpected-multiline": "error",
616
+ "no-unmodified-loop-condition": "error",
617
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
618
+ "no-unreachable": "error",
619
+ "no-unreachable-loop": "error",
620
+ "no-unsafe-finally": "error",
621
+ "no-unsafe-negation": "error",
622
+ "no-return-await": "off",
623
+ // es6
624
+ "no-var": "error",
625
+ "prefer-const": [
626
+ "error",
627
+ {
628
+ destructuring: "all",
629
+ ignoreReadBeforeAssign: true
630
+ }
631
+ ],
632
+ "prefer-arrow-callback": [
633
+ "error",
634
+ {
635
+ allowNamedFunctions: false,
636
+ allowUnboundThis: true
637
+ }
638
+ ],
639
+ "one-var": ["error", "never"],
640
+ "object-shorthand": [
641
+ "error",
642
+ "always",
643
+ {
644
+ ignoreConstructors: false
645
+ }
646
+ ],
647
+ "prefer-exponentiation-operator": "error",
648
+ "prefer-rest-params": "error",
649
+ "prefer-spread": "error",
650
+ "prefer-template": "error",
651
+ "prefer-promise-reject-errors": "error",
652
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
653
+ "yoda": ["error", "never"],
654
+ "spaced-comment": [
655
+ "error",
656
+ "always",
657
+ {
658
+ line: {
659
+ markers: ["/"],
660
+ exceptions: ["/", "#"]
661
+ },
662
+ block: {
663
+ markers: ["!"],
664
+ exceptions: ["*"],
665
+ balanced: true
666
+ }
667
+ }
668
+ ],
669
+ // best-practice
670
+ "array-callback-return": "error",
671
+ "block-scoped-var": "error",
672
+ "no-unused-expressions": [
673
+ "error",
674
+ {
675
+ allowShortCircuit: true,
676
+ allowTernary: true,
677
+ allowTaggedTemplates: true
678
+ }
679
+ ],
680
+ "no-unused-vars": [
681
+ "error",
682
+ {
683
+ args: "none",
684
+ caughtErrors: "none",
685
+ ignoreRestSiblings: true,
686
+ vars: "all"
687
+ }
688
+ ],
689
+ "no-use-before-define": [
690
+ "error",
691
+ { functions: false, classes: false, variables: true }
692
+ ],
693
+ "consistent-return": "off",
694
+ "complexity": ["off", 11],
695
+ "eqeqeq": ["error", "smart"],
696
+ "no-alert": "error",
697
+ "no-case-declarations": "error",
698
+ "no-multi-str": "error",
699
+ "no-with": "error",
700
+ "no-invalid-this": "error",
701
+ "vars-on-top": "error",
702
+ "require-await": "off",
703
+ "use-isnan": [
704
+ "error",
705
+ {
706
+ enforceForSwitchCase: true,
707
+ enforceForIndexOf: true
708
+ }
709
+ ],
710
+ "valid-typeof": ["error", { requireStringLiterals: true }],
711
+ // so1ve
712
+ "so1ve/import-dedupe": "error",
713
+ "so1ve/use-async-with-await": "error",
714
+ // Sort Imports
715
+ "sort-imports/imports": ["error"],
716
+ "sort-imports/exports": "error",
717
+ // array-func
718
+ "array-func/prefer-array-from": "off",
719
+ // json-schema-validator
720
+ "json-schema-validator/no-invalid": "warn",
721
+ // regexp
722
+ "regexp/no-unused-capturing-group": "warn",
723
+ ...overrides
724
+ }
725
+ },
726
+ {
727
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
728
+ rules: {
729
+ "no-console": "off"
730
+ }
731
+ }
732
+ ];
733
+
734
+ const jsonc = () => [
735
+ {
736
+ plugins: {
737
+ jsonc: pluginJsonc
738
+ }
739
+ },
740
+ {
741
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_ESLINTRC],
742
+ languageOptions: {
743
+ parser: parserJsonc
744
+ },
745
+ rules: {
746
+ ...pluginJsonc.configs.base.overrides[0].rules,
747
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
748
+ "jsonc/no-octal-escape": "error",
749
+ "jsonc/quotes": "off",
750
+ "jsonc/quotes-props": "off"
751
+ }
752
+ }
753
+ ];
754
+
755
+ const mdx = ({
756
+ componentExts = [],
757
+ overrides
758
+ } = {}) => [
759
+ {
760
+ ...pluginMdx.flat,
761
+ processor: pluginMdx.createRemarkProcessor({
762
+ lintCodeBlocks: true,
763
+ languageMapper: {}
764
+ })
765
+ },
766
+ {
767
+ ...pluginMdx.flatCodeBlocks,
768
+ files: [
769
+ ...pluginMdx.flatCodeBlocks.files,
770
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/*.${ext}`)
771
+ ],
772
+ rules: {
773
+ ...pluginMdx.flatCodeBlocks.rules,
774
+ "html/require-doctype": "off",
775
+ "ts/no-redeclare": "off",
776
+ "ts/no-unused-vars": "off",
777
+ "ts/no-use-before-define": "off",
778
+ "ts/no-var-requires": "off",
779
+ "ts/consistent-type-imports": "off",
780
+ "ts/no-namespace": "off",
781
+ "ts/no-require-imports": "off",
782
+ "import/no-unresolved": "off",
783
+ "unused-imports/no-unused-imports": "off",
784
+ "unused-imports/no-unused-vars": "off",
785
+ "no-alert": "off",
786
+ "no-console": "off",
787
+ "no-restricted-imports": "off",
788
+ "no-undef": "off",
789
+ "no-unused-expressions": "off",
790
+ ...overrides
791
+ }
792
+ }
793
+ ];
794
+
795
+ const node = () => [
796
+ {
797
+ plugins: {
798
+ node: pluginNode
799
+ }
800
+ },
801
+ {
802
+ rules: {
803
+ "node/no-callback-literal": "off",
804
+ "node/handle-callback-err": ["error", "^(err|error)$"],
805
+ "node/no-deprecated-api": "error",
806
+ "node/no-exports-assign": "error",
807
+ "node/no-new-require": "error",
808
+ "node/no-path-concat": "error",
809
+ "node/process-exit-as-throw": "error"
810
+ }
811
+ }
812
+ ];
813
+
814
+ const onlyError = () => [
815
+ {
816
+ plugins: {
817
+ "only-error": pluginOnlyError
818
+ }
819
+ }
820
+ ];
821
+
822
+ const promise = () => [
823
+ {
824
+ plugins: {
825
+ promise: pluginPromise
826
+ }
827
+ },
828
+ {
829
+ rules: {
830
+ "promise/param-names": "error"
831
+ }
832
+ }
833
+ ];
834
+
835
+ const solid = ({
836
+ overrides,
837
+ typescript
838
+ } = {}) => [
839
+ {
840
+ plugins: {
841
+ solid: pluginSolid
842
+ }
843
+ },
844
+ {
845
+ languageOptions: {
846
+ sourceType: "module",
847
+ parserOptions: {
848
+ ecmaFeatures: {
849
+ jsx: true
850
+ }
851
+ }
852
+ },
853
+ rules: {
854
+ ...pluginSolid.configs.recommended.rules,
855
+ ...typescript ? pluginSolid.configs.typescript.rules : {},
856
+ ...overrides
857
+ }
858
+ }
859
+ ];
860
+
861
+ const sortImports = () => [
862
+ {
863
+ plugins: {
864
+ "sort-imports": pluginSortImports
865
+ }
866
+ },
867
+ {
868
+ rules: {
869
+ "sort-imports/imports": "error",
870
+ "sort-imports/exports": "error"
871
+ }
872
+ }
873
+ ];
874
+
875
+ const test = ({
876
+ overrides
877
+ } = {}) => [
878
+ {
879
+ plugins: {
880
+ "no-only-tests": pluginNoOnlyTests,
881
+ "vitest": pluginVitest,
882
+ "jest-formatting": pluginJestFormatting
883
+ }
884
+ },
885
+ {
886
+ files: GLOB_TESTS,
887
+ rules: {
888
+ ...pluginVitest.configs.recommended.rules,
889
+ "no-only-tests/no-only-tests": "error",
890
+ "vitest/expect-expect": "off",
891
+ "vitest/valid-describe-callback": "off",
892
+ "vitest/no-alias-methods": "error",
893
+ "vitest/no-interpolation-in-snapshots": "error",
894
+ "vitest/no-test-prefixes": "error",
895
+ "vitest/prefer-expect-resolves": "error",
896
+ "vitest/prefer-comparison-matcher": "error",
897
+ "vitest/prefer-mock-promise-shorthand": "error",
898
+ "vitest/prefer-spy-on": "error",
899
+ "vitest/prefer-to-be-falsy": "error",
900
+ "vitest/prefer-to-be-object": "error",
901
+ "vitest/prefer-to-be-truthy": "error",
902
+ "vitest/prefer-to-contain": "error",
903
+ "vitest/prefer-to-have-length": "error",
904
+ "vitest/prefer-todo": "error",
905
+ "vitest/valid-title": ["error", { allowArguments: true }],
906
+ ...overrides
907
+ }
908
+ }
909
+ ];
910
+
911
+ const toml = ({
912
+ overrides
913
+ } = {}) => [
914
+ {
915
+ plugins: {
916
+ toml: pluginToml
917
+ }
918
+ },
919
+ {
920
+ languageOptions: {
921
+ parser: parserToml
922
+ },
923
+ files: [GLOB_TOML],
924
+ rules: {
925
+ ...pluginToml.configs.recommended.rules,
926
+ "no-irregular-whitespace": "off",
927
+ "spaced-comment": "off",
928
+ ...overrides
929
+ }
930
+ }
931
+ ];
932
+
933
+ const combine = (...configs) => configs.flatMap((config) => Array.isArray(config) ? config : [config]);
934
+ const renameRules = (rules, from, to) => Object.fromEntries(
935
+ Object.entries(rules).map(([key, value]) => {
936
+ if (key.startsWith(from)) {
937
+ return [to + key.slice(from.length), value];
938
+ }
939
+ return [key, value];
940
+ })
941
+ );
942
+ const rulesOn = /* @__PURE__ */ new Set();
943
+ const rulesOff = /* @__PURE__ */ new Set();
944
+ function recordRulesStateConfigs(configs) {
945
+ var _a;
946
+ for (const config of configs) {
947
+ recordRulesState((_a = config.rules) != null ? _a : {});
948
+ }
949
+ return configs;
950
+ }
951
+ function recordRulesState(rules) {
952
+ for (const [key, value] of Object.entries(rules != null ? rules : {})) {
953
+ const firstValue = Array.isArray(value) ? value[0] : value;
954
+ if (firstValue == null) {
955
+ continue;
956
+ }
957
+ if (firstValue === "off" || firstValue === 0) {
958
+ rulesOff.add(key);
959
+ } else {
960
+ rulesOn.add(key);
961
+ }
962
+ }
963
+ return rules;
964
+ }
965
+ function warnUnnecessaryOffRules() {
966
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
967
+ for (const off of unnecessaryOffRules) {
968
+ console.warn(
969
+ `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
970
+ );
971
+ }
972
+ }
973
+
974
+ function typescript({
975
+ componentExts = [],
976
+ parserOptions,
977
+ overrides
978
+ } = {}) {
979
+ const typeAwareRules = {
980
+ "etc/no-assign-mutated-array": "error",
981
+ "etc/no-deprecated": "warn",
982
+ "etc/no-internal": "error",
983
+ "no-throw-literal": "off",
984
+ "ts/no-throw-literal": "error",
985
+ "no-implied-eval": "off",
986
+ "ts/no-implied-eval": "error",
987
+ "dot-notation": "off",
988
+ "ts/dot-notation": ["error", { allowKeywords: true }],
989
+ "no-void": ["error", { allowAsStatement: true }],
990
+ "ts/await-thenable": "error",
991
+ "ts/no-for-in-array": "error",
992
+ "ts/no-unnecessary-type-assertion": "error",
993
+ "ts/restrict-template-expressions": [
994
+ "error",
995
+ {
996
+ allowAny: true,
997
+ allowNumber: true,
998
+ allowBoolean: true
999
+ }
1000
+ ],
1001
+ "ts/array-type": ["error", { default: "array", readonly: "array" }],
1002
+ "ts/consistent-generic-constructors": "error",
1003
+ "ts/consistent-type-exports": "error",
1004
+ "ts/consistent-type-assertions": [
1005
+ "error",
1006
+ { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
1007
+ ],
1008
+ "ts/prefer-nullish-coalescing": "error",
1009
+ "ts/prefer-optional-chain": "error",
1010
+ "ts/prefer-return-this-type": "error",
1011
+ "ts/no-unnecessary-type-arguments": "error",
1012
+ "ts/non-nullable-type-assertion-style": "error"
1013
+ };
1014
+ return [
1015
+ {
1016
+ // Install the plugins without globs, so they can be configured separately.
1017
+ plugins: {
1018
+ import: pluginImport,
1019
+ ts: pluginTs,
1020
+ etc: pluginEtc
1021
+ }
1022
+ },
1023
+ {
1024
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1025
+ languageOptions: {
1026
+ parser: parserTs,
1027
+ parserOptions: {
1028
+ sourceType: "module",
1029
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1030
+ EXPERIMENTAL_useProjectService: true,
1031
+ ...parserOptions
1032
+ }
1033
+ },
1034
+ settings: {
1035
+ "import/resolver": {
1036
+ node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
1037
+ typescript: {
1038
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1039
+ }
1040
+ }
1041
+ },
1042
+ rules: {
1043
+ ...renameRules(
1044
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
1045
+ "@typescript-eslint/",
1046
+ "ts/"
1047
+ ),
1048
+ ...renameRules(
1049
+ pluginTs.configs.recommended.rules,
1050
+ "@typescript-eslint/",
1051
+ "ts/"
1052
+ ),
1053
+ "import/named": "off",
1054
+ // TS
1055
+ "ts/comma-dangle": "off",
1056
+ "ts/brace-style": "off",
1057
+ "ts/comma-spacing": "off",
1058
+ "ts/func-call-spacing": "off",
1059
+ "ts/indent": "off",
1060
+ "ts/keyword-spacing": "off",
1061
+ "ts/member-delimiter-style": "off",
1062
+ "ts/no-extra-parens": "off",
1063
+ "ts/no-extra-semi": "off",
1064
+ "ts/quotes": "off",
1065
+ "ts/semi": "off",
1066
+ "ts/space-before-function-paren": "off",
1067
+ "ts/type-annotation-spacing": "off",
1068
+ "ts/ban-ts-comment": [
1069
+ "error",
1070
+ {
1071
+ minimumDescriptionLength: 0
1072
+ }
1073
+ ],
1074
+ "ts/ban-types": [
1075
+ "error",
1076
+ {
1077
+ extendDefaults: false,
1078
+ types: {
1079
+ String: {
1080
+ message: "Use `string` instead.",
1081
+ fixWith: "string"
1082
+ },
1083
+ Number: {
1084
+ message: "Use `number` instead.",
1085
+ fixWith: "number"
1086
+ },
1087
+ Boolean: {
1088
+ message: "Use `boolean` instead.",
1089
+ fixWith: "boolean"
1090
+ },
1091
+ Symbol: {
1092
+ message: "Use `symbol` instead.",
1093
+ fixWith: "symbol"
1094
+ },
1095
+ BigInt: {
1096
+ message: "Use `bigint` instead.",
1097
+ fixWith: "bigint"
1098
+ },
1099
+ Object: {
1100
+ message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
1101
+ fixWith: "Record<PropertyKey, unknown>"
1102
+ },
1103
+ object: {
1104
+ message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
1105
+ fixWith: "Record<PropertyKey, unknown>"
1106
+ },
1107
+ Function: {
1108
+ message: "Use `(...args: any[]) => any` instead.",
1109
+ fixWith: "(...args: any[]) => any"
1110
+ }
1111
+ }
1112
+ }
1113
+ ],
1114
+ "ts/consistent-type-imports": [
1115
+ "error",
1116
+ { prefer: "type-imports", disallowTypeAnnotations: false }
1117
+ ],
1118
+ "ts/consistent-type-definitions": ["error", "interface"],
1119
+ "ts/consistent-indexed-object-style": ["error", "record"],
1120
+ "ts/prefer-ts-expect-error": "error",
1121
+ "ts/no-require-imports": "error",
1122
+ "ts/method-signature-style": ["error", "property"],
1123
+ "ts/explicit-member-accessibility": "error",
1124
+ // Override JS
1125
+ "no-useless-constructor": "off",
1126
+ "no-invalid-this": "off",
1127
+ "ts/no-invalid-this": "error",
1128
+ "no-redeclare": "off",
1129
+ "ts/no-redeclare": "error",
1130
+ "no-use-before-define": "off",
1131
+ "ts/no-use-before-define": [
1132
+ "error",
1133
+ { functions: false, classes: false, variables: true }
1134
+ ],
1135
+ "object-curly-spacing": "off",
1136
+ "space-before-blocks": "off",
1137
+ "ts/space-before-blocks": "off",
1138
+ "space-before-function-paren": "off",
1139
+ "no-dupe-class-members": "off",
1140
+ "ts/no-dupe-class-members": "error",
1141
+ "no-loss-of-precision": "off",
1142
+ "ts/no-loss-of-precision": "error",
1143
+ "lines-between-class-members": "off",
1144
+ "ts/lines-between-class-members": [
1145
+ "error",
1146
+ "always",
1147
+ { exceptAfterSingleLine: true }
1148
+ ],
1149
+ // so1ve
1150
+ "so1ve/no-inline-type-import": "error",
1151
+ // off
1152
+ "ts/camelcase": "off",
1153
+ "ts/explicit-function-return-type": "off",
1154
+ "ts/no-explicit-any": "off",
1155
+ "ts/no-parameter-properties": "off",
1156
+ "ts/no-empty-interface": "off",
1157
+ "ts/ban-ts-ignore": "off",
1158
+ "ts/no-empty-function": "off",
1159
+ "ts/no-non-null-assertion": "off",
1160
+ "ts/explicit-module-boundary-types": "off",
1161
+ "ts/triple-slash-reference": "off",
1162
+ "ts/prefer-for-of": "error",
1163
+ "ts/no-duplicate-enum-values": "error",
1164
+ "ts/no-non-null-asserted-nullish-coalescing": "error",
1165
+ // handled by unused-imports/no-unused-imports
1166
+ "ts/no-unused-vars": "off",
1167
+ ...typeAwareRules,
1168
+ ...overrides
1169
+ }
1170
+ },
1171
+ {
1172
+ files: [GLOB_MARKDOWN_CODE],
1173
+ languageOptions: {
1174
+ parser: parserTs,
1175
+ parserOptions: {
1176
+ sourceType: "module"
1177
+ }
1178
+ },
1179
+ rules: {
1180
+ ...Object.fromEntries(
1181
+ Object.keys(typeAwareRules).map((k) => [k, "off"])
1182
+ )
1183
+ }
1184
+ },
1185
+ {
1186
+ files: ["**/*.d.ts"],
1187
+ rules: {
1188
+ "eslint-comments/no-unlimited-disable": "off",
1189
+ "import/no-duplicates": "off",
1190
+ "unused-imports/no-unused-vars": "off"
1191
+ }
1192
+ },
1193
+ {
1194
+ files: ["**/*.js", "**/*.cjs"],
1195
+ rules: {
1196
+ "ts/no-require-imports": "off",
1197
+ "ts/no-var-requires": "off"
1198
+ }
1199
+ }
1200
+ ];
1201
+ }
1202
+
1203
+ const unicorn = () => [
1204
+ {
1205
+ plugins: {
1206
+ unicorn: pluginUnicorn
1207
+ },
1208
+ rules: {
1209
+ "unicorn/throw-new-error": "error",
1210
+ "unicorn/relative-url-style": ["error", "always"],
1211
+ "unicorn/switch-case-braces": "error",
1212
+ "unicorn/number-literal-case": "error",
1213
+ "unicorn/numeric-separators-style": "error",
1214
+ "unicorn/new-for-builtins": "error",
1215
+ "unicorn/error-message": "error",
1216
+ "unicorn/escape-case": "error",
1217
+ "unicorn/explicit-length-check": "error",
1218
+ "unicorn/no-instanceof-array": "error",
1219
+ "unicorn/no-new-buffer": "error",
1220
+ "unicorn/no-new-array": "error",
1221
+ "unicorn/no-array-for-each": "error",
1222
+ "unicorn/no-array-method-this-argument": "error",
1223
+ "unicorn/no-for-loop": "error",
1224
+ "unicorn/no-lonely-if": "error",
1225
+ "unicorn/no-negated-condition": "error",
1226
+ "unicorn/no-useless-spread": "error",
1227
+ "unicorn/prefer-ternary": "error",
1228
+ "unicorn/prefer-query-selector": "error",
1229
+ "unicorn/prefer-modern-dom-apis": "error",
1230
+ "unicorn/prefer-modern-math-apis": "error",
1231
+ "unicorn/prefer-json-parse-buffer": "error",
1232
+ "unicorn/prefer-date-now": "error",
1233
+ "unicorn/prefer-array-some": "error",
1234
+ "unicorn/prefer-array-index-of": "error",
1235
+ "unicorn/prefer-array-flat": "error",
1236
+ "unicorn/prefer-array-find": "error",
1237
+ "unicorn/prefer-spread": "error",
1238
+ "unicorn/prefer-set-size": "error",
1239
+ "unicorn/prefer-string-slice": "error",
1240
+ "unicorn/prefer-includes": "error",
1241
+ "unicorn/prefer-string-starts-ends-with": "error",
1242
+ "unicorn/prefer-text-content": "error",
1243
+ "unicorn/prefer-type-error": "error",
1244
+ "unicorn/prefer-node-protocol": "error",
1245
+ "unicorn/prefer-negative-index": "error",
1246
+ "unicorn/prefer-regexp-test": "error",
1247
+ "unicorn/prefer-optional-catch-binding": "error",
1248
+ "unicorn/prefer-object-from-entries": "error",
1249
+ "unicorn/prefer-prototype-methods": "error"
1250
+ }
1251
+ }
1252
+ ];
1253
+
1254
+ const vue = ({
1255
+ overrides,
1256
+ typescript
1257
+ } = {}) => [
1258
+ {
1259
+ plugins: {
1260
+ vue: pluginVue
1261
+ }
1262
+ },
1263
+ {
1264
+ files: [GLOB_VUE],
1265
+ languageOptions: {
1266
+ parser: parserVue,
1267
+ parserOptions: {
1268
+ ecmaFeatures: {
1269
+ jsx: true
1270
+ },
1271
+ extraFileExtensions: [".vue"],
1272
+ parser: typescript ? parserTs : null,
1273
+ sourceType: "module"
1274
+ }
1275
+ },
1276
+ processor: pluginVue.processors[".vue"],
1277
+ rules: {
1278
+ ...pluginVue.configs.base.rules,
1279
+ ...pluginVue.configs["vue3-essential"].rules,
1280
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
1281
+ ...pluginVue.configs["vue3-recommended"].rules,
1282
+ "no-unused-vars": "off",
1283
+ "no-undef": "off",
1284
+ "@typescript-eslint/no-unused-vars": "off",
1285
+ "vue/no-v-html": "off",
1286
+ "vue/require-prop-types": "off",
1287
+ "vue/require-default-prop": "off",
1288
+ "vue/multi-word-component-names": "off",
1289
+ "vue/no-ref-object-reactivity-loss": "error",
1290
+ "vue/no-setup-props-reactivity-loss": "error",
1291
+ "vue/block-order": [
1292
+ "error",
1293
+ {
1294
+ order: ["script:not([setup])", "script[setup]", "template", "style"]
1295
+ }
1296
+ ],
1297
+ "vue/component-api-style": ["error", ["script-setup", "composition"]],
1298
+ "vue/component-name-in-template-casing": [
1299
+ "error",
1300
+ "PascalCase",
1301
+ { registeredComponentsOnly: false }
1302
+ ],
1303
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1304
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1305
+ "vue/define-macros-order": [
1306
+ "error",
1307
+ {
1308
+ order: ["defineOptions", "defineEmits", "defineProps", "defineSlots"]
1309
+ }
1310
+ ],
1311
+ "vue/html-comment-content-spacing": [
1312
+ "error",
1313
+ "always",
1314
+ { exceptions: ["-"] }
1315
+ ],
1316
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1317
+ "vue/no-useless-v-bind": ["error", { ignoreIncludesComment: true }],
1318
+ "vue/no-unused-refs": "error",
1319
+ "vue/no-v-text-v-html-on-component": "error",
1320
+ "vue/padding-line-between-blocks": ["error", "always"],
1321
+ "vue/prefer-separate-static-class": "error",
1322
+ // extensions
1323
+ "vue/dot-location": ["error", "property"],
1324
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1325
+ "vue/eqeqeq": ["error", "smart"],
1326
+ "vue/no-constant-condition": "error",
1327
+ "vue/no-empty-pattern": "error",
1328
+ "vue/no-irregular-whitespace": "error",
1329
+ "vue/no-loss-of-precision": "error",
1330
+ "vue/no-restricted-syntax": [
1331
+ "error",
1332
+ "DebuggerStatement",
1333
+ "LabeledStatement",
1334
+ "WithStatement"
1335
+ ],
1336
+ "vue/no-sparse-arrays": "error",
1337
+ "vue/object-curly-newline": [
1338
+ "error",
1339
+ { multiline: true, consistent: true }
1340
+ ],
1341
+ "vue/object-property-newline": [
1342
+ "error",
1343
+ { allowMultiplePropertiesPerLine: true }
1344
+ ],
1345
+ "vue/object-shorthand": [
1346
+ "error",
1347
+ "always",
1348
+ { ignoreConstructors: false, avoidQuotes: true }
1349
+ ],
1350
+ "vue/prefer-template": "error",
1351
+ "vue/quote-props": ["error", "consistent-as-needed"],
1352
+ "vue/block-lang": [
1353
+ "error",
1354
+ {
1355
+ script: {
1356
+ lang: ["js", "ts"]
1357
+ },
1358
+ template: {
1359
+ lang: ["html", "jade", "pug", "ejs"]
1360
+ },
1361
+ style: {
1362
+ lang: ["css", "sass", "scss", "less", "stylus", "postcss"]
1363
+ }
1364
+ }
1365
+ ],
1366
+ "vue/require-macro-variable-name": [
1367
+ "error",
1368
+ {
1369
+ defineProps: "props",
1370
+ defineEmits: "emit",
1371
+ defineSlots: "slots",
1372
+ useSlots: "slots",
1373
+ useAttrs: "attrs"
1374
+ }
1375
+ ],
1376
+ "vue/require-typed-ref": "error",
1377
+ "vue/no-static-inline-styles": ["error", { allowBinding: true }],
1378
+ "vue/no-console": [
1379
+ "error",
1380
+ { allow: ["error", "warn", "table", "time"] }
1381
+ ],
1382
+ "vue/camelcase": "error",
1383
+ "vue/v-for-delimiter-style": ["error", "in"],
1384
+ "vue/attributes-order": [
1385
+ "error",
1386
+ {
1387
+ order: [
1388
+ "DEFINITION",
1389
+ "LIST_RENDERING",
1390
+ "CONDITIONALS",
1391
+ "RENDER_MODIFIERS",
1392
+ "TWO_WAY_BINDING",
1393
+ "OTHER_DIRECTIVES",
1394
+ ["UNIQUE", "SLOT"],
1395
+ "GLOBAL",
1396
+ "OTHER_ATTR",
1397
+ "EVENTS",
1398
+ "CONTENT"
1399
+ ],
1400
+ alphabetical: true
1401
+ }
1402
+ ],
1403
+ "vue/prefer-true-attribute-shorthand": "error",
1404
+ "vue/prefer-define-options": "error",
1405
+ "vue/html-comment-content-newline": [
1406
+ "error",
1407
+ { singleline: "ignore", multiline: "always" }
1408
+ ],
1409
+ "vue/html-comment-indent": ["error", "tab"],
1410
+ "vue/html-self-closing": [
1411
+ "error",
1412
+ {
1413
+ html: {
1414
+ void: "always",
1415
+ normal: "always",
1416
+ component: "always"
1417
+ },
1418
+ svg: "always",
1419
+ math: "always"
1420
+ }
1421
+ ],
1422
+ "vue/no-useless-concat": "error",
1423
+ // off
1424
+ "vue/no-multiple-template-root": "off",
1425
+ "vue/multiline-html-element-content-newline": "off",
1426
+ "vue/singleline-html-element-content-newline": "off",
1427
+ "vue/no-extra-parens": "off",
1428
+ "vue/array-bracket-spacing": "off",
1429
+ "vue/arrow-spacing": "off",
1430
+ "vue/block-spacing": "off",
1431
+ "vue/brace-style": "off",
1432
+ "vue/comma-dangle": "off",
1433
+ "vue/comma-spacing": "off",
1434
+ "vue/comma-style": "off",
1435
+ "vue/operator-linebreak": "off",
1436
+ "vue/template-curly-spacing": "off",
1437
+ "vue/key-spacing": "off",
1438
+ "vue/keyword-spacing": "off",
1439
+ "vue/html-quotes": "off",
1440
+ "vue/html-indent": "off",
1441
+ "vue/no-multi-spaces": "off",
1442
+ "vue/max-attributes-per-line": "off",
1443
+ "vue/html-closing-bracket-spacing": "off",
1444
+ ...overrides
1445
+ }
1446
+ }
1447
+ ];
1448
+
1449
+ const yaml = ({
1450
+ overrides
1451
+ } = {}) => [
1452
+ {
1453
+ plugins: {
1454
+ yaml: pluginYaml
1455
+ },
1456
+ languageOptions: {
1457
+ parser: parserYaml
1458
+ },
1459
+ files: [GLOB_YAML],
1460
+ rules: {
1461
+ ...renameRules(pluginYaml.configs.prettier.rules, "yml/", "yaml/"),
1462
+ ...renameRules(pluginYaml.configs.recommended.rules, "yml/", "yaml/"),
1463
+ "yaml/no-empty-document": "off",
1464
+ "spaced-comment": "off",
1465
+ ...overrides
1466
+ }
1467
+ }
1468
+ ];
1469
+
1470
+ const flatConfigProps = [
1471
+ "files",
1472
+ "ignores",
1473
+ "languageOptions",
1474
+ "linterOptions",
1475
+ "processor",
1476
+ "plugins",
1477
+ "rules",
1478
+ "settings"
1479
+ ];
1480
+ const VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1481
+ function so1ve(options = {}, ...userConfigs) {
1482
+ var _a, _b, _c, _d, _e, _f;
1483
+ const {
1484
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1485
+ solid: enableSolid = isPackageExists("solid-js"),
1486
+ typescript: enableTypeScript = isPackageExists("typescript"),
1487
+ gitignore: enableGitignore = true,
1488
+ overrides = {},
1489
+ componentExts = []
1490
+ } = options;
1491
+ const configs = [];
1492
+ if (enableGitignore) {
1493
+ if (typeof enableGitignore === "boolean") {
1494
+ if (fs.existsSync(".gitignore")) {
1495
+ configs.push([gitignore()]);
1496
+ }
1497
+ } else {
1498
+ configs.push([gitignore(enableGitignore)]);
1499
+ }
1500
+ }
1501
+ configs.push(
1502
+ ignores(),
1503
+ javascript({
1504
+ overrides: overrides.javascript
1505
+ }),
1506
+ comments(),
1507
+ node(),
1508
+ onlyError(),
1509
+ promise(),
1510
+ sortImports(),
1511
+ imports(),
1512
+ unicorn()
1513
+ );
1514
+ if (enableVue) {
1515
+ componentExts.push("vue");
1516
+ }
1517
+ if (enableTypeScript) {
1518
+ configs.push(
1519
+ typescript({
1520
+ componentExts,
1521
+ overrides: overrides.typescript
1522
+ })
1523
+ );
1524
+ }
1525
+ if ((_a = options.test) != null ? _a : true) {
1526
+ configs.push(
1527
+ test({
1528
+ overrides: overrides.test
1529
+ })
1530
+ );
1531
+ }
1532
+ if (enableVue) {
1533
+ configs.push(
1534
+ vue({
1535
+ overrides: overrides.vue,
1536
+ typescript: !!enableTypeScript
1537
+ })
1538
+ );
1539
+ }
1540
+ if (enableSolid) {
1541
+ configs.push(
1542
+ solid({
1543
+ overrides: overrides.solid,
1544
+ typescript: !!enableTypeScript
1545
+ })
1546
+ );
1547
+ }
1548
+ if ((_b = options.jsonc) != null ? _b : true) {
1549
+ configs.push(jsonc());
1550
+ }
1551
+ if ((_c = options.toml) != null ? _c : true) {
1552
+ configs.push(
1553
+ toml({
1554
+ overrides: overrides.toml
1555
+ })
1556
+ );
1557
+ }
1558
+ if ((_d = options.yaml) != null ? _d : true) {
1559
+ configs.push(
1560
+ yaml({
1561
+ overrides: overrides.yaml
1562
+ })
1563
+ );
1564
+ }
1565
+ if ((_e = options.mdx) != null ? _e : true) {
1566
+ configs.push(
1567
+ mdx({
1568
+ componentExts,
1569
+ overrides: overrides.mdx
1570
+ })
1571
+ );
1572
+ }
1573
+ if ((_f = options.formatting) != null ? _f : true) {
1574
+ configs.push(formatting(options));
1575
+ }
1576
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1577
+ if (key in options) {
1578
+ acc[key] = options[key];
1579
+ }
1580
+ return acc;
1581
+ }, {});
1582
+ if (Object.keys(fusedConfig).length > 0) {
1583
+ configs.push([fusedConfig]);
1584
+ }
1585
+ const merged = combine(...configs, ...userConfigs);
1586
+ return merged;
1587
+ }
1588
+
1589
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, combine, comments, formatting, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };