@ntnyq/eslint-config 5.5.0 → 5.7.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/dist/index.d.ts +426 -183
- package/dist/index.js +239 -198
- package/package.json +36 -35
package/dist/index.js
CHANGED
|
@@ -333,7 +333,7 @@ const unCategorizedRules = {
|
|
|
333
333
|
* @returns ESLint configs
|
|
334
334
|
*/
|
|
335
335
|
const configVue = (options = {}) => {
|
|
336
|
-
const { files = [GLOB_VUE], extraFileExtensions = [] } = options;
|
|
336
|
+
const { files = [GLOB_VUE], ecmaVersion = "latest", extraFileExtensions = [] } = options;
|
|
337
337
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
338
338
|
function getVueProcessor() {
|
|
339
339
|
const processorVueSFC = pluginVue.processors[".vue"];
|
|
@@ -359,7 +359,7 @@ const configVue = (options = {}) => {
|
|
|
359
359
|
languageOptions: {
|
|
360
360
|
parser: parserVue,
|
|
361
361
|
parserOptions: {
|
|
362
|
-
ecmaVersion
|
|
362
|
+
ecmaVersion,
|
|
363
363
|
extraFileExtensions,
|
|
364
364
|
parser: parserTypeScript,
|
|
365
365
|
sourceType: "module",
|
|
@@ -550,8 +550,7 @@ function getOverrides(options, key) {
|
|
|
550
550
|
//#endregion
|
|
551
551
|
//#region src/utils/combineConfigs.ts
|
|
552
552
|
async function combineConfigs(...configs) {
|
|
553
|
-
|
|
554
|
-
return resolved.flat();
|
|
553
|
+
return (await Promise.all(configs)).flat();
|
|
555
554
|
}
|
|
556
555
|
|
|
557
556
|
//#endregion
|
|
@@ -577,8 +576,7 @@ async function ensurePackages(packages) {
|
|
|
577
576
|
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
578
577
|
if (nonExistingPackages.length === 0) return;
|
|
579
578
|
const { confirm } = await import("@clack/prompts");
|
|
580
|
-
|
|
581
|
-
if (confirmInstall) try {
|
|
579
|
+
if (await confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) try {
|
|
582
580
|
const { installPackage } = await import("@antfu/install-pkg");
|
|
583
581
|
await installPackage(nonExistingPackages, { dev: true });
|
|
584
582
|
} catch (err) {
|
|
@@ -601,12 +599,11 @@ async function interopDefault(mod) {
|
|
|
601
599
|
//#endregion
|
|
602
600
|
//#region src/utils/mergePrettierOptions.ts
|
|
603
601
|
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
604
|
-
|
|
602
|
+
return {
|
|
605
603
|
...options,
|
|
606
604
|
...overrides,
|
|
607
605
|
plugins: [...options.plugins || [], ...overrides.plugins || []]
|
|
608
606
|
};
|
|
609
|
-
return result;
|
|
610
607
|
}
|
|
611
608
|
|
|
612
609
|
//#endregion
|
|
@@ -1292,6 +1289,10 @@ const configAstro = async (options = {}) => {
|
|
|
1292
1289
|
|
|
1293
1290
|
//#endregion
|
|
1294
1291
|
//#region src/configs/jsdoc.ts
|
|
1292
|
+
const SPECIAL_CHAR = {
|
|
1293
|
+
emptyString: "",
|
|
1294
|
+
singleSpace: " "
|
|
1295
|
+
};
|
|
1295
1296
|
/**
|
|
1296
1297
|
* JavaScript specific rules
|
|
1297
1298
|
*/
|
|
@@ -1324,6 +1325,8 @@ const configJsdoc = (options = {}) => [{
|
|
|
1324
1325
|
name: "ntnyq/jsdoc",
|
|
1325
1326
|
plugins: { jsdoc: pluginJsdoc },
|
|
1326
1327
|
rules: {
|
|
1328
|
+
"jsdoc/prefer-import-tag": "off",
|
|
1329
|
+
"jsdoc/require-tags": "off",
|
|
1327
1330
|
"jsdoc/tag-lines": "off",
|
|
1328
1331
|
"jsdoc/text-escaping": "off",
|
|
1329
1332
|
"jsdoc/check-access": "warn",
|
|
@@ -1334,7 +1337,17 @@ const configJsdoc = (options = {}) => [{
|
|
|
1334
1337
|
"jsdoc/require-property-name": "warn",
|
|
1335
1338
|
"jsdoc/require-returns-check": "warn",
|
|
1336
1339
|
"jsdoc/require-returns-description": "warn",
|
|
1340
|
+
"jsdoc/require-template-description": "warn",
|
|
1337
1341
|
"jsdoc/require-yields-check": "warn",
|
|
1342
|
+
"jsdoc/require-next-description": "warn",
|
|
1343
|
+
"jsdoc/require-next-type": "warn",
|
|
1344
|
+
"jsdoc/require-throws-description": "warn",
|
|
1345
|
+
"jsdoc/require-throws-type": "warn",
|
|
1346
|
+
"jsdoc/require-yields-description": "warn",
|
|
1347
|
+
"jsdoc/require-yields-type": "warn",
|
|
1348
|
+
"jsdoc/ts-method-signature-style": "warn",
|
|
1349
|
+
"jsdoc/ts-no-empty-object-type": "warn",
|
|
1350
|
+
"jsdoc/ts-no-unnecessary-template-expression": "warn",
|
|
1338
1351
|
"jsdoc/check-alignment": "error",
|
|
1339
1352
|
"jsdoc/check-line-alignment": "error",
|
|
1340
1353
|
"jsdoc/check-param-names": "error",
|
|
@@ -1364,8 +1377,25 @@ const configJsdoc = (options = {}) => [{
|
|
|
1364
1377
|
"jsdoc/no-blank-blocks": "error",
|
|
1365
1378
|
"jsdoc/no-defaults": "error",
|
|
1366
1379
|
"jsdoc/no-multi-asterisks": "error",
|
|
1380
|
+
"jsdoc/reject-any-type": "error",
|
|
1381
|
+
"jsdoc/reject-function-type": "error",
|
|
1367
1382
|
"jsdoc/require-asterisk-prefix": "error",
|
|
1368
1383
|
"jsdoc/require-hyphen-before-param-description": "error",
|
|
1384
|
+
"jsdoc/type-formatting": ["error", {
|
|
1385
|
+
arrayBrackets: "square",
|
|
1386
|
+
enableFixer: true,
|
|
1387
|
+
genericDot: false,
|
|
1388
|
+
keyValuePostColonSpacing: SPECIAL_CHAR.singleSpace,
|
|
1389
|
+
keyValuePostKeySpacing: SPECIAL_CHAR.emptyString,
|
|
1390
|
+
keyValuePostOptionalSpacing: SPECIAL_CHAR.emptyString,
|
|
1391
|
+
keyValuePostVariadicSpacing: SPECIAL_CHAR.emptyString,
|
|
1392
|
+
objectFieldIndent: SPECIAL_CHAR.emptyString,
|
|
1393
|
+
objectFieldQuote: null,
|
|
1394
|
+
objectFieldSeparator: "comma",
|
|
1395
|
+
stringQuotes: "single",
|
|
1396
|
+
typeBracketSpacing: SPECIAL_CHAR.emptyString,
|
|
1397
|
+
unionSpacing: SPECIAL_CHAR.singleSpace
|
|
1398
|
+
}],
|
|
1369
1399
|
...options.typescript ? typescriptRules : javscriptRules,
|
|
1370
1400
|
...options.overrides
|
|
1371
1401
|
}
|
|
@@ -1529,25 +1559,31 @@ const configPinia = (options = {}) => {
|
|
|
1529
1559
|
* @returns ESLint configs
|
|
1530
1560
|
*/
|
|
1531
1561
|
const configDepend = (options = {}) => {
|
|
1532
|
-
const { files = [GLOB_SRC], allowed = [], packageJson: enableCheckPackageJson = true
|
|
1562
|
+
const { files = [GLOB_SRC], allowed = [], modules = [], packageJson: enableCheckPackageJson = true, presets = [
|
|
1563
|
+
"native",
|
|
1564
|
+
"microutilities",
|
|
1565
|
+
"preferred"
|
|
1566
|
+
] } = options;
|
|
1567
|
+
const rules = {
|
|
1568
|
+
"depend/ban-dependencies": ["error", {
|
|
1569
|
+
allowed,
|
|
1570
|
+
modules,
|
|
1571
|
+
presets
|
|
1572
|
+
}],
|
|
1573
|
+
...options.overrides
|
|
1574
|
+
};
|
|
1533
1575
|
const configs = [{
|
|
1534
1576
|
name: "ntnyq/depend",
|
|
1535
1577
|
files,
|
|
1536
1578
|
plugins: { depend: pluginDepend },
|
|
1537
|
-
rules
|
|
1538
|
-
"depend/ban-dependencies": ["error", { allowed }],
|
|
1539
|
-
...options.overrides
|
|
1540
|
-
}
|
|
1579
|
+
rules
|
|
1541
1580
|
}];
|
|
1542
1581
|
if (enableCheckPackageJson) configs.push({
|
|
1543
1582
|
name: "ntnyq/depend/package-json",
|
|
1544
1583
|
files: [GLOB_PACKAGE_JSON],
|
|
1545
1584
|
plugins: { depend: pluginDepend },
|
|
1546
1585
|
languageOptions: { parser: parserJsonc },
|
|
1547
|
-
rules
|
|
1548
|
-
"depend/ban-dependencies": ["error", { allowed }],
|
|
1549
|
-
...options.overrides
|
|
1550
|
-
}
|
|
1586
|
+
rules
|
|
1551
1587
|
});
|
|
1552
1588
|
return configs;
|
|
1553
1589
|
};
|
|
@@ -1885,7 +1921,6 @@ const configSvelte = async (options = {}) => {
|
|
|
1885
1921
|
"svelte/no-dupe-else-if-blocks": "error",
|
|
1886
1922
|
"svelte/no-dupe-style-properties": "error",
|
|
1887
1923
|
"svelte/no-dupe-use-directives": "error",
|
|
1888
|
-
"svelte/no-dynamic-slot-name": "error",
|
|
1889
1924
|
"svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
|
|
1890
1925
|
"svelte/no-inner-declarations": "error",
|
|
1891
1926
|
"svelte/no-not-function-handler": "error",
|
|
@@ -2190,7 +2225,7 @@ const configDeMorgan = (options = {}) => [{
|
|
|
2190
2225
|
*/
|
|
2191
2226
|
const configMarkdown = (options = {}) => {
|
|
2192
2227
|
const { files = [GLOB_MARKDOWN_CODE], extraFileExtensions = [] } = options;
|
|
2193
|
-
|
|
2228
|
+
return [
|
|
2194
2229
|
...pluginMarkdown.configs.processor.map((config) => ({
|
|
2195
2230
|
...config,
|
|
2196
2231
|
name: `ntnyq/${config.name}`
|
|
@@ -2243,7 +2278,6 @@ const configMarkdown = (options = {}) => {
|
|
|
2243
2278
|
}
|
|
2244
2279
|
}
|
|
2245
2280
|
];
|
|
2246
|
-
return configs;
|
|
2247
2281
|
};
|
|
2248
2282
|
|
|
2249
2283
|
//#endregion
|
|
@@ -2454,179 +2488,184 @@ const strictRules = {
|
|
|
2454
2488
|
* @param options - {@link ConfigJavaScriptOptions}
|
|
2455
2489
|
* @returns ESLint configs
|
|
2456
2490
|
*/
|
|
2457
|
-
const configJavaScript = (options = {}) =>
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
"consistent-return": "off",
|
|
2472
|
-
"no-return-assign": "off",
|
|
2473
|
-
"no-useless-escape": "off",
|
|
2474
|
-
"require-await": "off",
|
|
2475
|
-
"sort-imports": "off",
|
|
2476
|
-
"accessor-pairs": ["error", {
|
|
2477
|
-
enforceForClassMembers: true,
|
|
2478
|
-
setWithoutGet: true
|
|
2479
|
-
}],
|
|
2480
|
-
"array-callback-return": "error",
|
|
2481
|
-
"block-scoped-var": "error",
|
|
2482
|
-
camelcase: ["error", {
|
|
2483
|
-
allow: ["^UNSAFE_"],
|
|
2484
|
-
ignoreGlobals: true,
|
|
2485
|
-
properties: "never"
|
|
2486
|
-
}],
|
|
2487
|
-
"constructor-super": "error",
|
|
2488
|
-
curly: ["error", "all"],
|
|
2489
|
-
"default-case-last": "error",
|
|
2490
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
2491
|
-
eqeqeq: ["error", "smart"],
|
|
2492
|
-
"new-cap": ["error", {
|
|
2493
|
-
capIsNew: false,
|
|
2494
|
-
newIsCap: true,
|
|
2495
|
-
properties: true
|
|
2496
|
-
}],
|
|
2497
|
-
"no-alert": "error",
|
|
2498
|
-
"no-array-constructor": "error",
|
|
2499
|
-
"no-async-promise-executor": "error",
|
|
2500
|
-
"no-caller": "error",
|
|
2501
|
-
"no-case-declarations": "error",
|
|
2502
|
-
"no-class-assign": "error",
|
|
2503
|
-
"no-compare-neg-zero": "error",
|
|
2504
|
-
"no-cond-assign": "error",
|
|
2505
|
-
"no-const-assign": "error",
|
|
2506
|
-
"no-constant-condition": ["error", { checkLoops: false }],
|
|
2507
|
-
"no-control-regex": "error",
|
|
2508
|
-
"no-debugger": "error",
|
|
2509
|
-
"no-delete-var": "error",
|
|
2510
|
-
"no-dupe-args": "error",
|
|
2511
|
-
"no-dupe-class-members": "error",
|
|
2512
|
-
"no-dupe-keys": "error",
|
|
2513
|
-
"no-duplicate-case": "error",
|
|
2514
|
-
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
2515
|
-
"no-empty-character-class": "error",
|
|
2516
|
-
"no-empty-pattern": "error",
|
|
2517
|
-
"no-empty-static-block": "error",
|
|
2518
|
-
"no-eval": "error",
|
|
2519
|
-
"no-ex-assign": "error",
|
|
2520
|
-
"no-extend-native": "error",
|
|
2521
|
-
"no-extra-bind": "error",
|
|
2522
|
-
"no-extra-boolean-cast": "error",
|
|
2523
|
-
"no-fallthrough": "error",
|
|
2524
|
-
"no-func-assign": "error",
|
|
2525
|
-
"no-global-assign": "error",
|
|
2526
|
-
"no-implied-eval": "error",
|
|
2527
|
-
"no-import-assign": "error",
|
|
2528
|
-
"no-invalid-regexp": "error",
|
|
2529
|
-
"no-irregular-whitespace": "error",
|
|
2530
|
-
"no-iterator": "error",
|
|
2531
|
-
"no-labels": ["error", {
|
|
2532
|
-
allowLoop: false,
|
|
2533
|
-
allowSwitch: false
|
|
2534
|
-
}],
|
|
2535
|
-
"no-lone-blocks": "error",
|
|
2536
|
-
"no-loss-of-precision": "error",
|
|
2537
|
-
"no-misleading-character-class": "error",
|
|
2538
|
-
"no-multi-str": "error",
|
|
2539
|
-
"no-negated-condition": "error",
|
|
2540
|
-
"no-new": "error",
|
|
2541
|
-
"no-new-func": "error",
|
|
2542
|
-
"no-new-native-nonconstructor": "error",
|
|
2543
|
-
"no-new-wrappers": "error",
|
|
2544
|
-
"no-obj-calls": "error",
|
|
2545
|
-
"no-octal": "error",
|
|
2546
|
-
"no-octal-escape": "error",
|
|
2547
|
-
"no-proto": "error",
|
|
2548
|
-
"no-prototype-builtins": "error",
|
|
2549
|
-
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
2550
|
-
"no-regex-spaces": "error",
|
|
2551
|
-
"no-self-assign": ["error", { props: true }],
|
|
2552
|
-
"no-self-compare": "error",
|
|
2553
|
-
"no-sequences": "error",
|
|
2554
|
-
"no-shadow-restricted-names": "error",
|
|
2555
|
-
"no-sparse-arrays": "error",
|
|
2556
|
-
"no-template-curly-in-string": "error",
|
|
2557
|
-
"no-this-before-super": "error",
|
|
2558
|
-
"no-throw-literal": "error",
|
|
2559
|
-
"no-undef": "error",
|
|
2560
|
-
"no-undef-init": "error",
|
|
2561
|
-
"no-unexpected-multiline": "error",
|
|
2562
|
-
"no-unmodified-loop-condition": "error",
|
|
2563
|
-
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
2564
|
-
"no-unreachable": "error",
|
|
2565
|
-
"no-unreachable-loop": "error",
|
|
2566
|
-
"no-unsafe-finally": "error",
|
|
2567
|
-
"no-unsafe-negation": "error",
|
|
2568
|
-
"no-unused-expressions": ["error", {
|
|
2569
|
-
allowShortCircuit: true,
|
|
2570
|
-
allowTaggedTemplates: true,
|
|
2571
|
-
allowTernary: true
|
|
2572
|
-
}],
|
|
2573
|
-
"no-unused-vars": ["error", {
|
|
2574
|
-
args: "none",
|
|
2575
|
-
caughtErrors: "none",
|
|
2576
|
-
ignoreRestSiblings: true,
|
|
2577
|
-
vars: "all"
|
|
2578
|
-
}],
|
|
2579
|
-
"no-use-before-define": ["error", {
|
|
2580
|
-
allowNamedExports: false,
|
|
2581
|
-
classes: false,
|
|
2582
|
-
functions: false,
|
|
2583
|
-
variables: true
|
|
2584
|
-
}],
|
|
2585
|
-
"no-useless-backreference": "error",
|
|
2586
|
-
"no-useless-call": "error",
|
|
2587
|
-
"no-useless-catch": "error",
|
|
2588
|
-
"no-useless-computed-key": "error",
|
|
2589
|
-
"no-useless-constructor": "error",
|
|
2590
|
-
"no-useless-rename": "error",
|
|
2591
|
-
"no-useless-return": "error",
|
|
2592
|
-
"no-var": "error",
|
|
2593
|
-
"no-void": "error",
|
|
2594
|
-
"no-with": "error",
|
|
2595
|
-
"object-shorthand": [
|
|
2596
|
-
"error",
|
|
2597
|
-
"always",
|
|
2598
|
-
{
|
|
2599
|
-
avoidQuotes: true,
|
|
2600
|
-
ignoreConstructors: false
|
|
2491
|
+
const configJavaScript = (options = {}) => {
|
|
2492
|
+
const { ecmaVersion = "latest" } = options;
|
|
2493
|
+
return [{
|
|
2494
|
+
...jsConfig.configs.recommended,
|
|
2495
|
+
name: "ntnyq/js/recommended"
|
|
2496
|
+
}, {
|
|
2497
|
+
name: "ntnyq/js/core",
|
|
2498
|
+
languageOptions: {
|
|
2499
|
+
ecmaVersion,
|
|
2500
|
+
sourceType: "module",
|
|
2501
|
+
globals: {
|
|
2502
|
+
...globals.browser,
|
|
2503
|
+
...globals.es2021,
|
|
2504
|
+
...globals.node
|
|
2601
2505
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
}]
|
|
2506
|
+
},
|
|
2507
|
+
rules: {
|
|
2508
|
+
"consistent-return": "off",
|
|
2509
|
+
"no-return-assign": "off",
|
|
2510
|
+
"no-useless-escape": "off",
|
|
2511
|
+
"require-await": "off",
|
|
2512
|
+
"sort-imports": "off",
|
|
2513
|
+
"accessor-pairs": ["error", {
|
|
2514
|
+
enforceForClassMembers: true,
|
|
2515
|
+
setWithoutGet: true
|
|
2516
|
+
}],
|
|
2517
|
+
"array-callback-return": "error",
|
|
2518
|
+
"block-scoped-var": "error",
|
|
2519
|
+
camelcase: ["error", {
|
|
2520
|
+
allow: ["^UNSAFE_"],
|
|
2521
|
+
ignoreGlobals: true,
|
|
2522
|
+
properties: "never"
|
|
2523
|
+
}],
|
|
2524
|
+
"constructor-super": "error",
|
|
2525
|
+
curly: ["error", "all"],
|
|
2526
|
+
"default-case-last": "error",
|
|
2527
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
2528
|
+
eqeqeq: ["error", "smart"],
|
|
2529
|
+
"new-cap": ["error", {
|
|
2530
|
+
capIsNew: false,
|
|
2531
|
+
newIsCap: true,
|
|
2532
|
+
properties: true
|
|
2533
|
+
}],
|
|
2534
|
+
"no-alert": "error",
|
|
2535
|
+
"no-array-constructor": "error",
|
|
2536
|
+
"no-async-promise-executor": "error",
|
|
2537
|
+
"no-caller": "error",
|
|
2538
|
+
"no-case-declarations": "error",
|
|
2539
|
+
"no-class-assign": "error",
|
|
2540
|
+
"no-compare-neg-zero": "error",
|
|
2541
|
+
"no-cond-assign": "error",
|
|
2542
|
+
"no-const-assign": "error",
|
|
2543
|
+
"no-constant-condition": ["error", { checkLoops: false }],
|
|
2544
|
+
"no-control-regex": "error",
|
|
2545
|
+
"no-debugger": "error",
|
|
2546
|
+
"no-delete-var": "error",
|
|
2547
|
+
"no-dupe-args": "error",
|
|
2548
|
+
"no-dupe-class-members": "error",
|
|
2549
|
+
"no-dupe-keys": "error",
|
|
2550
|
+
"no-duplicate-case": "error",
|
|
2551
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
2552
|
+
"no-empty-character-class": "error",
|
|
2553
|
+
"no-empty-pattern": "error",
|
|
2554
|
+
"no-empty-static-block": "error",
|
|
2555
|
+
"no-eval": "error",
|
|
2556
|
+
"no-ex-assign": "error",
|
|
2557
|
+
"no-extend-native": "error",
|
|
2558
|
+
"no-extra-bind": "error",
|
|
2559
|
+
"no-extra-boolean-cast": "error",
|
|
2560
|
+
"no-fallthrough": "error",
|
|
2561
|
+
"no-func-assign": "error",
|
|
2562
|
+
"no-global-assign": "error",
|
|
2563
|
+
"no-implied-eval": "error",
|
|
2564
|
+
"no-import-assign": "error",
|
|
2565
|
+
"no-invalid-regexp": "error",
|
|
2566
|
+
"no-irregular-whitespace": "error",
|
|
2567
|
+
"no-iterator": "error",
|
|
2568
|
+
"no-labels": ["error", {
|
|
2569
|
+
allowLoop: false,
|
|
2570
|
+
allowSwitch: false
|
|
2571
|
+
}],
|
|
2572
|
+
"no-lone-blocks": "error",
|
|
2573
|
+
"no-loss-of-precision": "error",
|
|
2574
|
+
"no-misleading-character-class": "error",
|
|
2575
|
+
"no-multi-str": "error",
|
|
2576
|
+
"no-negated-condition": "error",
|
|
2577
|
+
"no-new": "error",
|
|
2578
|
+
"no-new-func": "error",
|
|
2579
|
+
"no-new-native-nonconstructor": "error",
|
|
2580
|
+
"no-new-wrappers": "error",
|
|
2581
|
+
"no-obj-calls": "error",
|
|
2582
|
+
"no-octal": "error",
|
|
2583
|
+
"no-octal-escape": "error",
|
|
2584
|
+
"no-proto": "error",
|
|
2585
|
+
"no-prototype-builtins": "error",
|
|
2586
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
2587
|
+
"no-regex-spaces": "error",
|
|
2588
|
+
"no-self-assign": ["error", { props: true }],
|
|
2589
|
+
"no-self-compare": "error",
|
|
2590
|
+
"no-sequences": "error",
|
|
2591
|
+
"no-shadow-restricted-names": "error",
|
|
2592
|
+
"no-sparse-arrays": "error",
|
|
2593
|
+
"no-template-curly-in-string": "error",
|
|
2594
|
+
"no-this-before-super": "error",
|
|
2595
|
+
"no-throw-literal": "error",
|
|
2596
|
+
"no-undef": "error",
|
|
2597
|
+
"no-undef-init": "error",
|
|
2598
|
+
"no-unexpected-multiline": "error",
|
|
2599
|
+
"no-unmodified-loop-condition": "error",
|
|
2600
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
2601
|
+
"no-unreachable": "error",
|
|
2602
|
+
"no-unreachable-loop": "error",
|
|
2603
|
+
"no-unsafe-finally": "error",
|
|
2604
|
+
"no-unsafe-negation": "error",
|
|
2605
|
+
"no-unused-expressions": ["error", {
|
|
2606
|
+
allowShortCircuit: true,
|
|
2607
|
+
allowTaggedTemplates: true,
|
|
2608
|
+
allowTernary: true
|
|
2609
|
+
}],
|
|
2610
|
+
"no-unused-vars": ["error", {
|
|
2611
|
+
args: "none",
|
|
2612
|
+
caughtErrors: "none",
|
|
2613
|
+
ignoreRestSiblings: true,
|
|
2614
|
+
vars: "all"
|
|
2615
|
+
}],
|
|
2616
|
+
"no-use-before-define": ["error", {
|
|
2617
|
+
allowNamedExports: false,
|
|
2618
|
+
classes: false,
|
|
2619
|
+
functions: false,
|
|
2620
|
+
variables: true
|
|
2621
|
+
}],
|
|
2622
|
+
"no-useless-backreference": "error",
|
|
2623
|
+
"no-useless-call": "error",
|
|
2624
|
+
"no-useless-catch": "error",
|
|
2625
|
+
"no-useless-computed-key": "error",
|
|
2626
|
+
"no-useless-constructor": "error",
|
|
2627
|
+
"no-useless-rename": "error",
|
|
2628
|
+
"no-useless-return": "error",
|
|
2629
|
+
"no-var": "error",
|
|
2630
|
+
"no-void": "error",
|
|
2631
|
+
"no-with": "error",
|
|
2632
|
+
"object-shorthand": [
|
|
2633
|
+
"error",
|
|
2634
|
+
"always",
|
|
2635
|
+
{
|
|
2636
|
+
avoidQuotes: true,
|
|
2637
|
+
ignoreConstructors: false
|
|
2638
|
+
}
|
|
2639
|
+
],
|
|
2640
|
+
"one-var": ["error", "never"],
|
|
2641
|
+
"prefer-arrow-callback": ["error", {
|
|
2642
|
+
allowNamedFunctions: false,
|
|
2643
|
+
allowUnboundThis: true
|
|
2644
|
+
}],
|
|
2645
|
+
"prefer-const": ["error", {
|
|
2646
|
+
destructuring: "all",
|
|
2647
|
+
ignoreReadBeforeAssign: true
|
|
2648
|
+
}],
|
|
2649
|
+
"prefer-promise-reject-errors": "error",
|
|
2650
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
2651
|
+
"prefer-rest-params": "error",
|
|
2652
|
+
"prefer-spread": "error",
|
|
2653
|
+
"prefer-template": "error",
|
|
2654
|
+
"preserve-caught-error": ["error", { requireCatchParameter: true }],
|
|
2655
|
+
"symbol-description": "error",
|
|
2656
|
+
"unicode-bom": ["error", "never"],
|
|
2657
|
+
"use-isnan": ["error", {
|
|
2658
|
+
enforceForIndexOf: true,
|
|
2659
|
+
enforceForSwitchCase: true
|
|
2660
|
+
}],
|
|
2661
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
2662
|
+
"vars-on-top": "error",
|
|
2663
|
+
yoda: ["error", "never"],
|
|
2664
|
+
...options.strict ? strictRules : {},
|
|
2665
|
+
...options.overrides
|
|
2666
|
+
}
|
|
2667
|
+
}];
|
|
2668
|
+
};
|
|
2630
2669
|
const configJSX = () => [{
|
|
2631
2670
|
name: "ntnyq/jsx",
|
|
2632
2671
|
files: [GLOB_JSX_ONLY],
|
|
@@ -2691,7 +2730,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2691
2730
|
* @see {@link https://typescript-eslint.io/troubleshooting/typed-linting}
|
|
2692
2731
|
*/
|
|
2693
2732
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
2694
|
-
const { allowDefaultProject = [], extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
2733
|
+
const { allowDefaultProject = [], ecmaVersion = "latest", extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
2695
2734
|
const files = options.files ?? [
|
|
2696
2735
|
GLOB_TS,
|
|
2697
2736
|
GLOB_TSX,
|
|
@@ -2699,6 +2738,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2699
2738
|
];
|
|
2700
2739
|
function createParserConfig(enableTypeAware = false, files$1 = [], ignores = []) {
|
|
2701
2740
|
const typescriptParserOptions = {
|
|
2741
|
+
ecmaVersion,
|
|
2702
2742
|
extraFileExtensions,
|
|
2703
2743
|
sourceType: "module",
|
|
2704
2744
|
...enableTypeAware ? {
|
|
@@ -2710,7 +2750,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2710
2750
|
} : {},
|
|
2711
2751
|
...parserOptions
|
|
2712
2752
|
};
|
|
2713
|
-
|
|
2753
|
+
return {
|
|
2714
2754
|
name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
2715
2755
|
files: files$1,
|
|
2716
2756
|
ignores: [...ignores],
|
|
@@ -2719,7 +2759,6 @@ const configTypeScript = (options = {}) => {
|
|
|
2719
2759
|
parserOptions: typescriptParserOptions
|
|
2720
2760
|
}
|
|
2721
2761
|
};
|
|
2722
|
-
return parserConfig;
|
|
2723
2762
|
}
|
|
2724
2763
|
return [
|
|
2725
2764
|
{
|
|
@@ -3086,12 +3125,13 @@ const configESLintComments = (options = {}) => [{
|
|
|
3086
3125
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
3087
3126
|
const { shareable = {}, vue: enableVue = hasVue(), pinia: enablePinia = hasPinia(), test: enableTest = hasVitest(), unocss: enableUnoCSS = hasUnoCSS(), typescript: enableTypeScript = hasTypeScript(), yml: enableYML = true, sort: enableSort = true, toml: enableTOML = true, jsonc: enableJSONC = true, antfu: enableAntfu = true, ntnyq: enableNtnyq = true, depend: enableDepend = true, regexp: enableRegexp = true, unicorn: enableUnicorn = true, deMorgan: enableDeMorgan = true, prettier: enablePrettier = true, markdown: enableMarkdown = true, gitignore: enableGitIgnore = true, jsdoc: enableJsdoc = true, importX: enableImportX = true, specials: enableSpecials = true, githubAction: enableGitHubAction = true, perfectionist: enablePerfectionist = true, pnpm: enablePnpm = false, svgo: enableSVGO = false, html: enableHTML = false, astro: enableAstro = false, svelte: enableSvelte = false, eslintPlugin: enableESLintPlugin = false } = options;
|
|
3088
3127
|
const configs = [];
|
|
3089
|
-
const { extraFileExtensions = [] } = shareable;
|
|
3128
|
+
const { ecmaVersion = "latest", extraFileExtensions = [] } = shareable;
|
|
3090
3129
|
if (enableVue) extraFileExtensions.push(".vue");
|
|
3091
3130
|
if (enableAstro) extraFileExtensions.push(".astro");
|
|
3092
3131
|
if (enableSvelte) extraFileExtensions.push(".svelte");
|
|
3093
3132
|
if (enableGitIgnore) configs.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
|
|
3094
3133
|
configs.push(configIgnores(options.ignores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")), configESLintComments({ overrides: getOverrides(options, "eslintComments") }), configJavaScript({
|
|
3134
|
+
ecmaVersion,
|
|
3095
3135
|
...resolveSubOptions(options, "javascript"),
|
|
3096
3136
|
overrides: getOverrides(options, "javascript")
|
|
3097
3137
|
}));
|
|
@@ -3120,11 +3160,13 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3120
3160
|
overrides: getOverrides(options, "regexp")
|
|
3121
3161
|
}));
|
|
3122
3162
|
if (enableTypeScript) configs.push(configTypeScript({
|
|
3163
|
+
ecmaVersion,
|
|
3123
3164
|
...resolveSubOptions(options, "typescript"),
|
|
3124
3165
|
overrides: getOverrides(options, "typescript"),
|
|
3125
3166
|
extraFileExtensions
|
|
3126
3167
|
}));
|
|
3127
3168
|
if (enableVue) configs.push(configVue({
|
|
3169
|
+
ecmaVersion,
|
|
3128
3170
|
...resolveSubOptions(options, "vue"),
|
|
3129
3171
|
typescript: !!enableTypeScript,
|
|
3130
3172
|
overrides: getOverrides(options, "vue"),
|
|
@@ -3186,8 +3228,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3186
3228
|
...resolveSubOptions(options, "prettier"),
|
|
3187
3229
|
overrides: getOverrides(options, "prettier")
|
|
3188
3230
|
}) : [];
|
|
3189
|
-
|
|
3190
|
-
return composer;
|
|
3231
|
+
return new FlatConfigComposer(...configs, ...userConfigs, ...prettierConfigs);
|
|
3191
3232
|
}
|
|
3192
3233
|
|
|
3193
3234
|
//#endregion
|