@lincy/eslint-config 6.5.2 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.cjs +178 -275
- package/dist/index.d.cts +1694 -2150
- package/dist/index.d.mts +1693 -2149
- package/dist/index.mjs +153 -249
- package/package.json +46 -42
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
3
6
|
var __create = Object.create;
|
|
4
7
|
var __defProp = Object.defineProperty;
|
|
5
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,16 +10,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
10
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
12
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
20
19
|
}
|
|
21
20
|
return to;
|
|
22
21
|
};
|
|
@@ -24,38 +23,38 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
23
|
value: mod,
|
|
25
24
|
enumerable: true
|
|
26
25
|
}) : target, mod));
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
27
|
let eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
30
28
|
let node_process = require("node:process");
|
|
31
|
-
node_process = __toESM(node_process);
|
|
29
|
+
node_process = __toESM(node_process, 1);
|
|
32
30
|
let node_fs_promises = require("node:fs/promises");
|
|
33
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
31
|
+
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
34
32
|
let node_url = require("node:url");
|
|
35
33
|
let node_fs = require("node:fs");
|
|
36
|
-
node_fs = __toESM(node_fs);
|
|
34
|
+
node_fs = __toESM(node_fs, 1);
|
|
37
35
|
let node_path = require("node:path");
|
|
38
|
-
node_path = __toESM(node_path);
|
|
36
|
+
node_path = __toESM(node_path, 1);
|
|
39
37
|
let local_pkg = require("local-pkg");
|
|
38
|
+
let _e18e_eslint_plugin = require("@e18e/eslint-plugin");
|
|
39
|
+
_e18e_eslint_plugin = __toESM(_e18e_eslint_plugin, 1);
|
|
40
40
|
let _eslint_community_eslint_plugin_eslint_comments = require("@eslint-community/eslint-plugin-eslint-comments");
|
|
41
|
-
_eslint_community_eslint_plugin_eslint_comments = __toESM(_eslint_community_eslint_plugin_eslint_comments);
|
|
41
|
+
_eslint_community_eslint_plugin_eslint_comments = __toESM(_eslint_community_eslint_plugin_eslint_comments, 1);
|
|
42
42
|
let eslint_plugin_antfu = require("eslint-plugin-antfu");
|
|
43
|
-
eslint_plugin_antfu = __toESM(eslint_plugin_antfu);
|
|
43
|
+
eslint_plugin_antfu = __toESM(eslint_plugin_antfu, 1);
|
|
44
44
|
let eslint_plugin_import_lite = require("eslint-plugin-import-lite");
|
|
45
|
-
eslint_plugin_import_lite = __toESM(eslint_plugin_import_lite);
|
|
45
|
+
eslint_plugin_import_lite = __toESM(eslint_plugin_import_lite, 1);
|
|
46
46
|
let eslint_plugin_n = require("eslint-plugin-n");
|
|
47
|
-
eslint_plugin_n = __toESM(eslint_plugin_n);
|
|
47
|
+
eslint_plugin_n = __toESM(eslint_plugin_n, 1);
|
|
48
48
|
let eslint_plugin_perfectionist = require("eslint-plugin-perfectionist");
|
|
49
|
-
eslint_plugin_perfectionist = __toESM(eslint_plugin_perfectionist);
|
|
49
|
+
eslint_plugin_perfectionist = __toESM(eslint_plugin_perfectionist, 1);
|
|
50
50
|
let eslint_plugin_unicorn = require("eslint-plugin-unicorn");
|
|
51
|
-
eslint_plugin_unicorn = __toESM(eslint_plugin_unicorn);
|
|
51
|
+
eslint_plugin_unicorn = __toESM(eslint_plugin_unicorn, 1);
|
|
52
52
|
let eslint_plugin_unused_imports = require("eslint-plugin-unused-imports");
|
|
53
|
-
eslint_plugin_unused_imports = __toESM(eslint_plugin_unused_imports);
|
|
53
|
+
eslint_plugin_unused_imports = __toESM(eslint_plugin_unused_imports, 1);
|
|
54
54
|
let globals = require("globals");
|
|
55
|
-
globals = __toESM(globals);
|
|
55
|
+
globals = __toESM(globals, 1);
|
|
56
56
|
let eslint_merge_processors = require("eslint-merge-processors");
|
|
57
57
|
let eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
58
|
-
|
|
59
58
|
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
60
59
|
const toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, node_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
61
60
|
async function findUp(name, { cwd = node_process.default.cwd(), type = "file", stopAt } = {}) {
|
|
@@ -88,7 +87,6 @@ function findUpSync(name, { cwd = node_process.default.cwd(), type = "file", sto
|
|
|
88
87
|
directory = node_path.default.dirname(directory);
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
//#endregion
|
|
93
91
|
//#region src/configs/comments.ts
|
|
94
92
|
async function comments(options = {}) {
|
|
@@ -105,7 +103,6 @@ async function comments(options = {}) {
|
|
|
105
103
|
}
|
|
106
104
|
}];
|
|
107
105
|
}
|
|
108
|
-
|
|
109
106
|
//#endregion
|
|
110
107
|
//#region src/globs.ts
|
|
111
108
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -124,7 +121,6 @@ const GLOB_JSON5 = "**/*.json5";
|
|
|
124
121
|
const GLOB_JSONC = "**/*.jsonc";
|
|
125
122
|
const GLOB_MARKDOWN = "**/*.md";
|
|
126
123
|
const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
127
|
-
const GLOB_SVELTE = "**/*.svelte";
|
|
128
124
|
const GLOB_VUE = "**/*.vue";
|
|
129
125
|
const GLOB_YAML = "**/*.y?(a)ml";
|
|
130
126
|
const GLOB_TOML = "**/*.toml";
|
|
@@ -136,7 +132,9 @@ const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
|
136
132
|
const GLOB_TESTS = [
|
|
137
133
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
138
134
|
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
139
|
-
`**/*.test.${GLOB_SRC_EXT}
|
|
135
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
136
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
137
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
140
138
|
];
|
|
141
139
|
const GLOB_ALL_SRC = [
|
|
142
140
|
GLOB_SRC,
|
|
@@ -144,9 +142,9 @@ const GLOB_ALL_SRC = [
|
|
|
144
142
|
GLOB_JSON,
|
|
145
143
|
GLOB_JSON5,
|
|
146
144
|
GLOB_MARKDOWN,
|
|
147
|
-
GLOB_SVELTE,
|
|
148
145
|
GLOB_VUE,
|
|
149
146
|
GLOB_YAML,
|
|
147
|
+
GLOB_XML,
|
|
150
148
|
GLOB_HTML
|
|
151
149
|
];
|
|
152
150
|
const GLOB_EXCLUDE = [
|
|
@@ -155,12 +153,13 @@ const GLOB_EXCLUDE = [
|
|
|
155
153
|
"**/package-lock.json",
|
|
156
154
|
"**/yarn.lock",
|
|
157
155
|
"**/pnpm-lock.yaml",
|
|
156
|
+
"**/bun.lockb",
|
|
158
157
|
"**/output",
|
|
159
158
|
"**/coverage",
|
|
160
|
-
"**/tmp",
|
|
161
159
|
"**/temp",
|
|
162
|
-
"**/.tmp",
|
|
163
160
|
"**/.temp",
|
|
161
|
+
"**/tmp",
|
|
162
|
+
"**/.tmp",
|
|
164
163
|
"**/.history",
|
|
165
164
|
"**/.vitepress/cache",
|
|
166
165
|
"**/.nuxt",
|
|
@@ -168,18 +167,22 @@ const GLOB_EXCLUDE = [
|
|
|
168
167
|
"**/.vercel",
|
|
169
168
|
"**/.changeset",
|
|
170
169
|
"**/.idea",
|
|
170
|
+
"**/.cache",
|
|
171
171
|
"**/.output",
|
|
172
172
|
"**/.vite-inspect",
|
|
173
173
|
"**/.yarn",
|
|
174
|
-
"**/vite.config.*.timestamp-*",
|
|
175
174
|
"**/CHANGELOG*.md",
|
|
176
|
-
"**/*.min.*",
|
|
177
175
|
"**/LICENSE*",
|
|
176
|
+
"**/*.min.*",
|
|
178
177
|
"**/__snapshots__",
|
|
178
|
+
"**/vite.config.*.timestamp-*",
|
|
179
179
|
"**/auto-import?(s).d.ts",
|
|
180
|
-
"**/components.d.ts"
|
|
180
|
+
"**/components.d.ts",
|
|
181
|
+
"**/.context",
|
|
182
|
+
"**/.claude",
|
|
183
|
+
"**/.agents",
|
|
184
|
+
"**/.*/skills"
|
|
181
185
|
];
|
|
182
|
-
|
|
183
186
|
//#endregion
|
|
184
187
|
//#region src/configs/disables.ts
|
|
185
188
|
async function disables() {
|
|
@@ -235,7 +238,29 @@ async function disables() {
|
|
|
235
238
|
}
|
|
236
239
|
];
|
|
237
240
|
}
|
|
238
|
-
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/configs/e18e.ts
|
|
243
|
+
async function e18e(options = {}) {
|
|
244
|
+
const { isInEditor = false, modernization = true, type = "app", moduleReplacements = type === "lib" && isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
245
|
+
const configs = _e18e_eslint_plugin.default.configs;
|
|
246
|
+
return [{
|
|
247
|
+
name: "eslint/e18e/rules",
|
|
248
|
+
plugins: { e18e: _e18e_eslint_plugin.default },
|
|
249
|
+
rules: {
|
|
250
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
251
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
252
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
253
|
+
...type === "lib" ? {} : { "e18e/prefer-static-regex": "off" },
|
|
254
|
+
"e18e/prefer-array-at": "off",
|
|
255
|
+
"e18e/prefer-array-from-map": "off",
|
|
256
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
257
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
258
|
+
"e18e/prefer-array-to-spliced": "off",
|
|
259
|
+
"e18e/prefer-spread-syntax": "off",
|
|
260
|
+
...overrides
|
|
261
|
+
}
|
|
262
|
+
}];
|
|
263
|
+
}
|
|
239
264
|
//#endregion
|
|
240
265
|
//#region src/utils.ts
|
|
241
266
|
const scopeUrl = (0, node_url.fileURLToPath)(new URL(".", require("url").pathToFileURL(__filename).href));
|
|
@@ -262,8 +287,8 @@ const parserPlain = {
|
|
|
262
287
|
/**
|
|
263
288
|
* Combine array and non-array configs into a single array.
|
|
264
289
|
*/
|
|
265
|
-
async function combine(...configs
|
|
266
|
-
return (await Promise.all(configs
|
|
290
|
+
async function combine(...configs) {
|
|
291
|
+
return (await Promise.all(configs)).flat();
|
|
267
292
|
}
|
|
268
293
|
function renameRules(rules, map) {
|
|
269
294
|
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
@@ -271,8 +296,8 @@ function renameRules(rules, map) {
|
|
|
271
296
|
return [key, value];
|
|
272
297
|
}));
|
|
273
298
|
}
|
|
274
|
-
function renamePluginInConfigs(configs
|
|
275
|
-
return configs
|
|
299
|
+
function renamePluginInConfigs(configs, map) {
|
|
300
|
+
return configs.map((i) => {
|
|
276
301
|
const clone = { ...i };
|
|
277
302
|
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
278
303
|
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
@@ -306,26 +331,26 @@ function isInEditorEnv() {
|
|
|
306
331
|
function isInGitHooksOrLintStaged() {
|
|
307
332
|
return !!(node_process.default.env.GIT_PARAMS || node_process.default.env.VSCODE_GIT_COMMAND || node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
308
333
|
}
|
|
309
|
-
|
|
310
334
|
//#endregion
|
|
311
335
|
//#region src/configs/stylistic.ts
|
|
312
336
|
const StylisticConfigDefaults = {
|
|
313
337
|
indent: 4,
|
|
314
338
|
jsx: true,
|
|
315
339
|
lessOpinionated: false,
|
|
340
|
+
other_indent: 2,
|
|
316
341
|
quotes: "single",
|
|
317
342
|
semi: false
|
|
318
343
|
};
|
|
319
344
|
async function stylistic(options = {}) {
|
|
320
|
-
const { overrides = {}, stylistic
|
|
321
|
-
const { indent, jsx
|
|
345
|
+
const { overrides = {}, stylistic = StylisticConfigDefaults } = options;
|
|
346
|
+
const { indent, jsx, lessOpinionated, quotes, semi } = typeof stylistic === "boolean" ? StylisticConfigDefaults : {
|
|
322
347
|
...StylisticConfigDefaults,
|
|
323
|
-
...stylistic
|
|
348
|
+
...stylistic
|
|
324
349
|
};
|
|
325
350
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
326
351
|
const config = pluginStylistic.configs.customize({
|
|
327
352
|
indent,
|
|
328
|
-
jsx
|
|
353
|
+
jsx,
|
|
329
354
|
pluginName: "style",
|
|
330
355
|
quotes,
|
|
331
356
|
semi
|
|
@@ -359,7 +384,6 @@ async function stylistic(options = {}) {
|
|
|
359
384
|
}
|
|
360
385
|
}];
|
|
361
386
|
}
|
|
362
|
-
|
|
363
387
|
//#endregion
|
|
364
388
|
//#region src/configs/formatters.ts
|
|
365
389
|
function mergePrettierOptions(options, overrides) {
|
|
@@ -369,18 +393,18 @@ function mergePrettierOptions(options, overrides) {
|
|
|
369
393
|
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
370
394
|
};
|
|
371
395
|
}
|
|
372
|
-
async function formatters(options = {}, stylistic
|
|
396
|
+
async function formatters(options = {}, stylistic = {}) {
|
|
373
397
|
const defaultIndent = 4;
|
|
374
398
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
375
399
|
if (options === true) {
|
|
376
|
-
const isPrettierPluginXmlInScope
|
|
400
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
377
401
|
options = {
|
|
378
402
|
css: false,
|
|
379
403
|
graphql: true,
|
|
380
404
|
html: true,
|
|
381
405
|
markdown: true,
|
|
382
|
-
svg: isPrettierPluginXmlInScope
|
|
383
|
-
xml: isPrettierPluginXmlInScope
|
|
406
|
+
svg: isPrettierPluginXmlInScope,
|
|
407
|
+
xml: isPrettierPluginXmlInScope
|
|
384
408
|
};
|
|
385
409
|
} else options = {
|
|
386
410
|
css: options.css ?? false,
|
|
@@ -393,7 +417,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
393
417
|
await ensurePackages(["eslint-plugin-format", options.xml || options.svg ? "@prettier/plugin-xml" : void 0]);
|
|
394
418
|
const { indent, quotes, semi } = {
|
|
395
419
|
...StylisticConfigDefaults,
|
|
396
|
-
...stylistic
|
|
420
|
+
...stylistic
|
|
397
421
|
};
|
|
398
422
|
const prettierOptions = Object.assign({
|
|
399
423
|
endOfLine: "lf",
|
|
@@ -410,16 +434,17 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
410
434
|
xmlSortAttributesByKey: false,
|
|
411
435
|
xmlWhitespaceSensitivity: "ignore"
|
|
412
436
|
};
|
|
413
|
-
const dprintOptions =
|
|
437
|
+
const dprintOptions = {
|
|
414
438
|
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
415
439
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
416
|
-
useTabs: indent === "tab"
|
|
417
|
-
|
|
418
|
-
|
|
440
|
+
useTabs: indent === "tab",
|
|
441
|
+
...typeof options.dprintOptions === "boolean" ? {} : options.dprintOptions || {}
|
|
442
|
+
};
|
|
443
|
+
const configs = [{
|
|
419
444
|
name: "eslint/formatter/setup",
|
|
420
445
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
421
446
|
}];
|
|
422
|
-
if (options.css) configs
|
|
447
|
+
if (options.css) configs.push({
|
|
423
448
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
424
449
|
languageOptions: { parser: parserPlain },
|
|
425
450
|
name: "eslint/formatter/css",
|
|
@@ -435,13 +460,13 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
435
460
|
name: "eslint/formatter/less",
|
|
436
461
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
437
462
|
});
|
|
438
|
-
if (options.html) configs
|
|
463
|
+
if (options.html) configs.push({
|
|
439
464
|
files: [GLOB_HTML],
|
|
440
465
|
languageOptions: { parser: parserPlain },
|
|
441
466
|
name: "eslint/formatter/html",
|
|
442
467
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
443
468
|
});
|
|
444
|
-
if (options.xml) configs
|
|
469
|
+
if (options.xml) configs.push({
|
|
445
470
|
files: [GLOB_XML],
|
|
446
471
|
languageOptions: { parser: parserPlain },
|
|
447
472
|
name: "eslint/formatter/xml",
|
|
@@ -453,7 +478,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
453
478
|
plugins: ["@prettier/plugin-xml"]
|
|
454
479
|
})] }
|
|
455
480
|
});
|
|
456
|
-
if (options.svg) configs
|
|
481
|
+
if (options.svg) configs.push({
|
|
457
482
|
files: [GLOB_SVG],
|
|
458
483
|
languageOptions: { parser: parserPlain },
|
|
459
484
|
name: "eslint/formatter/svg",
|
|
@@ -467,7 +492,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
467
492
|
});
|
|
468
493
|
if (options.markdown) {
|
|
469
494
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
470
|
-
configs
|
|
495
|
+
configs.push({
|
|
471
496
|
files: [GLOB_MARKDOWN],
|
|
472
497
|
ignores: [],
|
|
473
498
|
languageOptions: { parser: parserPlain },
|
|
@@ -481,29 +506,30 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
481
506
|
}] }
|
|
482
507
|
});
|
|
483
508
|
}
|
|
484
|
-
if (options.graphql) configs
|
|
509
|
+
if (options.graphql) configs.push({
|
|
485
510
|
files: [GLOB_GRAPHQL],
|
|
486
511
|
languageOptions: { parser: parserPlain },
|
|
487
512
|
name: "eslint/formatter/graphql",
|
|
488
513
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
489
514
|
});
|
|
490
|
-
return configs
|
|
515
|
+
return configs;
|
|
491
516
|
}
|
|
492
|
-
|
|
493
517
|
//#endregion
|
|
494
518
|
//#region src/configs/ignores.ts
|
|
495
|
-
async function ignores(
|
|
496
|
-
|
|
519
|
+
async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
520
|
+
let ignores = [...GLOB_EXCLUDE];
|
|
521
|
+
if (ignoreTypeScript) ignores.push(GLOB_TS, GLOB_TSX);
|
|
522
|
+
if (typeof userIgnores === "function") ignores = userIgnores(ignores);
|
|
523
|
+
else ignores = [...ignores, ...userIgnores];
|
|
497
524
|
return [{
|
|
498
|
-
ignores
|
|
525
|
+
ignores,
|
|
499
526
|
name: "eslint/ignores"
|
|
500
527
|
}];
|
|
501
528
|
}
|
|
502
|
-
|
|
503
529
|
//#endregion
|
|
504
530
|
//#region src/configs/imports.ts
|
|
505
531
|
async function imports(options = {}) {
|
|
506
|
-
const { overrides = {}, stylistic
|
|
532
|
+
const { overrides = {}, stylistic = true } = options;
|
|
507
533
|
return [{
|
|
508
534
|
name: "eslint/imports/rules",
|
|
509
535
|
plugins: {
|
|
@@ -519,12 +545,11 @@ async function imports(options = {}) {
|
|
|
519
545
|
"import/no-duplicates": "error",
|
|
520
546
|
"import/no-mutable-exports": "error",
|
|
521
547
|
"import/no-named-default": "error",
|
|
522
|
-
...stylistic
|
|
548
|
+
...stylistic ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
|
|
523
549
|
...overrides
|
|
524
550
|
}
|
|
525
551
|
}];
|
|
526
552
|
}
|
|
527
|
-
|
|
528
553
|
//#endregion
|
|
529
554
|
//#region src/configs/javascript.ts
|
|
530
555
|
async function javascript(options = {}) {
|
|
@@ -749,11 +774,10 @@ async function javascript(options = {}) {
|
|
|
749
774
|
}
|
|
750
775
|
}];
|
|
751
776
|
}
|
|
752
|
-
|
|
753
777
|
//#endregion
|
|
754
778
|
//#region src/configs/jsdoc.ts
|
|
755
779
|
async function jsdoc(options = {}) {
|
|
756
|
-
const { overrides = {}, stylistic
|
|
780
|
+
const { overrides = {}, stylistic = true } = options;
|
|
757
781
|
return [{
|
|
758
782
|
name: "eslint/jsdoc/setup",
|
|
759
783
|
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
@@ -776,7 +800,7 @@ async function jsdoc(options = {}) {
|
|
|
776
800
|
"jsdoc/require-returns-check": "warn",
|
|
777
801
|
"jsdoc/require-returns-description": "warn",
|
|
778
802
|
"jsdoc/require-yields-check": "warn",
|
|
779
|
-
...stylistic
|
|
803
|
+
...stylistic ? {
|
|
780
804
|
"jsdoc/check-alignment": "warn",
|
|
781
805
|
"jsdoc/multiline-blocks": "warn"
|
|
782
806
|
} : {},
|
|
@@ -784,7 +808,6 @@ async function jsdoc(options = {}) {
|
|
|
784
808
|
}
|
|
785
809
|
}];
|
|
786
810
|
}
|
|
787
|
-
|
|
788
811
|
//#endregion
|
|
789
812
|
//#region src/configs/jsonc.ts
|
|
790
813
|
async function jsonc(options = {}) {
|
|
@@ -792,7 +815,8 @@ async function jsonc(options = {}) {
|
|
|
792
815
|
GLOB_JSON,
|
|
793
816
|
GLOB_JSON5,
|
|
794
817
|
GLOB_JSONC
|
|
795
|
-
], overrides = {}, stylistic
|
|
818
|
+
], overrides = {}, stylistic = true } = options;
|
|
819
|
+
const { other_indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
796
820
|
return [{
|
|
797
821
|
name: "eslint/jsonc/setup",
|
|
798
822
|
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
@@ -827,11 +851,11 @@ async function jsonc(options = {}) {
|
|
|
827
851
|
"jsonc/space-unary-ops": "error",
|
|
828
852
|
"jsonc/valid-json-number": "error",
|
|
829
853
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
830
|
-
...stylistic
|
|
854
|
+
...stylistic ? {
|
|
831
855
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
832
856
|
"jsonc/comma-dangle": ["error", "never"],
|
|
833
857
|
"jsonc/comma-style": ["error", "last"],
|
|
834
|
-
"jsonc/indent": ["error", 2],
|
|
858
|
+
"jsonc/indent": ["error", typeof other_indent === "number" ? other_indent : 2],
|
|
835
859
|
"jsonc/key-spacing": ["error", {
|
|
836
860
|
afterColon: true,
|
|
837
861
|
beforeColon: false
|
|
@@ -849,7 +873,6 @@ async function jsonc(options = {}) {
|
|
|
849
873
|
}
|
|
850
874
|
}];
|
|
851
875
|
}
|
|
852
|
-
|
|
853
876
|
//#endregion
|
|
854
877
|
//#region src/configs/jsx.ts
|
|
855
878
|
async function jsx() {
|
|
@@ -859,22 +882,21 @@ async function jsx() {
|
|
|
859
882
|
name: "eslint/jsx/setup"
|
|
860
883
|
}];
|
|
861
884
|
}
|
|
862
|
-
|
|
863
885
|
//#endregion
|
|
864
886
|
//#region src/configs/markdown.ts
|
|
865
887
|
async function markdown(options = {}) {
|
|
866
888
|
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
867
|
-
const markdown
|
|
889
|
+
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
868
890
|
return [
|
|
869
891
|
{
|
|
870
892
|
name: "eslint/markdown/setup",
|
|
871
|
-
plugins: { markdown
|
|
893
|
+
plugins: { markdown }
|
|
872
894
|
},
|
|
873
895
|
{
|
|
874
896
|
files,
|
|
875
897
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
876
898
|
name: "eslint/markdown/processor",
|
|
877
|
-
processor: (0, eslint_merge_processors.mergeProcessors)([markdown
|
|
899
|
+
processor: (0, eslint_merge_processors.mergeProcessors)([markdown.processors.markdown, eslint_merge_processors.processorPassThrough])
|
|
878
900
|
},
|
|
879
901
|
{
|
|
880
902
|
files,
|
|
@@ -885,7 +907,8 @@ async function markdown(options = {}) {
|
|
|
885
907
|
files,
|
|
886
908
|
name: "eslint/markdown/rules",
|
|
887
909
|
rules: {
|
|
888
|
-
...markdown
|
|
910
|
+
...markdown.configs.recommended.at(0)?.rules,
|
|
911
|
+
"markdown/fenced-code-language": "off",
|
|
889
912
|
"markdown/no-missing-label-refs": "off",
|
|
890
913
|
...overridesMarkdown
|
|
891
914
|
}
|
|
@@ -911,7 +934,7 @@ async function markdown(options = {}) {
|
|
|
911
934
|
name: "eslint/markdown/disables/code",
|
|
912
935
|
rules: {
|
|
913
936
|
"antfu/no-top-level-await": "off",
|
|
914
|
-
"
|
|
937
|
+
"e18e/prefer-static-regex": "off",
|
|
915
938
|
"no-alert": "off",
|
|
916
939
|
"no-console": "off",
|
|
917
940
|
"no-labels": "off",
|
|
@@ -924,6 +947,7 @@ async function markdown(options = {}) {
|
|
|
924
947
|
"node/prefer-global/process": "off",
|
|
925
948
|
"style/comma-dangle": "off",
|
|
926
949
|
"style/eol-last": "off",
|
|
950
|
+
"style/padding-line-between-statements": "off",
|
|
927
951
|
"ts/consistent-type-imports": "off",
|
|
928
952
|
"ts/explicit-function-return-type": "off",
|
|
929
953
|
"ts/no-namespace": "off",
|
|
@@ -935,27 +959,11 @@ async function markdown(options = {}) {
|
|
|
935
959
|
"unicode-bom": "off",
|
|
936
960
|
"unused-imports/no-unused-imports": "off",
|
|
937
961
|
"unused-imports/no-unused-vars": "off",
|
|
938
|
-
"ts/await-thenable": "off",
|
|
939
|
-
"ts/dot-notation": "off",
|
|
940
|
-
"ts/no-floating-promises": "off",
|
|
941
|
-
"ts/no-for-in-array": "off",
|
|
942
|
-
"ts/no-implied-eval": "off",
|
|
943
|
-
"ts/no-misused-promises": "off",
|
|
944
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
945
|
-
"ts/no-unsafe-argument": "off",
|
|
946
|
-
"ts/no-unsafe-assignment": "off",
|
|
947
|
-
"ts/no-unsafe-call": "off",
|
|
948
|
-
"ts/no-unsafe-member-access": "off",
|
|
949
|
-
"ts/no-unsafe-return": "off",
|
|
950
|
-
"ts/restrict-plus-operands": "off",
|
|
951
|
-
"ts/restrict-template-expressions": "off",
|
|
952
|
-
"ts/unbound-method": "off",
|
|
953
962
|
...overrides
|
|
954
963
|
}
|
|
955
964
|
}
|
|
956
965
|
];
|
|
957
966
|
}
|
|
958
|
-
|
|
959
967
|
//#endregion
|
|
960
968
|
//#region src/configs/nextjs.ts
|
|
961
969
|
function normalizeRules(rules) {
|
|
@@ -988,7 +996,6 @@ async function nextjs(options = {}) {
|
|
|
988
996
|
settings: { react: { version: "detect" } }
|
|
989
997
|
}];
|
|
990
998
|
}
|
|
991
|
-
|
|
992
999
|
//#endregion
|
|
993
1000
|
//#region src/configs/node.ts
|
|
994
1001
|
async function node(options = {}) {
|
|
@@ -1012,7 +1019,6 @@ async function node(options = {}) {
|
|
|
1012
1019
|
}
|
|
1013
1020
|
}];
|
|
1014
1021
|
}
|
|
1015
|
-
|
|
1016
1022
|
//#endregion
|
|
1017
1023
|
//#region src/configs/perfectionist.ts
|
|
1018
1024
|
/**
|
|
@@ -1068,14 +1074,13 @@ async function perfectionist(options = {}) {
|
|
|
1068
1074
|
}
|
|
1069
1075
|
}];
|
|
1070
1076
|
}
|
|
1071
|
-
|
|
1072
1077
|
//#endregion
|
|
1073
1078
|
//#region src/configs/pnpm.ts
|
|
1074
1079
|
async function detectCatalogUsage() {
|
|
1075
1080
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1076
1081
|
if (!workspaceFile) return false;
|
|
1077
|
-
const yaml
|
|
1078
|
-
return yaml
|
|
1082
|
+
const yaml = await node_fs_promises.default.readFile(workspaceFile, "utf-8");
|
|
1083
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1079
1084
|
}
|
|
1080
1085
|
async function pnpm(options) {
|
|
1081
1086
|
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
@@ -1083,9 +1088,9 @@ async function pnpm(options) {
|
|
|
1083
1088
|
interopDefault(import("eslint-plugin-yml")),
|
|
1084
1089
|
interopDefault(import("yaml-eslint-parser"))
|
|
1085
1090
|
]);
|
|
1086
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1087
|
-
const configs
|
|
1088
|
-
if (json) configs
|
|
1091
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1092
|
+
const configs = [];
|
|
1093
|
+
if (json) configs.push({
|
|
1089
1094
|
files: ["package.json", "**/package.json"],
|
|
1090
1095
|
language: "jsonc/x",
|
|
1091
1096
|
name: "eslint/pnpm/package-json",
|
|
@@ -1099,8 +1104,8 @@ async function pnpm(options) {
|
|
|
1099
1104
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1100
1105
|
}
|
|
1101
1106
|
});
|
|
1102
|
-
if (yaml
|
|
1103
|
-
configs
|
|
1107
|
+
if (yaml) {
|
|
1108
|
+
configs.push({
|
|
1104
1109
|
files: ["pnpm-workspace.yaml"],
|
|
1105
1110
|
languageOptions: { parser: yamlParser },
|
|
1106
1111
|
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
@@ -1114,7 +1119,7 @@ async function pnpm(options) {
|
|
|
1114
1119
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1115
1120
|
}
|
|
1116
1121
|
});
|
|
1117
|
-
if (sort) configs
|
|
1122
|
+
if (sort) configs.push({
|
|
1118
1123
|
files: ["pnpm-workspace.yaml"],
|
|
1119
1124
|
languageOptions: { parser: yamlParser },
|
|
1120
1125
|
name: "eslint/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1193,9 +1198,8 @@ async function pnpm(options) {
|
|
|
1193
1198
|
] }
|
|
1194
1199
|
});
|
|
1195
1200
|
}
|
|
1196
|
-
return configs
|
|
1201
|
+
return configs;
|
|
1197
1202
|
}
|
|
1198
|
-
|
|
1199
1203
|
//#endregion
|
|
1200
1204
|
//#region src/configs/react.ts
|
|
1201
1205
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1212,24 +1216,12 @@ const ReactRouterPackages = [
|
|
|
1212
1216
|
"@react-router/dev"
|
|
1213
1217
|
];
|
|
1214
1218
|
const NextJsPackages = ["next"];
|
|
1215
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
1216
1219
|
async function react(options = {}) {
|
|
1217
|
-
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {},
|
|
1218
|
-
await ensurePackages([
|
|
1219
|
-
"@eslint-react/eslint-plugin",
|
|
1220
|
-
"eslint-plugin-react-hooks",
|
|
1221
|
-
"eslint-plugin-react-refresh"
|
|
1222
|
-
]);
|
|
1220
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {}, tsconfigPath } = options;
|
|
1221
|
+
await ensurePackages(["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"]);
|
|
1223
1222
|
const isTypeAware = !!tsconfigPath;
|
|
1224
|
-
const typeAwareRules = {
|
|
1225
|
-
|
|
1226
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1227
|
-
};
|
|
1228
|
-
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1229
|
-
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1230
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1231
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1232
|
-
]);
|
|
1223
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "error" };
|
|
1224
|
+
const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
|
|
1233
1225
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1234
1226
|
const isUsingRemix = RemixPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1235
1227
|
const isUsingReactRouter = ReactRouterPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
@@ -1241,8 +1233,6 @@ async function react(options = {}) {
|
|
|
1241
1233
|
plugins: {
|
|
1242
1234
|
"react": plugins["@eslint-react"],
|
|
1243
1235
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1244
|
-
"react-hooks": pluginReactHooks,
|
|
1245
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1246
1236
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1247
1237
|
"react-refresh": pluginReactRefresh,
|
|
1248
1238
|
"react-rsc": plugins["@eslint-react/rsc"],
|
|
@@ -1257,85 +1247,7 @@ async function react(options = {}) {
|
|
|
1257
1247
|
},
|
|
1258
1248
|
name: "eslint/react/rules",
|
|
1259
1249
|
rules: {
|
|
1260
|
-
|
|
1261
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1262
|
-
"react-dom/no-find-dom-node": "error",
|
|
1263
|
-
"react-dom/no-flush-sync": "error",
|
|
1264
|
-
"react-dom/no-hydrate": "error",
|
|
1265
|
-
"react-dom/no-namespace": "error",
|
|
1266
|
-
"react-dom/no-render": "error",
|
|
1267
|
-
"react-dom/no-render-return-value": "error",
|
|
1268
|
-
"react-dom/no-script-url": "warn",
|
|
1269
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1270
|
-
"react-dom/no-use-form-state": "error",
|
|
1271
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1272
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1273
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1274
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1275
|
-
"react-naming-convention/context-name": "warn",
|
|
1276
|
-
"react-naming-convention/ref-name": "warn",
|
|
1277
|
-
"react-naming-convention/use-state": "warn",
|
|
1278
|
-
"react-rsc/function-definition": "error",
|
|
1279
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1280
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1281
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1282
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1283
|
-
"react/jsx-key-before-spread": "warn",
|
|
1284
|
-
"react/jsx-no-comment-textnodes": "warn",
|
|
1285
|
-
"react/jsx-no-duplicate-props": "warn",
|
|
1286
|
-
"react/jsx-uses-react": "warn",
|
|
1287
|
-
"react/jsx-uses-vars": "warn",
|
|
1288
|
-
"react/no-access-state-in-setstate": "error",
|
|
1289
|
-
"react/no-array-index-key": "warn",
|
|
1290
|
-
"react/no-children-count": "warn",
|
|
1291
|
-
"react/no-children-for-each": "warn",
|
|
1292
|
-
"react/no-children-map": "warn",
|
|
1293
|
-
"react/no-children-only": "warn",
|
|
1294
|
-
"react/no-children-to-array": "warn",
|
|
1295
|
-
"react/no-clone-element": "warn",
|
|
1296
|
-
"react/no-component-will-mount": "error",
|
|
1297
|
-
"react/no-component-will-receive-props": "error",
|
|
1298
|
-
"react/no-component-will-update": "error",
|
|
1299
|
-
"react/no-context-provider": "warn",
|
|
1300
|
-
"react/no-create-ref": "error",
|
|
1301
|
-
"react/no-default-props": "error",
|
|
1302
|
-
"react/no-direct-mutation-state": "error",
|
|
1303
|
-
"react/no-forward-ref": "warn",
|
|
1304
|
-
"react/no-missing-key": "error",
|
|
1305
|
-
"react/no-nested-component-definitions": "error",
|
|
1306
|
-
"react/no-nested-lazy-component-declarations": "error",
|
|
1307
|
-
"react/no-prop-types": "error",
|
|
1308
|
-
"react/no-redundant-should-component-update": "error",
|
|
1309
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1310
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1311
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1312
|
-
"react/no-string-refs": "error",
|
|
1313
|
-
"react/no-unnecessary-use-prefix": "warn",
|
|
1314
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1315
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1316
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1317
|
-
"react/no-unused-class-component-members": "warn",
|
|
1318
|
-
"react/no-use-context": "warn",
|
|
1319
|
-
"react/no-useless-forward-ref": "warn",
|
|
1320
|
-
"react/prefer-namespace-import": "error",
|
|
1321
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1322
|
-
...reactCompiler ? {
|
|
1323
|
-
"react-hooks/component-hook-factories": "error",
|
|
1324
|
-
"react-hooks/config": "error",
|
|
1325
|
-
"react-hooks/error-boundaries": "error",
|
|
1326
|
-
"react-hooks/gating": "error",
|
|
1327
|
-
"react-hooks/globals": "error",
|
|
1328
|
-
"react-hooks/immutability": "error",
|
|
1329
|
-
"react-hooks/incompatible-library": "warn",
|
|
1330
|
-
"react-hooks/preserve-manual-memoization": "error",
|
|
1331
|
-
"react-hooks/purity": "error",
|
|
1332
|
-
"react-hooks/refs": "error",
|
|
1333
|
-
"react-hooks/set-state-in-effect": "error",
|
|
1334
|
-
"react-hooks/set-state-in-render": "error",
|
|
1335
|
-
"react-hooks/static-components": "error",
|
|
1336
|
-
"react-hooks/unsupported-syntax": "warn",
|
|
1337
|
-
"react-hooks/use-memo": "error"
|
|
1338
|
-
} : {},
|
|
1250
|
+
...pluginReact.configs.recommended.rules,
|
|
1339
1251
|
"react-refresh/only-export-components": ["error", {
|
|
1340
1252
|
allowConstantExport: isAllowConstantExport,
|
|
1341
1253
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1365,6 +1277,7 @@ async function react(options = {}) {
|
|
|
1365
1277
|
"shouldRevalidate"
|
|
1366
1278
|
] : []]
|
|
1367
1279
|
}],
|
|
1280
|
+
"react/prefer-namespace-import": "error",
|
|
1368
1281
|
...overrides
|
|
1369
1282
|
}
|
|
1370
1283
|
},
|
|
@@ -1373,11 +1286,7 @@ async function react(options = {}) {
|
|
|
1373
1286
|
name: "eslint/react/typescript",
|
|
1374
1287
|
rules: {
|
|
1375
1288
|
"react-dom/no-string-style-prop": "off",
|
|
1376
|
-
"react-dom/no-unknown-property": "off"
|
|
1377
|
-
"react/jsx-no-duplicate-props": "off",
|
|
1378
|
-
"react/jsx-no-undef": "off",
|
|
1379
|
-
"react/jsx-uses-react": "off",
|
|
1380
|
-
"react/jsx-uses-vars": "off"
|
|
1289
|
+
"react-dom/no-unknown-property": "off"
|
|
1381
1290
|
}
|
|
1382
1291
|
},
|
|
1383
1292
|
...isTypeAware ? [{
|
|
@@ -1388,7 +1297,6 @@ async function react(options = {}) {
|
|
|
1388
1297
|
}] : []
|
|
1389
1298
|
];
|
|
1390
1299
|
}
|
|
1391
|
-
|
|
1392
1300
|
//#endregion
|
|
1393
1301
|
//#region src/configs/regexp.ts
|
|
1394
1302
|
async function regexp(options = {}) {
|
|
@@ -1406,7 +1314,6 @@ async function regexp(options = {}) {
|
|
|
1406
1314
|
}
|
|
1407
1315
|
}];
|
|
1408
1316
|
}
|
|
1409
|
-
|
|
1410
1317
|
//#endregion
|
|
1411
1318
|
//#region src/configs/sort.ts
|
|
1412
1319
|
/**
|
|
@@ -1639,7 +1546,6 @@ function sortTsconfig() {
|
|
|
1639
1546
|
] }
|
|
1640
1547
|
}];
|
|
1641
1548
|
}
|
|
1642
|
-
|
|
1643
1549
|
//#endregion
|
|
1644
1550
|
//#region src/configs/test.ts
|
|
1645
1551
|
async function test(options = {}) {
|
|
@@ -1668,6 +1574,7 @@ async function test(options = {}) {
|
|
|
1668
1574
|
"test/prefer-hooks-in-order": "error",
|
|
1669
1575
|
"test/prefer-lowercase-title": "error",
|
|
1670
1576
|
"antfu/no-top-level-await": "off",
|
|
1577
|
+
"e18e/prefer-static-regex": "off",
|
|
1671
1578
|
"no-unused-expressions": "off",
|
|
1672
1579
|
"node/prefer-global/process": "off",
|
|
1673
1580
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1675,12 +1582,11 @@ async function test(options = {}) {
|
|
|
1675
1582
|
}
|
|
1676
1583
|
}];
|
|
1677
1584
|
}
|
|
1678
|
-
|
|
1679
1585
|
//#endregion
|
|
1680
1586
|
//#region src/configs/toml.ts
|
|
1681
1587
|
async function toml(options = {}) {
|
|
1682
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1683
|
-
const {
|
|
1588
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1589
|
+
const { other_indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1684
1590
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1685
1591
|
return [{
|
|
1686
1592
|
name: "eslint/toml/setup",
|
|
@@ -1699,11 +1605,11 @@ async function toml(options = {}) {
|
|
|
1699
1605
|
"toml/precision-of-integer": "error",
|
|
1700
1606
|
"toml/tables-order": "error",
|
|
1701
1607
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1702
|
-
...stylistic
|
|
1608
|
+
...stylistic ? {
|
|
1703
1609
|
"toml/array-bracket-newline": "error",
|
|
1704
1610
|
"toml/array-bracket-spacing": "error",
|
|
1705
1611
|
"toml/array-element-newline": "error",
|
|
1706
|
-
"toml/indent": ["error", typeof
|
|
1612
|
+
"toml/indent": ["error", typeof other_indent === "number" ? other_indent : other_indent === "tab" ? "tab" : 4],
|
|
1707
1613
|
"toml/inline-table-curly-spacing": "error",
|
|
1708
1614
|
"toml/key-spacing": "error",
|
|
1709
1615
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -1716,14 +1622,13 @@ async function toml(options = {}) {
|
|
|
1716
1622
|
}
|
|
1717
1623
|
}];
|
|
1718
1624
|
}
|
|
1719
|
-
|
|
1720
1625
|
//#endregion
|
|
1721
1626
|
//#region src/configs/typescript.ts
|
|
1722
1627
|
async function typescript(options = {}) {
|
|
1723
1628
|
const { componentExts = [], erasableOnly = false, overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1724
|
-
const files = options.files ?? [
|
|
1725
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1726
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
1629
|
+
const files = options.files ?? ["**/*.?([cm])[jt]s?(x)", ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
1630
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`];
|
|
1631
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
1727
1632
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1728
1633
|
const isTypeAware = !!tsconfigPath;
|
|
1729
1634
|
const typeAwareRules = {
|
|
@@ -1753,10 +1658,10 @@ async function typescript(options = {}) {
|
|
|
1753
1658
|
"ts/unbound-method": "error"
|
|
1754
1659
|
};
|
|
1755
1660
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1756
|
-
function makeParser(typeAware, files
|
|
1661
|
+
function makeParser(typeAware, files, ignores) {
|
|
1757
1662
|
return {
|
|
1758
|
-
files
|
|
1759
|
-
...ignores
|
|
1663
|
+
files,
|
|
1664
|
+
...ignores ? { ignores } : {},
|
|
1760
1665
|
languageOptions: {
|
|
1761
1666
|
parser: parserTs,
|
|
1762
1667
|
parserOptions: {
|
|
@@ -1866,7 +1771,6 @@ async function typescript(options = {}) {
|
|
|
1866
1771
|
}] : []
|
|
1867
1772
|
];
|
|
1868
1773
|
}
|
|
1869
|
-
|
|
1870
1774
|
//#endregion
|
|
1871
1775
|
//#region src/configs/unicorn.ts
|
|
1872
1776
|
async function unicorn(options = {}) {
|
|
@@ -1896,7 +1800,6 @@ async function unicorn(options = {}) {
|
|
|
1896
1800
|
}
|
|
1897
1801
|
}];
|
|
1898
1802
|
}
|
|
1899
|
-
|
|
1900
1803
|
//#endregion
|
|
1901
1804
|
//#region src/configs/unocss.ts
|
|
1902
1805
|
async function unocss(options = {}) {
|
|
@@ -1914,7 +1817,6 @@ async function unocss(options = {}) {
|
|
|
1914
1817
|
}
|
|
1915
1818
|
}];
|
|
1916
1819
|
}
|
|
1917
|
-
|
|
1918
1820
|
//#endregion
|
|
1919
1821
|
//#region src/configs/vue.ts
|
|
1920
1822
|
const pkg = (0, local_pkg.getPackageInfoSync)("vue");
|
|
@@ -1922,9 +1824,9 @@ let vueVersion = pkg && pkg.version;
|
|
|
1922
1824
|
vueVersion = vueVersion && vueVersion[0];
|
|
1923
1825
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1924
1826
|
async function vue(options = {}) {
|
|
1925
|
-
const { files = [GLOB_VUE], overrides = {}, stylistic
|
|
1827
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic = true } = options;
|
|
1926
1828
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1927
|
-
const { indent = 4 } = typeof stylistic
|
|
1829
|
+
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1928
1830
|
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1929
1831
|
interopDefault(import("eslint-plugin-vue")),
|
|
1930
1832
|
interopDefault(import("vue-eslint-parser")),
|
|
@@ -2077,7 +1979,7 @@ async function vue(options = {}) {
|
|
|
2077
1979
|
nonwords: false,
|
|
2078
1980
|
words: true
|
|
2079
1981
|
}],
|
|
2080
|
-
...stylistic
|
|
1982
|
+
...stylistic ? {
|
|
2081
1983
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2082
1984
|
"vue/arrow-spacing": ["error", {
|
|
2083
1985
|
after: true,
|
|
@@ -2125,12 +2027,11 @@ async function vue(options = {}) {
|
|
|
2125
2027
|
}
|
|
2126
2028
|
}];
|
|
2127
2029
|
}
|
|
2128
|
-
|
|
2129
2030
|
//#endregion
|
|
2130
2031
|
//#region src/configs/yaml.ts
|
|
2131
2032
|
async function yaml(options = {}) {
|
|
2132
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2133
|
-
const { quotes = "single" } = typeof stylistic
|
|
2033
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2034
|
+
const { other_indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2134
2035
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2135
2036
|
return [{
|
|
2136
2037
|
name: "eslint/yaml/setup",
|
|
@@ -2148,14 +2049,14 @@ async function yaml(options = {}) {
|
|
|
2148
2049
|
"yaml/no-irregular-whitespace": "error",
|
|
2149
2050
|
"yaml/plain-scalar": "error",
|
|
2150
2051
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2151
|
-
...stylistic
|
|
2052
|
+
...stylistic ? {
|
|
2152
2053
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2153
2054
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2154
2055
|
"yaml/flow-mapping-curly-newline": "error",
|
|
2155
2056
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
2156
2057
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
2157
2058
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2158
|
-
"yaml/indent": ["error", 2],
|
|
2059
|
+
"yaml/indent": ["error", typeof other_indent === "number" ? other_indent : 2],
|
|
2159
2060
|
"yaml/key-spacing": "error",
|
|
2160
2061
|
"yaml/no-tab-indent": "error",
|
|
2161
2062
|
"yaml/quotes": ["error", {
|
|
@@ -2168,7 +2069,6 @@ async function yaml(options = {}) {
|
|
|
2168
2069
|
}
|
|
2169
2070
|
}];
|
|
2170
2071
|
}
|
|
2171
|
-
|
|
2172
2072
|
//#endregion
|
|
2173
2073
|
//#region src/factory.ts
|
|
2174
2074
|
const flatConfigProps = [
|
|
@@ -2189,8 +2089,9 @@ const VuePackages = [
|
|
|
2189
2089
|
const defaultPluginRenaming = {
|
|
2190
2090
|
"@eslint-react": "react",
|
|
2191
2091
|
"@eslint-react/dom": "react-dom",
|
|
2192
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2193
2092
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2093
|
+
"@eslint-react/rsc": "react-rsc",
|
|
2094
|
+
"@eslint-react/web-api": "react-web-api",
|
|
2194
2095
|
"@next/next": "next",
|
|
2195
2096
|
"@stylistic": "style",
|
|
2196
2097
|
"@typescript-eslint": "ts",
|
|
@@ -2210,7 +2111,7 @@ const defaultPluginRenaming = {
|
|
|
2210
2111
|
* 合并的 ESLint 配置
|
|
2211
2112
|
*/
|
|
2212
2113
|
function lincy(options = {}, ...userConfigs) {
|
|
2213
|
-
const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, ignores:
|
|
2114
|
+
const { autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsx: enableJsx = true, nextjs: enableNextjs = false, overrides = {}, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, type: appType = "app", typescript: enableTypeScript = (0, local_pkg.isPackageExists)("typescript") || (0, local_pkg.isPackageExists)("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => (0, local_pkg.isPackageExists)(i)) } = options;
|
|
2214
2115
|
let isInEditor = options.isInEditor;
|
|
2215
2116
|
if (isInEditor == null) {
|
|
2216
2117
|
isInEditor = isInEditorEnv();
|
|
@@ -2218,104 +2119,108 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2218
2119
|
}
|
|
2219
2120
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2220
2121
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
2221
|
-
const configs
|
|
2222
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
2122
|
+
const configs = [];
|
|
2123
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2223
2124
|
name: "eslint/gitignore",
|
|
2224
2125
|
...enableGitignore
|
|
2225
2126
|
})]));
|
|
2226
|
-
else configs
|
|
2127
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2227
2128
|
name: "eslint/gitignore",
|
|
2228
2129
|
strict: false
|
|
2229
2130
|
})]));
|
|
2230
2131
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2231
2132
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2232
|
-
configs
|
|
2133
|
+
configs.push(ignores([...overrides.ignores || [], ...userIgnores], !enableTypeScript), javascript({
|
|
2233
2134
|
isInEditor,
|
|
2234
2135
|
overrides: getOverrides(options, "javascript")
|
|
2235
2136
|
}), comments({ overrides: getOverrides(options, "comments") }), node({ overrides: getOverrides(options, "node") }), jsdoc({
|
|
2236
2137
|
overrides: getOverrides(options, "jsdoc"),
|
|
2237
2138
|
stylistic: stylisticOptions
|
|
2238
2139
|
}), perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
2239
|
-
if (
|
|
2140
|
+
if (enableE18e) configs.push(e18e({
|
|
2141
|
+
isInEditor,
|
|
2142
|
+
...enableE18e === true ? {} : enableE18e
|
|
2143
|
+
}));
|
|
2144
|
+
if (enableUnicorn) configs.push(unicorn({
|
|
2240
2145
|
...enableUnicorn === true ? {} : enableUnicorn,
|
|
2241
2146
|
overrides: getOverrides(options, "unicorn")
|
|
2242
2147
|
}));
|
|
2243
|
-
if (enableImports) configs
|
|
2148
|
+
if (enableImports) configs.push(imports({
|
|
2244
2149
|
overrides: getOverrides(options, "imports"),
|
|
2245
2150
|
stylistic: stylisticOptions
|
|
2246
2151
|
}));
|
|
2247
2152
|
if (enableVue) componentExts.push("vue");
|
|
2248
|
-
if (enableJsx) configs
|
|
2249
|
-
if (enableTypeScript) configs
|
|
2153
|
+
if (enableJsx) configs.push(jsx());
|
|
2154
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2250
2155
|
...typescriptOptions,
|
|
2251
2156
|
componentExts,
|
|
2252
2157
|
overrides: getOverrides(options, "typescript"),
|
|
2253
2158
|
tsconfigPath,
|
|
2254
|
-
type:
|
|
2159
|
+
type: appType
|
|
2255
2160
|
}));
|
|
2256
|
-
if (stylisticOptions) configs
|
|
2161
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2257
2162
|
overrides: getOverrides(options, "stylistic"),
|
|
2258
2163
|
stylistic: stylisticOptions
|
|
2259
2164
|
}));
|
|
2260
|
-
if (enableRegexp) configs
|
|
2165
|
+
if (enableRegexp) configs.push(regexp({
|
|
2261
2166
|
...resolveSubOptions(options, "regexp"),
|
|
2262
2167
|
...getOverrides(options, "regexp")
|
|
2263
2168
|
}));
|
|
2264
|
-
if (options.test ?? true) configs
|
|
2169
|
+
if (options.test ?? true) configs.push(test({
|
|
2265
2170
|
...resolveSubOptions(options, "test"),
|
|
2266
2171
|
isInEditor,
|
|
2267
2172
|
overrides: getOverrides(options, "test")
|
|
2268
2173
|
}));
|
|
2269
|
-
if (enableVue) configs
|
|
2174
|
+
if (enableVue) configs.push(vue({
|
|
2270
2175
|
...resolveSubOptions(options, "vue"),
|
|
2271
2176
|
overrides: getOverrides(options, "vue"),
|
|
2272
2177
|
stylistic: stylisticOptions,
|
|
2273
2178
|
typescript: !!enableTypeScript
|
|
2274
2179
|
}));
|
|
2275
|
-
if (enableReact) configs
|
|
2180
|
+
if (enableReact) configs.push(react({
|
|
2276
2181
|
...typescriptOptions,
|
|
2277
2182
|
...resolveSubOptions(options, "react"),
|
|
2278
2183
|
overrides: getOverrides(options, "react"),
|
|
2279
2184
|
tsconfigPath
|
|
2280
2185
|
}));
|
|
2281
|
-
if (enableNextjs) configs
|
|
2282
|
-
if (enableUnoCSS) configs
|
|
2186
|
+
if (enableNextjs) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2187
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2283
2188
|
...resolveSubOptions(options, "unocss"),
|
|
2284
2189
|
overrides: getOverrides(options, "unocss")
|
|
2285
2190
|
}));
|
|
2286
|
-
if (options.jsonc ?? true) configs
|
|
2191
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2287
2192
|
...resolveSubOptions(options, "jsonc"),
|
|
2288
2193
|
overrides: getOverrides(options, "jsonc"),
|
|
2289
2194
|
stylistic: stylisticOptions
|
|
2290
2195
|
}), sortPackageJson(), sortTsconfig());
|
|
2291
|
-
if (enableCatalogs) configs
|
|
2196
|
+
if (enableCatalogs) configs.push(pnpm({
|
|
2292
2197
|
isInEditor,
|
|
2293
2198
|
...resolveSubOptions(options, "pnpm")
|
|
2294
2199
|
}));
|
|
2295
|
-
if (options.yaml ?? true) configs
|
|
2200
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2296
2201
|
...resolveSubOptions(options, "yaml"),
|
|
2297
2202
|
overrides: getOverrides(options, "yaml"),
|
|
2298
2203
|
stylistic: stylisticOptions
|
|
2299
2204
|
}));
|
|
2300
|
-
if (options.toml ?? true) configs
|
|
2205
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2301
2206
|
overrides: getOverrides(options, "toml"),
|
|
2302
2207
|
stylistic: stylisticOptions
|
|
2303
2208
|
}));
|
|
2304
|
-
if (options.markdown ?? true) configs
|
|
2209
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2305
2210
|
...resolveSubOptions(options, "markdown"),
|
|
2306
2211
|
componentExts,
|
|
2307
2212
|
overrides: getOverrides(options, "markdown")
|
|
2308
2213
|
}));
|
|
2309
|
-
if (options.formatters) configs
|
|
2310
|
-
configs
|
|
2214
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2215
|
+
configs.push(disables());
|
|
2311
2216
|
if ("files" in options) throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
|
|
2312
2217
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2313
2218
|
if (key in options) acc[key] = options[key];
|
|
2314
2219
|
return acc;
|
|
2315
2220
|
}, {});
|
|
2316
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2221
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2317
2222
|
let composer = new eslint_flat_config_utils.FlatConfigComposer();
|
|
2318
|
-
composer = composer.append(...configs
|
|
2223
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2319
2224
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2320
2225
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2321
2226
|
"unused-imports/no-unused-imports",
|
|
@@ -2334,11 +2239,9 @@ function getOverrides(options, key) {
|
|
|
2334
2239
|
..."overrides" in sub ? sub.overrides : {}
|
|
2335
2240
|
};
|
|
2336
2241
|
}
|
|
2337
|
-
|
|
2338
2242
|
//#endregion
|
|
2339
2243
|
//#region src/index.ts
|
|
2340
2244
|
var src_default = lincy;
|
|
2341
|
-
|
|
2342
2245
|
//#endregion
|
|
2343
2246
|
exports.GLOB_ALL_SRC = GLOB_ALL_SRC;
|
|
2344
2247
|
exports.GLOB_CSS = GLOB_CSS;
|
|
@@ -2359,7 +2262,6 @@ exports.GLOB_SCSS = GLOB_SCSS;
|
|
|
2359
2262
|
exports.GLOB_SRC = GLOB_SRC;
|
|
2360
2263
|
exports.GLOB_SRC_EXT = GLOB_SRC_EXT;
|
|
2361
2264
|
exports.GLOB_STYLE = GLOB_STYLE;
|
|
2362
|
-
exports.GLOB_SVELTE = GLOB_SVELTE;
|
|
2363
2265
|
exports.GLOB_SVG = GLOB_SVG;
|
|
2364
2266
|
exports.GLOB_TESTS = GLOB_TESTS;
|
|
2365
2267
|
exports.GLOB_TOML = GLOB_TOML;
|
|
@@ -2374,6 +2276,7 @@ exports.comments = comments;
|
|
|
2374
2276
|
exports.default = src_default;
|
|
2375
2277
|
exports.defaultPluginRenaming = defaultPluginRenaming;
|
|
2376
2278
|
exports.disables = disables;
|
|
2279
|
+
exports.e18e = e18e;
|
|
2377
2280
|
exports.ensurePackages = ensurePackages;
|
|
2378
2281
|
exports.formatters = formatters;
|
|
2379
2282
|
exports.getOverrides = getOverrides;
|
|
@@ -2409,4 +2312,4 @@ exports.typescript = typescript;
|
|
|
2409
2312
|
exports.unicorn = unicorn;
|
|
2410
2313
|
exports.unocss = unocss;
|
|
2411
2314
|
exports.vue = vue;
|
|
2412
|
-
exports.yaml = yaml;
|
|
2315
|
+
exports.yaml = yaml;
|