@ntnyq/eslint-config 5.6.0 → 5.8.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 → index.d.mts} +327 -209
- package/dist/{index.js → index.mjs} +226 -193
- package/package.json +38 -38
|
@@ -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",
|
|
@@ -547,12 +547,6 @@ function getOverrides(options, key) {
|
|
|
547
547
|
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
//#endregion
|
|
551
|
-
//#region src/utils/combineConfigs.ts
|
|
552
|
-
async function combineConfigs(...configs) {
|
|
553
|
-
return (await Promise.all(configs)).flat();
|
|
554
|
-
}
|
|
555
|
-
|
|
556
550
|
//#endregion
|
|
557
551
|
//#region src/utils/isInGitHooksOrRunBySpecifyPackages.ts
|
|
558
552
|
const CHECKED_RUNNER_PACKAGES = [
|
|
@@ -567,6 +561,9 @@ function isInGitHooksOrRunBySpecifyPackages() {
|
|
|
567
561
|
|
|
568
562
|
//#endregion
|
|
569
563
|
//#region src/utils/ensurePackages.ts
|
|
564
|
+
/**
|
|
565
|
+
* @copyright {@link https://github.com/antfu/eslint-config}
|
|
566
|
+
*/
|
|
570
567
|
const isCwdInScope = isPackageExists("@ntnyq/eslint-config");
|
|
571
568
|
function isPackageInScope(name) {
|
|
572
569
|
return isPackageExists(name, { paths: [import.meta.dirname] });
|
|
@@ -1289,6 +1286,10 @@ const configAstro = async (options = {}) => {
|
|
|
1289
1286
|
|
|
1290
1287
|
//#endregion
|
|
1291
1288
|
//#region src/configs/jsdoc.ts
|
|
1289
|
+
const SPECIAL_CHAR = {
|
|
1290
|
+
emptyString: "",
|
|
1291
|
+
singleSpace: " "
|
|
1292
|
+
};
|
|
1292
1293
|
/**
|
|
1293
1294
|
* JavaScript specific rules
|
|
1294
1295
|
*/
|
|
@@ -1321,6 +1322,7 @@ const configJsdoc = (options = {}) => [{
|
|
|
1321
1322
|
name: "ntnyq/jsdoc",
|
|
1322
1323
|
plugins: { jsdoc: pluginJsdoc },
|
|
1323
1324
|
rules: {
|
|
1325
|
+
"jsdoc/prefer-import-tag": "off",
|
|
1324
1326
|
"jsdoc/require-tags": "off",
|
|
1325
1327
|
"jsdoc/tag-lines": "off",
|
|
1326
1328
|
"jsdoc/text-escaping": "off",
|
|
@@ -1332,6 +1334,7 @@ const configJsdoc = (options = {}) => [{
|
|
|
1332
1334
|
"jsdoc/require-property-name": "warn",
|
|
1333
1335
|
"jsdoc/require-returns-check": "warn",
|
|
1334
1336
|
"jsdoc/require-returns-description": "warn",
|
|
1337
|
+
"jsdoc/require-template-description": "warn",
|
|
1335
1338
|
"jsdoc/require-yields-check": "warn",
|
|
1336
1339
|
"jsdoc/require-next-description": "warn",
|
|
1337
1340
|
"jsdoc/require-next-type": "warn",
|
|
@@ -1339,6 +1342,9 @@ const configJsdoc = (options = {}) => [{
|
|
|
1339
1342
|
"jsdoc/require-throws-type": "warn",
|
|
1340
1343
|
"jsdoc/require-yields-description": "warn",
|
|
1341
1344
|
"jsdoc/require-yields-type": "warn",
|
|
1345
|
+
"jsdoc/ts-method-signature-style": "warn",
|
|
1346
|
+
"jsdoc/ts-no-empty-object-type": "warn",
|
|
1347
|
+
"jsdoc/ts-no-unnecessary-template-expression": "warn",
|
|
1342
1348
|
"jsdoc/check-alignment": "error",
|
|
1343
1349
|
"jsdoc/check-line-alignment": "error",
|
|
1344
1350
|
"jsdoc/check-param-names": "error",
|
|
@@ -1376,12 +1382,16 @@ const configJsdoc = (options = {}) => [{
|
|
|
1376
1382
|
arrayBrackets: "square",
|
|
1377
1383
|
enableFixer: true,
|
|
1378
1384
|
genericDot: false,
|
|
1379
|
-
|
|
1385
|
+
keyValuePostColonSpacing: SPECIAL_CHAR.singleSpace,
|
|
1386
|
+
keyValuePostKeySpacing: SPECIAL_CHAR.emptyString,
|
|
1387
|
+
keyValuePostOptionalSpacing: SPECIAL_CHAR.emptyString,
|
|
1388
|
+
keyValuePostVariadicSpacing: SPECIAL_CHAR.emptyString,
|
|
1389
|
+
objectFieldIndent: SPECIAL_CHAR.emptyString,
|
|
1380
1390
|
objectFieldQuote: null,
|
|
1381
1391
|
objectFieldSeparator: "comma",
|
|
1382
1392
|
stringQuotes: "single",
|
|
1383
|
-
typeBracketSpacing:
|
|
1384
|
-
unionSpacing:
|
|
1393
|
+
typeBracketSpacing: SPECIAL_CHAR.emptyString,
|
|
1394
|
+
unionSpacing: SPECIAL_CHAR.singleSpace
|
|
1385
1395
|
}],
|
|
1386
1396
|
...options.typescript ? typescriptRules : javscriptRules,
|
|
1387
1397
|
...options.overrides
|
|
@@ -1819,6 +1829,10 @@ const configFormat = async (options = {}) => {
|
|
|
1819
1829
|
//#endregion
|
|
1820
1830
|
//#region src/configs/regexp.ts
|
|
1821
1831
|
/**
|
|
1832
|
+
* @file config for plugin regexp
|
|
1833
|
+
* @see {@link https://github.com/ota-meshi/eslint-plugin-regexp}
|
|
1834
|
+
*/
|
|
1835
|
+
/**
|
|
1822
1836
|
* Config for regexp
|
|
1823
1837
|
*
|
|
1824
1838
|
* @see {@link https://github.com/ota-meshi/eslint-plugin-regexp}
|
|
@@ -2012,10 +2026,15 @@ const configCommand = (options = {}) => [{
|
|
|
2012
2026
|
* @param customIgnores - {@link ConfigIgnoresOptions}
|
|
2013
2027
|
* @returns ESLint configs
|
|
2014
2028
|
*/
|
|
2015
|
-
const configIgnores = (customIgnores = []) =>
|
|
2016
|
-
|
|
2017
|
-
ignores
|
|
2018
|
-
|
|
2029
|
+
const configIgnores = (customIgnores = []) => {
|
|
2030
|
+
let ignores = [...GLOB_EXCLUDE];
|
|
2031
|
+
if (typeof customIgnores === "function") ignores = customIgnores(ignores);
|
|
2032
|
+
else ignores.push(...customIgnores);
|
|
2033
|
+
return [{
|
|
2034
|
+
name: "ntnyq/ignores",
|
|
2035
|
+
ignores
|
|
2036
|
+
}];
|
|
2037
|
+
};
|
|
2019
2038
|
|
|
2020
2039
|
//#endregion
|
|
2021
2040
|
//#region src/configs/importX.ts
|
|
@@ -2109,12 +2128,14 @@ const configUnicorn = (options = {}) => {
|
|
|
2109
2128
|
"unicorn/no-console-spaces": "error",
|
|
2110
2129
|
"unicorn/no-for-loop": "error",
|
|
2111
2130
|
"unicorn/no-hex-escape": "error",
|
|
2131
|
+
"unicorn/no-immediate-mutation": "error",
|
|
2112
2132
|
"unicorn/no-instanceof-builtins": "error",
|
|
2113
2133
|
"unicorn/no-lonely-if": "error",
|
|
2114
2134
|
"unicorn/no-new-buffer": "error",
|
|
2115
2135
|
"unicorn/no-static-only-class": "error",
|
|
2116
2136
|
"unicorn/no-typeof-undefined": "error",
|
|
2117
2137
|
"unicorn/no-unnecessary-await": "error",
|
|
2138
|
+
"unicorn/no-useless-collection-argument": "error",
|
|
2118
2139
|
"unicorn/prefer-class-fields": "error",
|
|
2119
2140
|
"unicorn/prefer-import-meta-properties": "error",
|
|
2120
2141
|
"unicorn/prefer-includes": "error",
|
|
@@ -2127,6 +2148,7 @@ const configUnicorn = (options = {}) => {
|
|
|
2127
2148
|
"unicorn/prefer-optional-catch-binding": "error",
|
|
2128
2149
|
"unicorn/prefer-prototype-methods": "error",
|
|
2129
2150
|
"unicorn/prefer-reflect-apply": "error",
|
|
2151
|
+
"unicorn/prefer-response-static-json": "error",
|
|
2130
2152
|
"unicorn/prefer-structured-clone": "error",
|
|
2131
2153
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
2132
2154
|
"unicorn/catch-error-name": ["error", {
|
|
@@ -2475,180 +2497,184 @@ const strictRules = {
|
|
|
2475
2497
|
* @param options - {@link ConfigJavaScriptOptions}
|
|
2476
2498
|
* @returns ESLint configs
|
|
2477
2499
|
*/
|
|
2478
|
-
const configJavaScript = (options = {}) =>
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
"consistent-return": "off",
|
|
2493
|
-
"no-return-assign": "off",
|
|
2494
|
-
"no-useless-escape": "off",
|
|
2495
|
-
"require-await": "off",
|
|
2496
|
-
"sort-imports": "off",
|
|
2497
|
-
"accessor-pairs": ["error", {
|
|
2498
|
-
enforceForClassMembers: true,
|
|
2499
|
-
setWithoutGet: true
|
|
2500
|
-
}],
|
|
2501
|
-
"array-callback-return": "error",
|
|
2502
|
-
"block-scoped-var": "error",
|
|
2503
|
-
camelcase: ["error", {
|
|
2504
|
-
allow: ["^UNSAFE_"],
|
|
2505
|
-
ignoreGlobals: true,
|
|
2506
|
-
properties: "never"
|
|
2507
|
-
}],
|
|
2508
|
-
"constructor-super": "error",
|
|
2509
|
-
curly: ["error", "all"],
|
|
2510
|
-
"default-case-last": "error",
|
|
2511
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
2512
|
-
eqeqeq: ["error", "smart"],
|
|
2513
|
-
"new-cap": ["error", {
|
|
2514
|
-
capIsNew: false,
|
|
2515
|
-
newIsCap: true,
|
|
2516
|
-
properties: true
|
|
2517
|
-
}],
|
|
2518
|
-
"no-alert": "error",
|
|
2519
|
-
"no-array-constructor": "error",
|
|
2520
|
-
"no-async-promise-executor": "error",
|
|
2521
|
-
"no-caller": "error",
|
|
2522
|
-
"no-case-declarations": "error",
|
|
2523
|
-
"no-class-assign": "error",
|
|
2524
|
-
"no-compare-neg-zero": "error",
|
|
2525
|
-
"no-cond-assign": "error",
|
|
2526
|
-
"no-const-assign": "error",
|
|
2527
|
-
"no-constant-condition": ["error", { checkLoops: false }],
|
|
2528
|
-
"no-control-regex": "error",
|
|
2529
|
-
"no-debugger": "error",
|
|
2530
|
-
"no-delete-var": "error",
|
|
2531
|
-
"no-dupe-args": "error",
|
|
2532
|
-
"no-dupe-class-members": "error",
|
|
2533
|
-
"no-dupe-keys": "error",
|
|
2534
|
-
"no-duplicate-case": "error",
|
|
2535
|
-
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
2536
|
-
"no-empty-character-class": "error",
|
|
2537
|
-
"no-empty-pattern": "error",
|
|
2538
|
-
"no-empty-static-block": "error",
|
|
2539
|
-
"no-eval": "error",
|
|
2540
|
-
"no-ex-assign": "error",
|
|
2541
|
-
"no-extend-native": "error",
|
|
2542
|
-
"no-extra-bind": "error",
|
|
2543
|
-
"no-extra-boolean-cast": "error",
|
|
2544
|
-
"no-fallthrough": "error",
|
|
2545
|
-
"no-func-assign": "error",
|
|
2546
|
-
"no-global-assign": "error",
|
|
2547
|
-
"no-implied-eval": "error",
|
|
2548
|
-
"no-import-assign": "error",
|
|
2549
|
-
"no-invalid-regexp": "error",
|
|
2550
|
-
"no-irregular-whitespace": "error",
|
|
2551
|
-
"no-iterator": "error",
|
|
2552
|
-
"no-labels": ["error", {
|
|
2553
|
-
allowLoop: false,
|
|
2554
|
-
allowSwitch: false
|
|
2555
|
-
}],
|
|
2556
|
-
"no-lone-blocks": "error",
|
|
2557
|
-
"no-loss-of-precision": "error",
|
|
2558
|
-
"no-misleading-character-class": "error",
|
|
2559
|
-
"no-multi-str": "error",
|
|
2560
|
-
"no-negated-condition": "error",
|
|
2561
|
-
"no-new": "error",
|
|
2562
|
-
"no-new-func": "error",
|
|
2563
|
-
"no-new-native-nonconstructor": "error",
|
|
2564
|
-
"no-new-wrappers": "error",
|
|
2565
|
-
"no-obj-calls": "error",
|
|
2566
|
-
"no-octal": "error",
|
|
2567
|
-
"no-octal-escape": "error",
|
|
2568
|
-
"no-proto": "error",
|
|
2569
|
-
"no-prototype-builtins": "error",
|
|
2570
|
-
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
2571
|
-
"no-regex-spaces": "error",
|
|
2572
|
-
"no-self-assign": ["error", { props: true }],
|
|
2573
|
-
"no-self-compare": "error",
|
|
2574
|
-
"no-sequences": "error",
|
|
2575
|
-
"no-shadow-restricted-names": "error",
|
|
2576
|
-
"no-sparse-arrays": "error",
|
|
2577
|
-
"no-template-curly-in-string": "error",
|
|
2578
|
-
"no-this-before-super": "error",
|
|
2579
|
-
"no-throw-literal": "error",
|
|
2580
|
-
"no-undef": "error",
|
|
2581
|
-
"no-undef-init": "error",
|
|
2582
|
-
"no-unexpected-multiline": "error",
|
|
2583
|
-
"no-unmodified-loop-condition": "error",
|
|
2584
|
-
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
2585
|
-
"no-unreachable": "error",
|
|
2586
|
-
"no-unreachable-loop": "error",
|
|
2587
|
-
"no-unsafe-finally": "error",
|
|
2588
|
-
"no-unsafe-negation": "error",
|
|
2589
|
-
"no-unused-expressions": ["error", {
|
|
2590
|
-
allowShortCircuit: true,
|
|
2591
|
-
allowTaggedTemplates: true,
|
|
2592
|
-
allowTernary: true
|
|
2593
|
-
}],
|
|
2594
|
-
"no-unused-vars": ["error", {
|
|
2595
|
-
args: "none",
|
|
2596
|
-
caughtErrors: "none",
|
|
2597
|
-
ignoreRestSiblings: true,
|
|
2598
|
-
vars: "all"
|
|
2599
|
-
}],
|
|
2600
|
-
"no-use-before-define": ["error", {
|
|
2601
|
-
allowNamedExports: false,
|
|
2602
|
-
classes: false,
|
|
2603
|
-
functions: false,
|
|
2604
|
-
variables: true
|
|
2605
|
-
}],
|
|
2606
|
-
"no-useless-backreference": "error",
|
|
2607
|
-
"no-useless-call": "error",
|
|
2608
|
-
"no-useless-catch": "error",
|
|
2609
|
-
"no-useless-computed-key": "error",
|
|
2610
|
-
"no-useless-constructor": "error",
|
|
2611
|
-
"no-useless-rename": "error",
|
|
2612
|
-
"no-useless-return": "error",
|
|
2613
|
-
"no-var": "error",
|
|
2614
|
-
"no-void": "error",
|
|
2615
|
-
"no-with": "error",
|
|
2616
|
-
"object-shorthand": [
|
|
2617
|
-
"error",
|
|
2618
|
-
"always",
|
|
2619
|
-
{
|
|
2620
|
-
avoidQuotes: true,
|
|
2621
|
-
ignoreConstructors: false
|
|
2500
|
+
const configJavaScript = (options = {}) => {
|
|
2501
|
+
const { ecmaVersion = "latest" } = options;
|
|
2502
|
+
return [{
|
|
2503
|
+
...jsConfig.configs.recommended,
|
|
2504
|
+
name: "ntnyq/js/recommended"
|
|
2505
|
+
}, {
|
|
2506
|
+
name: "ntnyq/js/core",
|
|
2507
|
+
languageOptions: {
|
|
2508
|
+
ecmaVersion,
|
|
2509
|
+
sourceType: "module",
|
|
2510
|
+
globals: {
|
|
2511
|
+
...globals.browser,
|
|
2512
|
+
...globals.es2021,
|
|
2513
|
+
...globals.node
|
|
2622
2514
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2515
|
+
},
|
|
2516
|
+
rules: {
|
|
2517
|
+
"consistent-return": "off",
|
|
2518
|
+
"no-return-assign": "off",
|
|
2519
|
+
"no-useless-escape": "off",
|
|
2520
|
+
"require-await": "off",
|
|
2521
|
+
"sort-imports": "off",
|
|
2522
|
+
"accessor-pairs": ["error", {
|
|
2523
|
+
enforceForClassMembers: true,
|
|
2524
|
+
setWithoutGet: true
|
|
2525
|
+
}],
|
|
2526
|
+
"array-callback-return": "error",
|
|
2527
|
+
"block-scoped-var": "error",
|
|
2528
|
+
camelcase: ["error", {
|
|
2529
|
+
allow: ["^UNSAFE_"],
|
|
2530
|
+
ignoreGlobals: true,
|
|
2531
|
+
properties: "never"
|
|
2532
|
+
}],
|
|
2533
|
+
"constructor-super": "error",
|
|
2534
|
+
curly: ["error", "all"],
|
|
2535
|
+
"default-case-last": "error",
|
|
2536
|
+
"dot-notation": ["error", { allowKeywords: true }],
|
|
2537
|
+
eqeqeq: ["error", "smart"],
|
|
2538
|
+
"new-cap": ["error", {
|
|
2539
|
+
capIsNew: false,
|
|
2540
|
+
newIsCap: true,
|
|
2541
|
+
properties: true
|
|
2542
|
+
}],
|
|
2543
|
+
"no-alert": "error",
|
|
2544
|
+
"no-array-constructor": "error",
|
|
2545
|
+
"no-async-promise-executor": "error",
|
|
2546
|
+
"no-caller": "error",
|
|
2547
|
+
"no-case-declarations": "error",
|
|
2548
|
+
"no-class-assign": "error",
|
|
2549
|
+
"no-compare-neg-zero": "error",
|
|
2550
|
+
"no-cond-assign": "error",
|
|
2551
|
+
"no-const-assign": "error",
|
|
2552
|
+
"no-constant-condition": ["error", { checkLoops: false }],
|
|
2553
|
+
"no-control-regex": "error",
|
|
2554
|
+
"no-debugger": "error",
|
|
2555
|
+
"no-delete-var": "error",
|
|
2556
|
+
"no-dupe-args": "error",
|
|
2557
|
+
"no-dupe-class-members": "error",
|
|
2558
|
+
"no-dupe-keys": "error",
|
|
2559
|
+
"no-duplicate-case": "error",
|
|
2560
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
2561
|
+
"no-empty-character-class": "error",
|
|
2562
|
+
"no-empty-pattern": "error",
|
|
2563
|
+
"no-empty-static-block": "error",
|
|
2564
|
+
"no-eval": "error",
|
|
2565
|
+
"no-ex-assign": "error",
|
|
2566
|
+
"no-extend-native": "error",
|
|
2567
|
+
"no-extra-bind": "error",
|
|
2568
|
+
"no-extra-boolean-cast": "error",
|
|
2569
|
+
"no-fallthrough": "error",
|
|
2570
|
+
"no-func-assign": "error",
|
|
2571
|
+
"no-global-assign": "error",
|
|
2572
|
+
"no-implied-eval": "error",
|
|
2573
|
+
"no-import-assign": "error",
|
|
2574
|
+
"no-invalid-regexp": "error",
|
|
2575
|
+
"no-irregular-whitespace": "error",
|
|
2576
|
+
"no-iterator": "error",
|
|
2577
|
+
"no-labels": ["error", {
|
|
2578
|
+
allowLoop: false,
|
|
2579
|
+
allowSwitch: false
|
|
2580
|
+
}],
|
|
2581
|
+
"no-lone-blocks": "error",
|
|
2582
|
+
"no-loss-of-precision": "error",
|
|
2583
|
+
"no-misleading-character-class": "error",
|
|
2584
|
+
"no-multi-str": "error",
|
|
2585
|
+
"no-negated-condition": "error",
|
|
2586
|
+
"no-new": "error",
|
|
2587
|
+
"no-new-func": "error",
|
|
2588
|
+
"no-new-native-nonconstructor": "error",
|
|
2589
|
+
"no-new-wrappers": "error",
|
|
2590
|
+
"no-obj-calls": "error",
|
|
2591
|
+
"no-octal": "error",
|
|
2592
|
+
"no-octal-escape": "error",
|
|
2593
|
+
"no-proto": "error",
|
|
2594
|
+
"no-prototype-builtins": "error",
|
|
2595
|
+
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
2596
|
+
"no-regex-spaces": "error",
|
|
2597
|
+
"no-self-assign": ["error", { props: true }],
|
|
2598
|
+
"no-self-compare": "error",
|
|
2599
|
+
"no-sequences": "error",
|
|
2600
|
+
"no-shadow-restricted-names": "error",
|
|
2601
|
+
"no-sparse-arrays": "error",
|
|
2602
|
+
"no-template-curly-in-string": "error",
|
|
2603
|
+
"no-this-before-super": "error",
|
|
2604
|
+
"no-throw-literal": "error",
|
|
2605
|
+
"no-undef": "error",
|
|
2606
|
+
"no-undef-init": "error",
|
|
2607
|
+
"no-unexpected-multiline": "error",
|
|
2608
|
+
"no-unmodified-loop-condition": "error",
|
|
2609
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
2610
|
+
"no-unreachable": "error",
|
|
2611
|
+
"no-unreachable-loop": "error",
|
|
2612
|
+
"no-unsafe-finally": "error",
|
|
2613
|
+
"no-unsafe-negation": "error",
|
|
2614
|
+
"no-unused-expressions": ["error", {
|
|
2615
|
+
allowShortCircuit: true,
|
|
2616
|
+
allowTaggedTemplates: true,
|
|
2617
|
+
allowTernary: true
|
|
2618
|
+
}],
|
|
2619
|
+
"no-unused-vars": ["error", {
|
|
2620
|
+
args: "none",
|
|
2621
|
+
caughtErrors: "none",
|
|
2622
|
+
ignoreRestSiblings: true,
|
|
2623
|
+
vars: "all"
|
|
2624
|
+
}],
|
|
2625
|
+
"no-use-before-define": ["error", {
|
|
2626
|
+
allowNamedExports: false,
|
|
2627
|
+
classes: false,
|
|
2628
|
+
functions: false,
|
|
2629
|
+
variables: true
|
|
2630
|
+
}],
|
|
2631
|
+
"no-useless-backreference": "error",
|
|
2632
|
+
"no-useless-call": "error",
|
|
2633
|
+
"no-useless-catch": "error",
|
|
2634
|
+
"no-useless-computed-key": "error",
|
|
2635
|
+
"no-useless-constructor": "error",
|
|
2636
|
+
"no-useless-rename": "error",
|
|
2637
|
+
"no-useless-return": "error",
|
|
2638
|
+
"no-var": "error",
|
|
2639
|
+
"no-void": "error",
|
|
2640
|
+
"no-with": "error",
|
|
2641
|
+
"object-shorthand": [
|
|
2642
|
+
"error",
|
|
2643
|
+
"always",
|
|
2644
|
+
{
|
|
2645
|
+
avoidQuotes: true,
|
|
2646
|
+
ignoreConstructors: false
|
|
2647
|
+
}
|
|
2648
|
+
],
|
|
2649
|
+
"one-var": ["error", "never"],
|
|
2650
|
+
"prefer-arrow-callback": ["error", {
|
|
2651
|
+
allowNamedFunctions: false,
|
|
2652
|
+
allowUnboundThis: true
|
|
2653
|
+
}],
|
|
2654
|
+
"prefer-const": ["error", {
|
|
2655
|
+
destructuring: "all",
|
|
2656
|
+
ignoreReadBeforeAssign: true
|
|
2657
|
+
}],
|
|
2658
|
+
"prefer-promise-reject-errors": "error",
|
|
2659
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
2660
|
+
"prefer-rest-params": "error",
|
|
2661
|
+
"prefer-spread": "error",
|
|
2662
|
+
"prefer-template": "error",
|
|
2663
|
+
"preserve-caught-error": ["error", { requireCatchParameter: true }],
|
|
2664
|
+
"symbol-description": "error",
|
|
2665
|
+
"unicode-bom": ["error", "never"],
|
|
2666
|
+
"use-isnan": ["error", {
|
|
2667
|
+
enforceForIndexOf: true,
|
|
2668
|
+
enforceForSwitchCase: true
|
|
2669
|
+
}],
|
|
2670
|
+
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
2671
|
+
"vars-on-top": "error",
|
|
2672
|
+
yoda: ["error", "never"],
|
|
2673
|
+
...options.strict ? strictRules : {},
|
|
2674
|
+
...options.overrides
|
|
2675
|
+
}
|
|
2676
|
+
}];
|
|
2677
|
+
};
|
|
2652
2678
|
const configJSX = () => [{
|
|
2653
2679
|
name: "ntnyq/jsx",
|
|
2654
2680
|
files: [GLOB_JSX_ONLY],
|
|
@@ -2713,7 +2739,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2713
2739
|
* @see {@link https://typescript-eslint.io/troubleshooting/typed-linting}
|
|
2714
2740
|
*/
|
|
2715
2741
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
2716
|
-
const { allowDefaultProject = [], extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
2742
|
+
const { allowDefaultProject = [], ecmaVersion = "latest", extraFileExtensions = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`], overridesTypeAwareRules = {}, parserOptions = {} } = options;
|
|
2717
2743
|
const files = options.files ?? [
|
|
2718
2744
|
GLOB_TS,
|
|
2719
2745
|
GLOB_TSX,
|
|
@@ -2721,6 +2747,7 @@ const configTypeScript = (options = {}) => {
|
|
|
2721
2747
|
];
|
|
2722
2748
|
function createParserConfig(enableTypeAware = false, files$1 = [], ignores = []) {
|
|
2723
2749
|
const typescriptParserOptions = {
|
|
2750
|
+
ecmaVersion,
|
|
2724
2751
|
extraFileExtensions,
|
|
2725
2752
|
sourceType: "module",
|
|
2726
2753
|
...enableTypeAware ? {
|
|
@@ -3102,17 +3129,21 @@ const configESLintComments = (options = {}) => [{
|
|
|
3102
3129
|
//#endregion
|
|
3103
3130
|
//#region src/core.ts
|
|
3104
3131
|
/**
|
|
3132
|
+
* @file factory function to create ESLint config
|
|
3133
|
+
*/
|
|
3134
|
+
/**
|
|
3105
3135
|
* Config factory
|
|
3106
3136
|
*/
|
|
3107
3137
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
3108
|
-
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;
|
|
3138
|
+
const { shareable = {}, ignores: userIgnores = [], 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;
|
|
3109
3139
|
const configs = [];
|
|
3110
|
-
const { extraFileExtensions = [] } = shareable;
|
|
3140
|
+
const { ecmaVersion = "latest", extraFileExtensions = [] } = shareable;
|
|
3111
3141
|
if (enableVue) extraFileExtensions.push(".vue");
|
|
3112
3142
|
if (enableAstro) extraFileExtensions.push(".astro");
|
|
3113
3143
|
if (enableSvelte) extraFileExtensions.push(".svelte");
|
|
3114
3144
|
if (enableGitIgnore) configs.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
|
|
3115
|
-
configs.push(configIgnores(
|
|
3145
|
+
configs.push(configIgnores(userIgnores), configJSX(), configNode({ overrides: getOverrides(options, "node") }), configCommand(resolveSubOptions(options, "command")), configESLintComments({ overrides: getOverrides(options, "eslintComments") }), configJavaScript({
|
|
3146
|
+
ecmaVersion,
|
|
3116
3147
|
...resolveSubOptions(options, "javascript"),
|
|
3117
3148
|
overrides: getOverrides(options, "javascript")
|
|
3118
3149
|
}));
|
|
@@ -3141,11 +3172,13 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3141
3172
|
overrides: getOverrides(options, "regexp")
|
|
3142
3173
|
}));
|
|
3143
3174
|
if (enableTypeScript) configs.push(configTypeScript({
|
|
3175
|
+
ecmaVersion,
|
|
3144
3176
|
...resolveSubOptions(options, "typescript"),
|
|
3145
3177
|
overrides: getOverrides(options, "typescript"),
|
|
3146
3178
|
extraFileExtensions
|
|
3147
3179
|
}));
|
|
3148
3180
|
if (enableVue) configs.push(configVue({
|
|
3181
|
+
ecmaVersion,
|
|
3149
3182
|
...resolveSubOptions(options, "vue"),
|
|
3150
3183
|
typescript: !!enableTypeScript,
|
|
3151
3184
|
overrides: getOverrides(options, "vue"),
|
|
@@ -3211,4 +3244,4 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3211
3244
|
}
|
|
3212
3245
|
|
|
3213
3246
|
//#endregion
|
|
3214
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_YAML, PERFECTIONIST, PRETTIER_DEFAULT_OPTIONS,
|
|
3247
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_GITHUB_ACTION, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_SCHEMA, GLOB_JSX, GLOB_JSX_ONLY, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_NESTED, GLOB_NODE_MODULES, GLOB_PACKAGE_JSON, GLOB_PINIA_STORE, GLOB_PNPM_WORKSPACE_YAML, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TEST, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG_JSON, GLOB_TSX, GLOB_TSX_ONLY, GLOB_TYPES, GLOB_TYPE_TEST, GLOB_VUE, GLOB_YAML, PERFECTIONIST, PRETTIER_DEFAULT_OPTIONS, configAntfu, configAstro, configCommand, configDeMorgan, configDepend, configESLintComments, configESLintPlugin, configFormat, configGitHubAction, configGitIgnore, configHtml, configIgnores, configImportX, configJSX, configJavaScript, configJsdoc, configJsonc, configMarkdown, configNode, configNtnyq, configPerfectionist, configPinia, configPnpm, configPrettier, configRegexp, configSVGO, configSort, configSpecials, configSvelte, configTest, configToml, configTypeScript, configUnicorn, configUnoCSS, configUnusedImports, configVue, configYml, configsTypeScript, defineESLintConfig, ensurePackages, getOverrides, hasPinia, hasShadcnVue, hasTypeScript, hasUnoCSS, hasVitest, hasVue, interopDefault, isInGitHooksOrRunBySpecifyPackages, mergePrettierOptions, mergeProcessors, parserJsonc, parserPlain, parserToml, parserTypeScript, parserVue, parserYaml, pluginAntfu, pluginComments, pluginDeMorgan, pluginDepend, pluginGitHubAction, pluginImportX, pluginJsdoc, pluginJsonc, pluginMarkdown, pluginNoOnlyTests, pluginNode, pluginNtnyq, pluginPerfectionist, pluginPinia, pluginPrettier, pluginRegexp, pluginSvgo, pluginToml, pluginTypeScript, pluginUnicorn, pluginUnoCSS, pluginVitest, pluginVue, pluginYml, processorPassThrough, processorVueBlocks, resolveSubOptions };
|