@ntnyq/eslint-config 3.12.2 → 4.0.0-beta.1
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 +7 -13
- package/dist/index.d.ts +5272 -9187
- package/dist/index.js +267 -504
- package/package.json +30 -39
- package/dist/index.cjs +0 -3561
- package/dist/index.d.cts +0 -18565
package/dist/index.js
CHANGED
|
@@ -176,13 +176,7 @@ var GLOB_EXCLUDE = [
|
|
|
176
176
|
];
|
|
177
177
|
|
|
178
178
|
// src/configs/vue.ts
|
|
179
|
-
var
|
|
180
|
-
...default3.configs.base.rules,
|
|
181
|
-
...default3.configs.essential.rules,
|
|
182
|
-
...default3.configs["strongly-recommended"].rules,
|
|
183
|
-
...default3.configs.recommended.rules
|
|
184
|
-
};
|
|
185
|
-
var vue3Rules = {
|
|
179
|
+
var sharedRules = {
|
|
186
180
|
...default3.configs.base.rules,
|
|
187
181
|
...default3.configs["vue3-essential"].rules,
|
|
188
182
|
...default3.configs["vue3-strongly-recommended"].rules,
|
|
@@ -374,10 +368,9 @@ var unCategorizedRules = {
|
|
|
374
368
|
}
|
|
375
369
|
]
|
|
376
370
|
};
|
|
377
|
-
var
|
|
378
|
-
const
|
|
371
|
+
var configVue = (options = {}) => {
|
|
372
|
+
const { files = [GLOB_VUE] } = options;
|
|
379
373
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
380
|
-
const { files: FILES_VUE = [GLOB_VUE] } = options;
|
|
381
374
|
function getVueProcessor() {
|
|
382
375
|
const processorVueSFC = default3.processors[".vue"];
|
|
383
376
|
if (!sfcBlocks) return processorVueSFC;
|
|
@@ -402,10 +395,7 @@ var vue = (options = {}) => {
|
|
|
402
395
|
},
|
|
403
396
|
{
|
|
404
397
|
name: "ntnyq/vue/rules",
|
|
405
|
-
files
|
|
406
|
-
// File apply vue rules
|
|
407
|
-
...FILES_VUE
|
|
408
|
-
],
|
|
398
|
+
files,
|
|
409
399
|
languageOptions: {
|
|
410
400
|
parser: parserVue,
|
|
411
401
|
parserOptions: {
|
|
@@ -420,7 +410,7 @@ var vue = (options = {}) => {
|
|
|
420
410
|
},
|
|
421
411
|
processor: getVueProcessor(),
|
|
422
412
|
rules: {
|
|
423
|
-
...
|
|
413
|
+
...sharedRules,
|
|
424
414
|
"vue/html-self-closing": [
|
|
425
415
|
"error",
|
|
426
416
|
{
|
|
@@ -530,9 +520,9 @@ var vue = (options = {}) => {
|
|
|
530
520
|
};
|
|
531
521
|
|
|
532
522
|
// src/configs/yml.ts
|
|
533
|
-
var
|
|
523
|
+
var configYml = (options = {}) => [
|
|
534
524
|
{
|
|
535
|
-
name: "ntnyq/
|
|
525
|
+
name: "ntnyq/yml",
|
|
536
526
|
files: [GLOB_YAML],
|
|
537
527
|
languageOptions: {
|
|
538
528
|
parser: parserYaml
|
|
@@ -551,126 +541,8 @@ var yml = (options = {}) => [
|
|
|
551
541
|
}
|
|
552
542
|
];
|
|
553
543
|
|
|
554
|
-
// src/utils/env.ts
|
|
555
|
-
import { resolve } from "node:path";
|
|
556
|
-
import process from "node:process";
|
|
557
|
-
import { isPackageExists } from "local-pkg";
|
|
558
|
-
var hasPinia = isPackageExists("pinia");
|
|
559
|
-
var hasVitest = isPackageExists("vitest");
|
|
560
|
-
var hasTypeScript = isPackageExists("typescript");
|
|
561
|
-
var hasShadcnVue = isPackageExists("radix-vue") && isPackageExists("clsx");
|
|
562
|
-
var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
563
|
-
var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
|
|
564
|
-
paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")]
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
// src/utils/toArray.ts
|
|
568
|
-
function toArray(val) {
|
|
569
|
-
val = val ?? [];
|
|
570
|
-
return Array.isArray(val) ? val : [val];
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// src/utils/resolveSubOptions.ts
|
|
574
|
-
function resolveSubOptions(options, key) {
|
|
575
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/utils/getOverrides.ts
|
|
579
|
-
function getOverrides(options, key) {
|
|
580
|
-
const subOptions = resolveSubOptions(options, key);
|
|
581
|
-
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// src/utils/combineConfigs.ts
|
|
585
|
-
async function combineConfigs(...configs2) {
|
|
586
|
-
const resolved = await Promise.all(configs2);
|
|
587
|
-
return resolved.flat();
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// src/utils/ensurePackages.ts
|
|
591
|
-
import process3 from "node:process";
|
|
592
|
-
import { fileURLToPath } from "node:url";
|
|
593
|
-
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
594
|
-
|
|
595
|
-
// src/utils/isInGitHooksOrRunByNanoStagedOrRunByTSX.ts
|
|
596
|
-
import process2 from "node:process";
|
|
597
|
-
function isInGitHooksOrRunByNanoStagedOrRunByTSX() {
|
|
598
|
-
return !!(process2.env.GIT_PARAMS || process2.env.VSCODE_GIT_COMMAND || // lint staged files
|
|
599
|
-
process2.env.npm_lifecycle_script?.startsWith("nano-staged") || // run `scripts/generateType.ts`
|
|
600
|
-
process2.env.npm_lifecycle_script?.startsWith("tsx"));
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// src/utils/ensurePackages.ts
|
|
604
|
-
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
605
|
-
var isCwdInScope = isPackageExists2("@ntnyq/eslint-config");
|
|
606
|
-
function isPackageInScope(name) {
|
|
607
|
-
return isPackageExists2(name, {
|
|
608
|
-
paths: [scopeUrl]
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
async function ensurePackages(packages) {
|
|
612
|
-
if (process3.env.CI || !process3.stdout.isTTY || isInGitHooksOrRunByNanoStagedOrRunByTSX() || !isCwdInScope) {
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
616
|
-
if (nonExistingPackages.length === 0) {
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
const { confirm } = await import("@clack/prompts");
|
|
620
|
-
const confirmInstall = await confirm({
|
|
621
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
622
|
-
});
|
|
623
|
-
if (confirmInstall) {
|
|
624
|
-
try {
|
|
625
|
-
const { installPackage } = await import("@antfu/install-pkg");
|
|
626
|
-
await installPackage(nonExistingPackages, { dev: true });
|
|
627
|
-
} catch (err) {
|
|
628
|
-
console.log(err);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// src/utils/interopDefault.ts
|
|
634
|
-
async function interopDefault(mod) {
|
|
635
|
-
const resolved = await mod;
|
|
636
|
-
return resolved.default || resolved;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// src/utils/mergePrettierOptions.ts
|
|
640
|
-
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
641
|
-
const result = {
|
|
642
|
-
...options,
|
|
643
|
-
...overrides,
|
|
644
|
-
plugins: [
|
|
645
|
-
// built-in plugins
|
|
646
|
-
...options.plugins || [],
|
|
647
|
-
// custom plugins
|
|
648
|
-
...overrides.plugins || []
|
|
649
|
-
]
|
|
650
|
-
};
|
|
651
|
-
return result;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// src/configs/esX.ts
|
|
655
|
-
var esX = async (options = {}) => {
|
|
656
|
-
await ensurePackages(["eslint-plugin-es-x"]);
|
|
657
|
-
const pluginEsX = await interopDefault(import("eslint-plugin-es-x"));
|
|
658
|
-
return [
|
|
659
|
-
{
|
|
660
|
-
name: "ntnyq/es-x",
|
|
661
|
-
plugins: {
|
|
662
|
-
"es-x": pluginEsX
|
|
663
|
-
},
|
|
664
|
-
rules: {
|
|
665
|
-
// Overrides rules
|
|
666
|
-
...options.overrides
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
];
|
|
670
|
-
};
|
|
671
|
-
|
|
672
544
|
// src/configs/node.ts
|
|
673
|
-
var
|
|
545
|
+
var configNode = (options = {}) => [
|
|
674
546
|
{
|
|
675
547
|
name: "ntnyq/node",
|
|
676
548
|
plugins: {
|
|
@@ -692,7 +564,7 @@ var node = (options = {}) => [
|
|
|
692
564
|
];
|
|
693
565
|
|
|
694
566
|
// src/configs/sort.ts
|
|
695
|
-
var
|
|
567
|
+
var configSort = (options = {}) => {
|
|
696
568
|
const configs2 = [];
|
|
697
569
|
const {
|
|
698
570
|
tsconfig: enableSortTsconfig = true,
|
|
@@ -1033,7 +905,7 @@ var sort = (options = {}) => {
|
|
|
1033
905
|
};
|
|
1034
906
|
|
|
1035
907
|
// src/configs/toml.ts
|
|
1036
|
-
var
|
|
908
|
+
var configToml = (options = {}) => [
|
|
1037
909
|
{
|
|
1038
910
|
name: "ntnyq/toml",
|
|
1039
911
|
files: [GLOB_TOML],
|
|
@@ -1070,7 +942,7 @@ var toml = (options = {}) => [
|
|
|
1070
942
|
];
|
|
1071
943
|
|
|
1072
944
|
// src/configs/test.ts
|
|
1073
|
-
var
|
|
945
|
+
var configTest = (options = {}) => [
|
|
1074
946
|
{
|
|
1075
947
|
name: "ntnyq/test",
|
|
1076
948
|
files: [...GLOB_TEST],
|
|
@@ -1082,7 +954,7 @@ var test = (options = {}) => [
|
|
|
1082
954
|
}
|
|
1083
955
|
}
|
|
1084
956
|
];
|
|
1085
|
-
var
|
|
957
|
+
var configVitest = (options = {}) => {
|
|
1086
958
|
if (!default14.configs?.recommended) return [];
|
|
1087
959
|
const vitestConfigs = default14.configs;
|
|
1088
960
|
return [
|
|
@@ -1103,7 +975,7 @@ var vitest = (options = {}) => {
|
|
|
1103
975
|
|
|
1104
976
|
// src/configs/svgo.ts
|
|
1105
977
|
import { createConfig as createSVGOConfig } from "eslint-plugin-svgo";
|
|
1106
|
-
var
|
|
978
|
+
var configSVGO = (options = {}) => {
|
|
1107
979
|
const { files = [GLOB_SVG], rules: overridesRules = {} } = options;
|
|
1108
980
|
return [
|
|
1109
981
|
createSVGOConfig({
|
|
@@ -1118,7 +990,7 @@ var svgo = (options = {}) => {
|
|
|
1118
990
|
};
|
|
1119
991
|
|
|
1120
992
|
// src/configs/antfu.ts
|
|
1121
|
-
var
|
|
993
|
+
var configAntfu = (options = {}) => [
|
|
1122
994
|
{
|
|
1123
995
|
name: "ntnyq/antfu",
|
|
1124
996
|
plugins: {
|
|
@@ -1152,7 +1024,7 @@ var typescriptRules = {
|
|
|
1152
1024
|
"jsdoc/require-returns-type": "off",
|
|
1153
1025
|
"jsdoc/no-types": "error"
|
|
1154
1026
|
};
|
|
1155
|
-
var
|
|
1027
|
+
var configJsdoc = (options = {}) => [
|
|
1156
1028
|
{
|
|
1157
1029
|
name: "ntnyq/jsdoc",
|
|
1158
1030
|
plugins: {
|
|
@@ -1199,6 +1071,9 @@ var jsdoc = (options = {}) => [
|
|
|
1199
1071
|
// magic-comments
|
|
1200
1072
|
"vite-ignore",
|
|
1201
1073
|
"unocss-include",
|
|
1074
|
+
// defined perfectionist group
|
|
1075
|
+
"pg",
|
|
1076
|
+
"perfectionist-group",
|
|
1202
1077
|
// eslint-plugin-command (block comment only)
|
|
1203
1078
|
"regex101",
|
|
1204
1079
|
// non-standard, but common used
|
|
@@ -1209,172 +1084,6 @@ var jsdoc = (options = {}) => [
|
|
|
1209
1084
|
]
|
|
1210
1085
|
}
|
|
1211
1086
|
],
|
|
1212
|
-
// TODO: this after investigate
|
|
1213
|
-
// 'jsdoc/sort-tags': [
|
|
1214
|
-
// 'error',
|
|
1215
|
-
// {
|
|
1216
|
-
// tagSequence: [
|
|
1217
|
-
// {
|
|
1218
|
-
// // Module/file-level
|
|
1219
|
-
// tags: ['module', 'exports', 'file', 'fileoverview', 'overview', 'import'],
|
|
1220
|
-
// },
|
|
1221
|
-
// {
|
|
1222
|
-
// // Identifying (name, type)
|
|
1223
|
-
// tags: [
|
|
1224
|
-
// 'typedef',
|
|
1225
|
-
// 'interface',
|
|
1226
|
-
// 'record',
|
|
1227
|
-
// 'template',
|
|
1228
|
-
// 'name',
|
|
1229
|
-
// 'kind',
|
|
1230
|
-
// 'type',
|
|
1231
|
-
// 'alias',
|
|
1232
|
-
// 'external',
|
|
1233
|
-
// 'host',
|
|
1234
|
-
// 'callback',
|
|
1235
|
-
// 'func',
|
|
1236
|
-
// 'function',
|
|
1237
|
-
// 'method',
|
|
1238
|
-
// 'class',
|
|
1239
|
-
// 'constructor',
|
|
1240
|
-
// ],
|
|
1241
|
-
// },
|
|
1242
|
-
// {
|
|
1243
|
-
// // Relationships
|
|
1244
|
-
// tags: [
|
|
1245
|
-
// 'modifies',
|
|
1246
|
-
// 'mixes',
|
|
1247
|
-
// 'mixin',
|
|
1248
|
-
// 'mixinClass',
|
|
1249
|
-
// 'mixinFunction',
|
|
1250
|
-
// 'namespace',
|
|
1251
|
-
// 'borrows',
|
|
1252
|
-
// 'constructs',
|
|
1253
|
-
// 'lends',
|
|
1254
|
-
// 'implements',
|
|
1255
|
-
// 'requires',
|
|
1256
|
-
// ],
|
|
1257
|
-
// },
|
|
1258
|
-
// {
|
|
1259
|
-
// // Long descriptions
|
|
1260
|
-
// tags: ['desc', 'description', 'classdesc', 'tutorial', 'copyright', 'license'],
|
|
1261
|
-
// },
|
|
1262
|
-
// {
|
|
1263
|
-
// // Simple annotations
|
|
1264
|
-
// tags: [
|
|
1265
|
-
// 'const',
|
|
1266
|
-
// 'constant',
|
|
1267
|
-
// 'final',
|
|
1268
|
-
// 'global',
|
|
1269
|
-
// 'readonly',
|
|
1270
|
-
// 'abstract',
|
|
1271
|
-
// 'virtual',
|
|
1272
|
-
// 'var',
|
|
1273
|
-
// 'member',
|
|
1274
|
-
// 'memberof',
|
|
1275
|
-
// 'memberof!',
|
|
1276
|
-
// 'inner',
|
|
1277
|
-
// 'instance',
|
|
1278
|
-
// 'inheritdoc',
|
|
1279
|
-
// 'inheritDoc',
|
|
1280
|
-
// 'override',
|
|
1281
|
-
// 'hideconstructor',
|
|
1282
|
-
// ],
|
|
1283
|
-
// },
|
|
1284
|
-
// {
|
|
1285
|
-
// // Core function/object inf
|
|
1286
|
-
// tags: ['param', 'arg', 'argument', 'prop', 'property', 'return', 'returns'],
|
|
1287
|
-
// },
|
|
1288
|
-
// {
|
|
1289
|
-
// // Important behavior details
|
|
1290
|
-
// tags: [
|
|
1291
|
-
// 'async',
|
|
1292
|
-
// 'generator',
|
|
1293
|
-
// 'default',
|
|
1294
|
-
// 'defaultvalue',
|
|
1295
|
-
// 'enum',
|
|
1296
|
-
// 'augments',
|
|
1297
|
-
// 'extends',
|
|
1298
|
-
// 'throws',
|
|
1299
|
-
// 'exception',
|
|
1300
|
-
// 'yield',
|
|
1301
|
-
// 'yields',
|
|
1302
|
-
// 'event',
|
|
1303
|
-
// 'fires',
|
|
1304
|
-
// 'emits',
|
|
1305
|
-
// 'listens',
|
|
1306
|
-
// 'this',
|
|
1307
|
-
// ],
|
|
1308
|
-
// },
|
|
1309
|
-
// {
|
|
1310
|
-
// // Access
|
|
1311
|
-
// tags: ['static', 'private', 'protected', 'public', 'access', 'internal', 'package'],
|
|
1312
|
-
// },
|
|
1313
|
-
// {
|
|
1314
|
-
// // Other/unknown
|
|
1315
|
-
// tags: ['-other'],
|
|
1316
|
-
// },
|
|
1317
|
-
// {
|
|
1318
|
-
// // Supplementary descriptions
|
|
1319
|
-
// tags: ['see', 'example'],
|
|
1320
|
-
// },
|
|
1321
|
-
// {
|
|
1322
|
-
// // Other Closure (undocumented) metadata
|
|
1323
|
-
// tags: [
|
|
1324
|
-
// 'closurePrimitive',
|
|
1325
|
-
// 'customElement',
|
|
1326
|
-
// 'expose',
|
|
1327
|
-
// 'hidden',
|
|
1328
|
-
// 'idGenerator',
|
|
1329
|
-
// 'meaning',
|
|
1330
|
-
// 'ngInject',
|
|
1331
|
-
// 'owner',
|
|
1332
|
-
// 'wizaction',
|
|
1333
|
-
// ],
|
|
1334
|
-
// },
|
|
1335
|
-
// {
|
|
1336
|
-
// // Other Closure (documented) metadata
|
|
1337
|
-
// tags: [
|
|
1338
|
-
// 'define',
|
|
1339
|
-
// 'dict',
|
|
1340
|
-
// 'export',
|
|
1341
|
-
// 'externs',
|
|
1342
|
-
// 'implicitCast',
|
|
1343
|
-
// 'noalias',
|
|
1344
|
-
// 'nocollapse',
|
|
1345
|
-
// 'nocompile',
|
|
1346
|
-
// 'noinline',
|
|
1347
|
-
// 'nosideeffects',
|
|
1348
|
-
// 'polymer',
|
|
1349
|
-
// 'polymerBehavior',
|
|
1350
|
-
// 'preserve',
|
|
1351
|
-
// 'struct',
|
|
1352
|
-
// 'suppress',
|
|
1353
|
-
// 'unrestricted',
|
|
1354
|
-
// ],
|
|
1355
|
-
// },
|
|
1356
|
-
// {
|
|
1357
|
-
// // Metadata
|
|
1358
|
-
// tags: ['category'],
|
|
1359
|
-
// },
|
|
1360
|
-
// {
|
|
1361
|
-
// // Non-Closure metadata
|
|
1362
|
-
// tags: [
|
|
1363
|
-
// 'ignore',
|
|
1364
|
-
// 'author',
|
|
1365
|
-
// 'version',
|
|
1366
|
-
// 'variation',
|
|
1367
|
-
// 'since',
|
|
1368
|
-
// 'deprecated',
|
|
1369
|
-
// 'compatibility',
|
|
1370
|
-
// 'todo',
|
|
1371
|
-
// ],
|
|
1372
|
-
// },
|
|
1373
|
-
// ],
|
|
1374
|
-
// alphabetizeExtras: true,
|
|
1375
|
-
// linesBetween: 1,
|
|
1376
|
-
// },
|
|
1377
|
-
// ],
|
|
1378
1087
|
"jsdoc/check-access": "warn",
|
|
1379
1088
|
"jsdoc/implements-on-classes": "warn",
|
|
1380
1089
|
"jsdoc/require-param-name": "warn",
|
|
@@ -1393,7 +1102,7 @@ var jsdoc = (options = {}) => [
|
|
|
1393
1102
|
];
|
|
1394
1103
|
|
|
1395
1104
|
// src/configs/jsonc.ts
|
|
1396
|
-
var
|
|
1105
|
+
var configJsonc = (options = {}) => [
|
|
1397
1106
|
{
|
|
1398
1107
|
name: "ntnyq/jsonc",
|
|
1399
1108
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
@@ -1438,7 +1147,7 @@ var jsonc = (options = {}) => [
|
|
|
1438
1147
|
];
|
|
1439
1148
|
|
|
1440
1149
|
// src/configs/pinia.ts
|
|
1441
|
-
var
|
|
1150
|
+
var configPinia = (options = {}) => {
|
|
1442
1151
|
const { files = [GLOB_PINIA_STORE] } = options;
|
|
1443
1152
|
return [
|
|
1444
1153
|
{
|
|
@@ -1470,7 +1179,7 @@ var pinia = (options = {}) => {
|
|
|
1470
1179
|
|
|
1471
1180
|
// src/configs/ntnyq.ts
|
|
1472
1181
|
import { createConfig as createNtnyqConfig } from "eslint-plugin-ntnyq";
|
|
1473
|
-
var
|
|
1182
|
+
var configNtnyq = (options = {}) => [
|
|
1474
1183
|
{
|
|
1475
1184
|
...createNtnyqConfig({
|
|
1476
1185
|
rules: {
|
|
@@ -1484,7 +1193,7 @@ var ntnyq = (options = {}) => [
|
|
|
1484
1193
|
];
|
|
1485
1194
|
|
|
1486
1195
|
// src/configs/depend.ts
|
|
1487
|
-
var
|
|
1196
|
+
var configDepend = (options = {}) => {
|
|
1488
1197
|
const {
|
|
1489
1198
|
files = [GLOB_SRC],
|
|
1490
1199
|
// check package.json file
|
|
@@ -1525,12 +1234,12 @@ var depend = (options = {}) => {
|
|
|
1525
1234
|
};
|
|
1526
1235
|
|
|
1527
1236
|
// src/configs/regexp.ts
|
|
1528
|
-
var
|
|
1237
|
+
var configRegexp = (options = {}) => {
|
|
1529
1238
|
const recommendedConfig = pluginRegexp.configs["flat/recommended"];
|
|
1530
1239
|
const recommendedRules2 = {
|
|
1531
1240
|
...recommendedConfig.rules
|
|
1532
1241
|
};
|
|
1533
|
-
if (options.severity
|
|
1242
|
+
if (options.severity === "warn") {
|
|
1534
1243
|
for (const key in recommendedRules2) {
|
|
1535
1244
|
if (recommendedRules2[key] === "error") {
|
|
1536
1245
|
recommendedRules2[key] = "warn";
|
|
@@ -1551,7 +1260,7 @@ var regexp = (options = {}) => {
|
|
|
1551
1260
|
};
|
|
1552
1261
|
|
|
1553
1262
|
// src/configs/unocss.ts
|
|
1554
|
-
var
|
|
1263
|
+
var configUnoCSS = (options = {}) => [
|
|
1555
1264
|
{
|
|
1556
1265
|
name: "ntnyq/unocss",
|
|
1557
1266
|
plugins: {
|
|
@@ -1615,8 +1324,108 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1615
1324
|
vueIndentScriptAndStyle: false
|
|
1616
1325
|
};
|
|
1617
1326
|
|
|
1327
|
+
// src/utils/env.ts
|
|
1328
|
+
import { resolve } from "node:path";
|
|
1329
|
+
import process from "node:process";
|
|
1330
|
+
import { isPackageExists } from "local-pkg";
|
|
1331
|
+
var hasPinia = isPackageExists("pinia");
|
|
1332
|
+
var hasVitest = isPackageExists("vitest");
|
|
1333
|
+
var hasTypeScript = isPackageExists("typescript");
|
|
1334
|
+
var hasShadcnVue = isPackageExists("radix-vue") && isPackageExists("clsx");
|
|
1335
|
+
var hasUnoCSS = isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
1336
|
+
var hasVue = isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
|
|
1337
|
+
paths: [resolve(process.cwd(), "playground"), resolve(process.cwd(), "docs")]
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
// src/utils/toArray.ts
|
|
1341
|
+
function toArray(val) {
|
|
1342
|
+
val = val ?? [];
|
|
1343
|
+
return Array.isArray(val) ? val : [val];
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// src/utils/resolveSubOptions.ts
|
|
1347
|
+
function resolveSubOptions(options, key) {
|
|
1348
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
// src/utils/getOverrides.ts
|
|
1352
|
+
function getOverrides(options, key) {
|
|
1353
|
+
const subOptions = resolveSubOptions(options, key);
|
|
1354
|
+
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
// src/utils/combineConfigs.ts
|
|
1358
|
+
async function combineConfigs(...configs2) {
|
|
1359
|
+
const resolved = await Promise.all(configs2);
|
|
1360
|
+
return resolved.flat();
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// src/utils/ensurePackages.ts
|
|
1364
|
+
import process3 from "node:process";
|
|
1365
|
+
import { fileURLToPath } from "node:url";
|
|
1366
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1367
|
+
|
|
1368
|
+
// src/utils/isInGitHooksOrRunByNanoStagedOrRunByTSX.ts
|
|
1369
|
+
import process2 from "node:process";
|
|
1370
|
+
function isInGitHooksOrRunByNanoStagedOrRunByTSX() {
|
|
1371
|
+
return !!(process2.env.GIT_PARAMS || process2.env.VSCODE_GIT_COMMAND || // lint staged files
|
|
1372
|
+
process2.env.npm_lifecycle_script?.startsWith("nano-staged") || // run `scripts/generateType.ts`
|
|
1373
|
+
process2.env.npm_lifecycle_script?.startsWith("tsx"));
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/utils/ensurePackages.ts
|
|
1377
|
+
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
1378
|
+
var isCwdInScope = isPackageExists2("@ntnyq/eslint-config");
|
|
1379
|
+
function isPackageInScope(name) {
|
|
1380
|
+
return isPackageExists2(name, {
|
|
1381
|
+
paths: [scopeUrl]
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
async function ensurePackages(packages) {
|
|
1385
|
+
if (process3.env.CI || !process3.stdout.isTTY || isInGitHooksOrRunByNanoStagedOrRunByTSX() || !isCwdInScope) {
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
const nonExistingPackages = packages.filter((pkg) => !!pkg && !isPackageInScope(pkg));
|
|
1389
|
+
if (nonExistingPackages.length === 0) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
const { confirm } = await import("@clack/prompts");
|
|
1393
|
+
const confirmInstall = await confirm({
|
|
1394
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
1395
|
+
});
|
|
1396
|
+
if (confirmInstall) {
|
|
1397
|
+
try {
|
|
1398
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
1399
|
+
await installPackage(nonExistingPackages, { dev: true });
|
|
1400
|
+
} catch (err) {
|
|
1401
|
+
console.log(err);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/utils/interopDefault.ts
|
|
1407
|
+
async function interopDefault(mod) {
|
|
1408
|
+
const resolved = await mod;
|
|
1409
|
+
return resolved.default || resolved;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// src/utils/mergePrettierOptions.ts
|
|
1413
|
+
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
1414
|
+
const result = {
|
|
1415
|
+
...options,
|
|
1416
|
+
...overrides,
|
|
1417
|
+
plugins: [
|
|
1418
|
+
// built-in plugins
|
|
1419
|
+
...options.plugins || [],
|
|
1420
|
+
// custom plugins
|
|
1421
|
+
...overrides.plugins || []
|
|
1422
|
+
]
|
|
1423
|
+
};
|
|
1424
|
+
return result;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1618
1427
|
// src/configs/format.ts
|
|
1619
|
-
var
|
|
1428
|
+
var configFormat = (options = {}) => {
|
|
1620
1429
|
const {
|
|
1621
1430
|
css: enableCSS = true,
|
|
1622
1431
|
html: enableHTML = true,
|
|
@@ -1715,8 +1524,8 @@ var regexper = defineCommand({
|
|
|
1715
1524
|
// @regexper https://regexper.com/#%2F(%5Cb%7C%5Cs%7C%5E)(%40regexper)(%5Cs%5CS%2B)%3F(%5Cb%7C%5Cs%7C%24)%2F
|
|
1716
1525
|
match: /(\b|\s|^)(@regexper)(\s\S+)?(\b|\s|$)/,
|
|
1717
1526
|
action(ctx) {
|
|
1718
|
-
const literal = ctx.findNodeBelow((
|
|
1719
|
-
return
|
|
1527
|
+
const literal = ctx.findNodeBelow((node) => {
|
|
1528
|
+
return node.type === "Literal" && "regex" in node;
|
|
1720
1529
|
});
|
|
1721
1530
|
if (!literal) {
|
|
1722
1531
|
return ctx.reportError("Unable to find a regexp literal to generate");
|
|
@@ -1754,7 +1563,7 @@ var regexper = defineCommand({
|
|
|
1754
1563
|
var commands = [regexper];
|
|
1755
1564
|
|
|
1756
1565
|
// src/configs/command.ts
|
|
1757
|
-
var
|
|
1566
|
+
var configCommand = (options = {}) => [
|
|
1758
1567
|
{
|
|
1759
1568
|
...createCommandConfig({
|
|
1760
1569
|
...options,
|
|
@@ -1772,7 +1581,7 @@ var command = (options = {}) => [
|
|
|
1772
1581
|
];
|
|
1773
1582
|
|
|
1774
1583
|
// src/configs/ignores.ts
|
|
1775
|
-
var
|
|
1584
|
+
var configIgnores = (customIgnores = []) => [
|
|
1776
1585
|
{
|
|
1777
1586
|
name: "ntnyq/ignores",
|
|
1778
1587
|
ignores: [
|
|
@@ -1784,7 +1593,7 @@ var ignores = (customIgnores = []) => [
|
|
|
1784
1593
|
];
|
|
1785
1594
|
|
|
1786
1595
|
// src/configs/importX.ts
|
|
1787
|
-
var
|
|
1596
|
+
var configImportX = (options = {}) => {
|
|
1788
1597
|
const {
|
|
1789
1598
|
typescript: enableTypeScript,
|
|
1790
1599
|
// use typescript resolve if possible
|
|
@@ -1818,6 +1627,7 @@ var importX = (options = {}) => {
|
|
|
1818
1627
|
"import-x/no-duplicates": "error",
|
|
1819
1628
|
"import-x/no-mutable-exports": "error",
|
|
1820
1629
|
"import-x/newline-after-import": "error",
|
|
1630
|
+
"import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
1821
1631
|
// Overrides rules
|
|
1822
1632
|
...options.overrides
|
|
1823
1633
|
}
|
|
@@ -1836,7 +1646,7 @@ var disabledRules2 = {
|
|
|
1836
1646
|
*/
|
|
1837
1647
|
"unicorn/prefer-global-this": "off"
|
|
1838
1648
|
};
|
|
1839
|
-
var
|
|
1649
|
+
var configUnicorn = (options = {}) => [
|
|
1840
1650
|
{
|
|
1841
1651
|
name: "ntnyq/unicorn",
|
|
1842
1652
|
plugins: {
|
|
@@ -1918,7 +1728,7 @@ var unicorn = (options = {}) => [
|
|
|
1918
1728
|
|
|
1919
1729
|
// src/configs/specials.ts
|
|
1920
1730
|
import globals from "globals";
|
|
1921
|
-
var
|
|
1731
|
+
var configSpecials = (options = {}) => {
|
|
1922
1732
|
const {
|
|
1923
1733
|
// Enable shadcn-vue support
|
|
1924
1734
|
shadcnVue: enableShadcnVue = hasShadcnVue
|
|
@@ -2007,7 +1817,7 @@ var specials = (options = {}) => {
|
|
|
2007
1817
|
};
|
|
2008
1818
|
|
|
2009
1819
|
// src/configs/comments.ts
|
|
2010
|
-
var
|
|
1820
|
+
var configComments = (options = {}) => [
|
|
2011
1821
|
{
|
|
2012
1822
|
name: "ntnyq/eslint-comments",
|
|
2013
1823
|
plugins: {
|
|
@@ -2023,8 +1833,7 @@ var comments = (options = {}) => [
|
|
|
2023
1833
|
];
|
|
2024
1834
|
|
|
2025
1835
|
// src/configs/markdown.ts
|
|
2026
|
-
var
|
|
2027
|
-
if (!Array.isArray(default8.configs?.processor)) return [];
|
|
1836
|
+
var configMarkdown = (options = {}) => {
|
|
2028
1837
|
const {
|
|
2029
1838
|
/**
|
|
2030
1839
|
* code block files
|
|
@@ -2118,7 +1927,7 @@ var markdown = (options = {}) => {
|
|
|
2118
1927
|
};
|
|
2119
1928
|
|
|
2120
1929
|
// src/configs/prettier.ts
|
|
2121
|
-
var
|
|
1930
|
+
var configPrettier = (options = {}) => {
|
|
2122
1931
|
const {
|
|
2123
1932
|
disabledFiles = [GLOB_SVG, GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
2124
1933
|
// User defined disabled files
|
|
@@ -2169,7 +1978,7 @@ var prettier = (options = {}) => {
|
|
|
2169
1978
|
"vue/space-unary-ops": "off",
|
|
2170
1979
|
"vue/template-curly-spacing": "off",
|
|
2171
1980
|
...default17.configs.recommended.rules,
|
|
2172
|
-
"prettier/prettier": options.severity ||
|
|
1981
|
+
"prettier/prettier": options.severity || "warn",
|
|
2173
1982
|
// Overrides rules
|
|
2174
1983
|
...options.overrides
|
|
2175
1984
|
}
|
|
@@ -2190,29 +1999,9 @@ var prettier = (options = {}) => {
|
|
|
2190
1999
|
];
|
|
2191
2000
|
};
|
|
2192
2001
|
|
|
2193
|
-
// src/configs/stylistic.ts
|
|
2194
|
-
var stylistic = async (options = {}) => {
|
|
2195
|
-
await ensurePackages(["@stylistic/eslint-plugin"]);
|
|
2196
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
2197
|
-
return [
|
|
2198
|
-
{
|
|
2199
|
-
name: "ntnyq/stylistic",
|
|
2200
|
-
plugins: {
|
|
2201
|
-
"@stylistic": pluginStylistic
|
|
2202
|
-
},
|
|
2203
|
-
rules: {
|
|
2204
|
-
// Only rules are not conflicted with Prettier
|
|
2205
|
-
// Use stylistic config to provide type support
|
|
2206
|
-
// Overrides rules
|
|
2207
|
-
...options.overrides
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
];
|
|
2211
|
-
};
|
|
2212
|
-
|
|
2213
2002
|
// src/configs/gitignore.ts
|
|
2214
2003
|
import createGitIgnoreConfig from "eslint-config-flat-gitignore";
|
|
2215
|
-
var
|
|
2004
|
+
var configGitIgnore = (options = {}) => {
|
|
2216
2005
|
options.strict ??= false;
|
|
2217
2006
|
return [
|
|
2218
2007
|
{
|
|
@@ -2247,7 +2036,7 @@ var strictRules = {
|
|
|
2247
2036
|
}
|
|
2248
2037
|
]
|
|
2249
2038
|
};
|
|
2250
|
-
var
|
|
2039
|
+
var configJavaScript = (options = {}) => [
|
|
2251
2040
|
{
|
|
2252
2041
|
...jsConfig.configs.recommended,
|
|
2253
2042
|
name: "ntnyq/js/recommended"
|
|
@@ -2439,7 +2228,7 @@ var javascript = (options = {}) => [
|
|
|
2439
2228
|
}
|
|
2440
2229
|
}
|
|
2441
2230
|
];
|
|
2442
|
-
var
|
|
2231
|
+
var configJSX = () => [
|
|
2443
2232
|
{
|
|
2444
2233
|
name: "ntnyq/jsx",
|
|
2445
2234
|
files: ["**/*.jsx"],
|
|
@@ -2490,7 +2279,7 @@ var typeAwareRules = {
|
|
|
2490
2279
|
var recommendedRules = configs.recommended.reduce((rules, config) => {
|
|
2491
2280
|
return { ...rules, ...config.rules || {} };
|
|
2492
2281
|
}, {});
|
|
2493
|
-
var
|
|
2282
|
+
var configTypeScript = (options = {}) => {
|
|
2494
2283
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
2495
2284
|
const {
|
|
2496
2285
|
extensions = [],
|
|
@@ -2505,7 +2294,7 @@ var typescript = (options = {}) => {
|
|
|
2505
2294
|
// Enable typescript in these exts
|
|
2506
2295
|
...extensions.map((ext) => `**/*.${ext}`)
|
|
2507
2296
|
];
|
|
2508
|
-
function createParserConfig(enableTypeAware = false, files2 = [],
|
|
2297
|
+
function createParserConfig(enableTypeAware = false, files2 = [], ignores = []) {
|
|
2509
2298
|
const typescriptParserOptions = {
|
|
2510
2299
|
extraFileExtensions: extensions.map((ext) => `.${ext}`),
|
|
2511
2300
|
sourceType: "module",
|
|
@@ -2521,7 +2310,7 @@ var typescript = (options = {}) => {
|
|
|
2521
2310
|
const parserConfig = {
|
|
2522
2311
|
name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
2523
2312
|
files: files2,
|
|
2524
|
-
ignores: [...
|
|
2313
|
+
ignores: [...ignores],
|
|
2525
2314
|
languageOptions: {
|
|
2526
2315
|
parser: parserTypeScript,
|
|
2527
2316
|
parserOptions: typescriptParserOptions
|
|
@@ -2671,7 +2460,7 @@ var typescript = (options = {}) => {
|
|
|
2671
2460
|
};
|
|
2672
2461
|
|
|
2673
2462
|
// src/configs/eslintPlugin.ts
|
|
2674
|
-
var
|
|
2463
|
+
var configESLintPlugin = async (options = {}) => {
|
|
2675
2464
|
await ensurePackages(["eslint-plugin-eslint-plugin"]);
|
|
2676
2465
|
const pluginESLintPlugin = await interopDefault(import("eslint-plugin-eslint-plugin"));
|
|
2677
2466
|
return [
|
|
@@ -2691,7 +2480,7 @@ var eslintPlugin = async (options = {}) => {
|
|
|
2691
2480
|
|
|
2692
2481
|
// src/configs/githubAction.ts
|
|
2693
2482
|
import { createConfig } from "eslint-plugin-github-action";
|
|
2694
|
-
var
|
|
2483
|
+
var configGitHubAction = (options = {}) => {
|
|
2695
2484
|
const {
|
|
2696
2485
|
// Support common overrides rules
|
|
2697
2486
|
overrides: overridesRules = {},
|
|
@@ -2714,7 +2503,7 @@ var githubAction = (options = {}) => {
|
|
|
2714
2503
|
};
|
|
2715
2504
|
|
|
2716
2505
|
// src/configs/perfectionist.ts
|
|
2717
|
-
var
|
|
2506
|
+
var INTERFACE_OR_OBJECT_TYPES_GROUPS = [
|
|
2718
2507
|
"required-property",
|
|
2719
2508
|
"optional-property",
|
|
2720
2509
|
"required-method",
|
|
@@ -2727,7 +2516,7 @@ var sharedGroupsForInterfaceOrObjectTypes = [
|
|
|
2727
2516
|
"index-signature",
|
|
2728
2517
|
"multiline-index-signature"
|
|
2729
2518
|
];
|
|
2730
|
-
var
|
|
2519
|
+
var INTERSECTION_OR_UNION_TYPES_GROUPS = [
|
|
2731
2520
|
/**
|
|
2732
2521
|
* eg. 'foobar', 24, false
|
|
2733
2522
|
*/
|
|
@@ -2777,16 +2566,23 @@ var sharedGroupsForIntersectionOrUnion = [
|
|
|
2777
2566
|
*/
|
|
2778
2567
|
"nullish"
|
|
2779
2568
|
];
|
|
2780
|
-
var
|
|
2781
|
-
var defaultSortObjectTypesGroups = [...sharedGroupsForInterfaceOrObjectTypes];
|
|
2782
|
-
var defaultSortIntersectionTypesGroups = [...sharedGroupsForIntersectionOrUnion];
|
|
2783
|
-
var defaultSortUnionTypesGroups = [...sharedGroupsForIntersectionOrUnion];
|
|
2784
|
-
var perfectionist = (options = {}) => {
|
|
2569
|
+
var configPerfectionist = (options = {}) => {
|
|
2785
2570
|
const {
|
|
2786
2571
|
sortEnums: enableSortEnums = true,
|
|
2787
2572
|
sortTypes: enableSortTypes = true,
|
|
2788
|
-
sortConstants: enableSortConstants = true
|
|
2573
|
+
sortConstants: enableSortConstants = true,
|
|
2574
|
+
partitionByComment = ["@pg", "@perfectionist-group"]
|
|
2789
2575
|
} = options;
|
|
2576
|
+
function getCommonRuleOptions(options2 = {}) {
|
|
2577
|
+
const ruleOptions = {
|
|
2578
|
+
type: "alphabetical",
|
|
2579
|
+
order: "asc",
|
|
2580
|
+
ignoreCase: true,
|
|
2581
|
+
...options2.disableNewlinesBetween ? {} : { newlinesBetween: "ignore" },
|
|
2582
|
+
...options2.disableNewlinesBetween ? {} : { partitionByComment }
|
|
2583
|
+
};
|
|
2584
|
+
return ruleOptions;
|
|
2585
|
+
}
|
|
2790
2586
|
const configs2 = [
|
|
2791
2587
|
{
|
|
2792
2588
|
name: "ntnyq/perfectionist/common",
|
|
@@ -2797,6 +2593,7 @@ var perfectionist = (options = {}) => {
|
|
|
2797
2593
|
"perfectionist/sort-imports": [
|
|
2798
2594
|
"error",
|
|
2799
2595
|
{
|
|
2596
|
+
...getCommonRuleOptions(),
|
|
2800
2597
|
groups: [
|
|
2801
2598
|
// Side effect style imports (e.g. 'normalize.css')
|
|
2802
2599
|
"side-effect-style",
|
|
@@ -2833,42 +2630,37 @@ var perfectionist = (options = {}) => {
|
|
|
2833
2630
|
*/
|
|
2834
2631
|
"unknown"
|
|
2835
2632
|
],
|
|
2836
|
-
|
|
2837
|
-
type: "natural",
|
|
2838
|
-
ignoreCase: true,
|
|
2839
|
-
internalPattern: ["^~/.+", "^@/.+", "^#.+"],
|
|
2840
|
-
newlinesBetween: "ignore",
|
|
2841
|
-
partitionByComment: true
|
|
2633
|
+
internalPattern: ["^~/.+", "^@/.+", "^#.+"]
|
|
2842
2634
|
}
|
|
2843
2635
|
],
|
|
2844
2636
|
"perfectionist/sort-exports": [
|
|
2845
2637
|
"error",
|
|
2846
2638
|
{
|
|
2847
|
-
|
|
2639
|
+
...getCommonRuleOptions({
|
|
2640
|
+
disableNewlinesBetween: true
|
|
2641
|
+
}),
|
|
2848
2642
|
type: "line-length",
|
|
2849
|
-
groupKind: "values-first"
|
|
2850
|
-
partitionByComment: true
|
|
2643
|
+
groupKind: "values-first"
|
|
2851
2644
|
}
|
|
2852
2645
|
],
|
|
2853
2646
|
"perfectionist/sort-named-exports": [
|
|
2854
2647
|
"error",
|
|
2855
2648
|
{
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2649
|
+
...getCommonRuleOptions({
|
|
2650
|
+
disableNewlinesBetween: true
|
|
2651
|
+
}),
|
|
2652
|
+
ignoreAlias: false,
|
|
2653
|
+
groupKind: "values-first"
|
|
2861
2654
|
}
|
|
2862
2655
|
],
|
|
2863
2656
|
"perfectionist/sort-named-imports": [
|
|
2864
2657
|
"error",
|
|
2865
2658
|
{
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2659
|
+
...getCommonRuleOptions({
|
|
2660
|
+
disableNewlinesBetween: true
|
|
2661
|
+
}),
|
|
2869
2662
|
ignoreAlias: false,
|
|
2870
|
-
groupKind: "values-first"
|
|
2871
|
-
partitionByComment: true
|
|
2663
|
+
groupKind: "values-first"
|
|
2872
2664
|
}
|
|
2873
2665
|
],
|
|
2874
2666
|
// Overrides rules
|
|
@@ -2887,17 +2679,13 @@ var perfectionist = (options = {}) => {
|
|
|
2887
2679
|
"perfectionist/sort-enums": [
|
|
2888
2680
|
"error",
|
|
2889
2681
|
{
|
|
2890
|
-
|
|
2891
|
-
order: "asc",
|
|
2892
|
-
partitionByComment: true
|
|
2682
|
+
...getCommonRuleOptions()
|
|
2893
2683
|
}
|
|
2894
2684
|
],
|
|
2895
2685
|
"perfectionist/sort-modules": [
|
|
2896
2686
|
"error",
|
|
2897
2687
|
{
|
|
2898
|
-
|
|
2899
|
-
order: "asc",
|
|
2900
|
-
partitionByComment: true
|
|
2688
|
+
...getCommonRuleOptions()
|
|
2901
2689
|
}
|
|
2902
2690
|
],
|
|
2903
2691
|
// Overrides rules
|
|
@@ -2916,52 +2704,44 @@ var perfectionist = (options = {}) => {
|
|
|
2916
2704
|
"perfectionist/sort-heritage-clauses": [
|
|
2917
2705
|
"error",
|
|
2918
2706
|
{
|
|
2919
|
-
|
|
2920
|
-
|
|
2707
|
+
...getCommonRuleOptions({
|
|
2708
|
+
disableNewlinesBetween: true,
|
|
2709
|
+
disablePartitionByComment: true
|
|
2710
|
+
})
|
|
2921
2711
|
}
|
|
2922
2712
|
],
|
|
2923
2713
|
"perfectionist/sort-interfaces": [
|
|
2924
2714
|
"error",
|
|
2925
2715
|
{
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
partitionByComment: true,
|
|
2929
|
-
groups: defaultSortInterfacesGroups
|
|
2716
|
+
...getCommonRuleOptions(),
|
|
2717
|
+
groups: INTERFACE_OR_OBJECT_TYPES_GROUPS
|
|
2930
2718
|
}
|
|
2931
2719
|
],
|
|
2932
2720
|
"perfectionist/sort-intersection-types": [
|
|
2933
2721
|
"error",
|
|
2934
2722
|
{
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
partitionByComment: true,
|
|
2938
|
-
groups: defaultSortIntersectionTypesGroups
|
|
2723
|
+
...getCommonRuleOptions(),
|
|
2724
|
+
groups: INTERSECTION_OR_UNION_TYPES_GROUPS
|
|
2939
2725
|
}
|
|
2940
2726
|
],
|
|
2941
2727
|
"perfectionist/sort-modules": [
|
|
2942
2728
|
"error",
|
|
2943
2729
|
{
|
|
2944
|
-
|
|
2945
|
-
order: "asc",
|
|
2946
|
-
partitionByComment: true
|
|
2730
|
+
...getCommonRuleOptions()
|
|
2947
2731
|
}
|
|
2948
2732
|
],
|
|
2949
2733
|
"perfectionist/sort-object-types": [
|
|
2950
2734
|
"error",
|
|
2951
2735
|
{
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
partitionByComment: true,
|
|
2955
|
-
groups: defaultSortObjectTypesGroups
|
|
2736
|
+
...getCommonRuleOptions(),
|
|
2737
|
+
groups: INTERFACE_OR_OBJECT_TYPES_GROUPS
|
|
2956
2738
|
}
|
|
2957
2739
|
],
|
|
2958
2740
|
"perfectionist/sort-union-types": [
|
|
2959
2741
|
"error",
|
|
2960
2742
|
{
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
partitionByComment: true,
|
|
2964
|
-
groups: defaultSortUnionTypesGroups
|
|
2743
|
+
...getCommonRuleOptions(),
|
|
2744
|
+
groups: INTERSECTION_OR_UNION_TYPES_GROUPS
|
|
2965
2745
|
}
|
|
2966
2746
|
],
|
|
2967
2747
|
// Overrides rules
|
|
@@ -2980,34 +2760,26 @@ var perfectionist = (options = {}) => {
|
|
|
2980
2760
|
"perfectionist/sort-maps": [
|
|
2981
2761
|
"error",
|
|
2982
2762
|
{
|
|
2983
|
-
|
|
2984
|
-
order: "asc",
|
|
2985
|
-
partitionByComment: true
|
|
2763
|
+
...getCommonRuleOptions()
|
|
2986
2764
|
}
|
|
2987
2765
|
],
|
|
2988
2766
|
"perfectionist/sort-objects": [
|
|
2989
2767
|
"error",
|
|
2990
2768
|
{
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
partitionByComment: true,
|
|
2994
|
-
groups: ["unknown", "method", "multiline"]
|
|
2769
|
+
...getCommonRuleOptions(),
|
|
2770
|
+
groups: ["property", "multiline-property", "method", "multiline-method", "unknown"]
|
|
2995
2771
|
}
|
|
2996
2772
|
],
|
|
2997
2773
|
"perfectionist/sort-sets": [
|
|
2998
2774
|
"error",
|
|
2999
2775
|
{
|
|
3000
|
-
|
|
3001
|
-
order: "asc",
|
|
3002
|
-
partitionByComment: true
|
|
2776
|
+
...getCommonRuleOptions()
|
|
3003
2777
|
}
|
|
3004
2778
|
],
|
|
3005
2779
|
"perfectionist/sort-modules": [
|
|
3006
2780
|
"error",
|
|
3007
2781
|
{
|
|
3008
|
-
|
|
3009
|
-
order: "asc",
|
|
3010
|
-
partitionByComment: true
|
|
2782
|
+
...getCommonRuleOptions()
|
|
3011
2783
|
}
|
|
3012
2784
|
],
|
|
3013
2785
|
// Overrides rules
|
|
@@ -3019,7 +2791,7 @@ var perfectionist = (options = {}) => {
|
|
|
3019
2791
|
};
|
|
3020
2792
|
|
|
3021
2793
|
// src/configs/unusedImports.ts
|
|
3022
|
-
var
|
|
2794
|
+
var configUnusedImports = (options = {}) => [
|
|
3023
2795
|
{
|
|
3024
2796
|
name: "ntnyq/unused-imports",
|
|
3025
2797
|
plugins: {
|
|
@@ -3081,7 +2853,6 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3081
2853
|
perfectionist: enablePerfectionist = true,
|
|
3082
2854
|
// disabled by default
|
|
3083
2855
|
svgo: enableSVGO = false,
|
|
3084
|
-
stylistic: enableStylistic = false,
|
|
3085
2856
|
eslintPlugin: enableESLintPlugin = false
|
|
3086
2857
|
} = options;
|
|
3087
2858
|
const configs2 = [];
|
|
@@ -3089,36 +2860,36 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3089
2860
|
supportedExtensions.push("vue");
|
|
3090
2861
|
}
|
|
3091
2862
|
if (enableGitIgnore) {
|
|
3092
|
-
configs2.push(
|
|
2863
|
+
configs2.push(configGitIgnore(resolveSubOptions(options, "gitignore")));
|
|
3093
2864
|
}
|
|
3094
2865
|
configs2.push(
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
2866
|
+
configIgnores(options.ignores),
|
|
2867
|
+
configJSX(),
|
|
2868
|
+
configNode({
|
|
3098
2869
|
overrides: getOverrides(options, "node")
|
|
3099
2870
|
}),
|
|
3100
|
-
|
|
3101
|
-
|
|
2871
|
+
configCommand(resolveSubOptions(options, "command")),
|
|
2872
|
+
configImportX({
|
|
3102
2873
|
...resolveSubOptions(options, "importX"),
|
|
3103
2874
|
typescript: !!enableTypeScript,
|
|
3104
2875
|
overrides: getOverrides(options, "importX")
|
|
3105
2876
|
}),
|
|
3106
|
-
|
|
2877
|
+
configJsdoc({
|
|
3107
2878
|
typescript: !!enableTypeScript,
|
|
3108
2879
|
overrides: getOverrides(options, "jsdoc"),
|
|
3109
2880
|
...resolveSubOptions(options, "jsdoc")
|
|
3110
2881
|
}),
|
|
3111
|
-
|
|
2882
|
+
configComments({
|
|
3112
2883
|
overrides: getOverrides(options, "comments")
|
|
3113
2884
|
}),
|
|
3114
|
-
|
|
2885
|
+
configJavaScript({
|
|
3115
2886
|
...resolveSubOptions(options, "javascript"),
|
|
3116
2887
|
overrides: getOverrides(options, "javascript")
|
|
3117
2888
|
})
|
|
3118
2889
|
);
|
|
3119
2890
|
if (enablePerfectionist) {
|
|
3120
2891
|
configs2.push(
|
|
3121
|
-
|
|
2892
|
+
configPerfectionist({
|
|
3122
2893
|
...resolveSubOptions(options, "perfectionist"),
|
|
3123
2894
|
overrides: getOverrides(options, "perfectionist")
|
|
3124
2895
|
})
|
|
@@ -3126,14 +2897,14 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3126
2897
|
}
|
|
3127
2898
|
if (enableUnicorn) {
|
|
3128
2899
|
configs2.push(
|
|
3129
|
-
|
|
2900
|
+
configUnicorn({
|
|
3130
2901
|
overrides: getOverrides(options, "unicorn")
|
|
3131
2902
|
})
|
|
3132
2903
|
);
|
|
3133
2904
|
}
|
|
3134
2905
|
if (enablePinia) {
|
|
3135
2906
|
configs2.push(
|
|
3136
|
-
|
|
2907
|
+
configPinia({
|
|
3137
2908
|
...resolveSubOptions(options, "pinia"),
|
|
3138
2909
|
overrides: getOverrides(options, "pinia")
|
|
3139
2910
|
})
|
|
@@ -3141,7 +2912,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3141
2912
|
}
|
|
3142
2913
|
if (enableRegexp) {
|
|
3143
2914
|
configs2.push(
|
|
3144
|
-
|
|
2915
|
+
configRegexp({
|
|
3145
2916
|
...resolveSubOptions(options, "regexp"),
|
|
3146
2917
|
overrides: getOverrides(options, "regexp")
|
|
3147
2918
|
})
|
|
@@ -3149,7 +2920,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3149
2920
|
}
|
|
3150
2921
|
if (enableTypeScript) {
|
|
3151
2922
|
configs2.push(
|
|
3152
|
-
|
|
2923
|
+
configTypeScript({
|
|
3153
2924
|
...resolveSubOptions(options, "typescript"),
|
|
3154
2925
|
extensions: supportedExtensions,
|
|
3155
2926
|
overrides: getOverrides(options, "typescript")
|
|
@@ -3158,7 +2929,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3158
2929
|
}
|
|
3159
2930
|
if (enableVue) {
|
|
3160
2931
|
configs2.push(
|
|
3161
|
-
|
|
2932
|
+
configVue({
|
|
3162
2933
|
...resolveSubOptions(options, "vue"),
|
|
3163
2934
|
typescript: !!enableTypeScript,
|
|
3164
2935
|
overrides: getOverrides(options, "vue")
|
|
@@ -3167,48 +2938,49 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3167
2938
|
}
|
|
3168
2939
|
if (enableYML) {
|
|
3169
2940
|
configs2.push(
|
|
3170
|
-
|
|
2941
|
+
configYml({
|
|
3171
2942
|
overrides: getOverrides(options, "yml")
|
|
3172
2943
|
})
|
|
3173
2944
|
);
|
|
3174
2945
|
}
|
|
3175
2946
|
if (enableTOML) {
|
|
3176
2947
|
configs2.push(
|
|
3177
|
-
|
|
2948
|
+
configToml({
|
|
3178
2949
|
overrides: getOverrides(options, "toml")
|
|
3179
2950
|
})
|
|
3180
2951
|
);
|
|
3181
2952
|
}
|
|
3182
2953
|
if (enableJSONC) {
|
|
3183
2954
|
configs2.push(
|
|
3184
|
-
|
|
2955
|
+
configJsonc({
|
|
3185
2956
|
overrides: getOverrides(options, "jsonc")
|
|
3186
2957
|
})
|
|
3187
2958
|
);
|
|
3188
2959
|
}
|
|
3189
2960
|
if (enableSort) {
|
|
3190
|
-
configs2.push(
|
|
2961
|
+
configs2.push(configSort(resolveSubOptions(options, "sort")));
|
|
3191
2962
|
}
|
|
3192
2963
|
if (enableTest) {
|
|
3193
2964
|
configs2.push(
|
|
3194
|
-
|
|
2965
|
+
configTest({
|
|
3195
2966
|
overrides: getOverrides(options, "test")
|
|
3196
2967
|
}),
|
|
3197
|
-
|
|
2968
|
+
configVitest({
|
|
3198
2969
|
overrides: getOverrides(options, "test")
|
|
3199
2970
|
})
|
|
3200
2971
|
);
|
|
3201
2972
|
}
|
|
3202
2973
|
if (enableUnoCSS) {
|
|
3203
2974
|
configs2.push(
|
|
3204
|
-
|
|
2975
|
+
configUnoCSS({
|
|
3205
2976
|
overrides: getOverrides(options, "unocss")
|
|
3206
2977
|
})
|
|
3207
2978
|
);
|
|
3208
2979
|
}
|
|
3209
2980
|
if (enableMarkdown) {
|
|
3210
2981
|
configs2.push(
|
|
3211
|
-
|
|
2982
|
+
configMarkdown({
|
|
2983
|
+
...resolveSubOptions(options, "markdown"),
|
|
3212
2984
|
extensions: supportedExtensions,
|
|
3213
2985
|
overrides: getOverrides(options, "markdown")
|
|
3214
2986
|
})
|
|
@@ -3216,14 +2988,14 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3216
2988
|
}
|
|
3217
2989
|
if (enableAntfu) {
|
|
3218
2990
|
configs2.push(
|
|
3219
|
-
|
|
2991
|
+
configAntfu({
|
|
3220
2992
|
overrides: getOverrides(options, "antfu")
|
|
3221
2993
|
})
|
|
3222
2994
|
);
|
|
3223
2995
|
}
|
|
3224
2996
|
if (enableDepend) {
|
|
3225
2997
|
configs2.push(
|
|
3226
|
-
|
|
2998
|
+
configDepend({
|
|
3227
2999
|
...resolveSubOptions(options, "depend"),
|
|
3228
3000
|
overrides: getOverrides(options, "depend")
|
|
3229
3001
|
})
|
|
@@ -3231,45 +3003,38 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3231
3003
|
}
|
|
3232
3004
|
if (enableNtnyq) {
|
|
3233
3005
|
configs2.push(
|
|
3234
|
-
|
|
3006
|
+
configNtnyq({
|
|
3235
3007
|
overrides: getOverrides(options, "ntnyq")
|
|
3236
3008
|
})
|
|
3237
3009
|
);
|
|
3238
3010
|
}
|
|
3239
3011
|
if (enableGitHubAction) {
|
|
3240
3012
|
configs2.push(
|
|
3241
|
-
|
|
3013
|
+
configGitHubAction({
|
|
3242
3014
|
overrides: getOverrides(options, "githubAction")
|
|
3243
3015
|
})
|
|
3244
3016
|
);
|
|
3245
3017
|
}
|
|
3246
3018
|
if (enableESLintPlugin) {
|
|
3247
3019
|
configs2.push(
|
|
3248
|
-
|
|
3020
|
+
configESLintPlugin({
|
|
3249
3021
|
overrides: getOverrides(options, "eslintPlugin")
|
|
3250
3022
|
})
|
|
3251
3023
|
);
|
|
3252
3024
|
}
|
|
3253
|
-
if (enableStylistic) {
|
|
3254
|
-
configs2.push(
|
|
3255
|
-
stylistic({
|
|
3256
|
-
overrides: getOverrides(options, "stylistic")
|
|
3257
|
-
})
|
|
3258
|
-
);
|
|
3259
|
-
}
|
|
3260
3025
|
if (enableSVGO) {
|
|
3261
|
-
configs2.push(
|
|
3026
|
+
configs2.push(configSVGO(resolveSubOptions(options, "svgo")));
|
|
3262
3027
|
}
|
|
3263
|
-
const
|
|
3264
|
-
const
|
|
3028
|
+
const specialsConfigs = configSpecials(resolveSubOptions(options, "specials"));
|
|
3029
|
+
const prettierConfigs = enablePrettier ? configPrettier({
|
|
3265
3030
|
...resolveSubOptions(options, "prettier"),
|
|
3266
3031
|
overrides: getOverrides(options, "prettier")
|
|
3267
3032
|
}) : [];
|
|
3268
3033
|
const composer = new FlatConfigComposer(
|
|
3269
3034
|
...configs2,
|
|
3270
3035
|
...userConfigs,
|
|
3271
|
-
...
|
|
3272
|
-
...
|
|
3036
|
+
...specialsConfigs,
|
|
3037
|
+
...prettierConfigs
|
|
3273
3038
|
);
|
|
3274
3039
|
return composer;
|
|
3275
3040
|
}
|
|
@@ -3311,48 +3076,62 @@ export {
|
|
|
3311
3076
|
GLOB_TYPES,
|
|
3312
3077
|
GLOB_VUE,
|
|
3313
3078
|
GLOB_YAML,
|
|
3314
|
-
antfu,
|
|
3315
3079
|
combineConfigs,
|
|
3316
|
-
|
|
3317
|
-
|
|
3080
|
+
configAntfu,
|
|
3081
|
+
configCommand,
|
|
3082
|
+
configComments,
|
|
3083
|
+
configDepend,
|
|
3084
|
+
configESLintPlugin,
|
|
3085
|
+
configFormat,
|
|
3086
|
+
configGitHubAction,
|
|
3087
|
+
configGitIgnore,
|
|
3088
|
+
configIgnores,
|
|
3089
|
+
configImportX,
|
|
3090
|
+
configJSX,
|
|
3091
|
+
configJavaScript,
|
|
3092
|
+
configJsdoc,
|
|
3093
|
+
configJsonc,
|
|
3094
|
+
configMarkdown,
|
|
3095
|
+
configNode,
|
|
3096
|
+
configNtnyq,
|
|
3097
|
+
configPerfectionist,
|
|
3098
|
+
configPinia,
|
|
3099
|
+
configPrettier,
|
|
3100
|
+
configRegexp,
|
|
3101
|
+
configSVGO,
|
|
3102
|
+
configSort,
|
|
3103
|
+
configSpecials,
|
|
3104
|
+
configTest,
|
|
3105
|
+
configToml,
|
|
3106
|
+
configTypeScript,
|
|
3107
|
+
configUnicorn,
|
|
3108
|
+
configUnoCSS,
|
|
3109
|
+
configUnusedImports,
|
|
3110
|
+
configVitest,
|
|
3111
|
+
configVue,
|
|
3112
|
+
configYml,
|
|
3113
|
+
configs as configsTypescript,
|
|
3318
3114
|
createNodeResolver,
|
|
3319
3115
|
createTypeScriptImportResolver,
|
|
3320
3116
|
defineESLintConfig,
|
|
3321
|
-
depend,
|
|
3322
3117
|
ensurePackages,
|
|
3323
|
-
esX,
|
|
3324
|
-
eslintPlugin,
|
|
3325
|
-
format,
|
|
3326
3118
|
getOverrides,
|
|
3327
|
-
githubAction,
|
|
3328
|
-
gitignore,
|
|
3329
3119
|
hasPinia,
|
|
3330
3120
|
hasShadcnVue,
|
|
3331
3121
|
hasTypeScript,
|
|
3332
3122
|
hasUnoCSS,
|
|
3333
3123
|
hasVitest,
|
|
3334
3124
|
hasVue,
|
|
3335
|
-
ignores,
|
|
3336
|
-
importX,
|
|
3337
3125
|
interopDefault,
|
|
3338
3126
|
isInGitHooksOrRunByNanoStagedOrRunByTSX,
|
|
3339
|
-
javascript,
|
|
3340
|
-
jsdoc,
|
|
3341
|
-
jsonc,
|
|
3342
|
-
jsx,
|
|
3343
|
-
markdown,
|
|
3344
3127
|
mergePrettierOptions,
|
|
3345
3128
|
mergeProcessors,
|
|
3346
|
-
node,
|
|
3347
|
-
ntnyq,
|
|
3348
3129
|
parserJsonc,
|
|
3349
3130
|
parserPlain,
|
|
3350
3131
|
parserToml,
|
|
3351
3132
|
parserTypeScript,
|
|
3352
3133
|
parserVue,
|
|
3353
3134
|
parserYaml,
|
|
3354
|
-
perfectionist,
|
|
3355
|
-
pinia,
|
|
3356
3135
|
default9 as pluginAntfu,
|
|
3357
3136
|
default21 as pluginComments,
|
|
3358
3137
|
pluginDepend,
|
|
@@ -3375,25 +3154,9 @@ export {
|
|
|
3375
3154
|
default20 as pluginUnusedImports,
|
|
3376
3155
|
default14 as pluginVitest,
|
|
3377
3156
|
default3 as pluginVue,
|
|
3378
|
-
default4 as
|
|
3379
|
-
prettier,
|
|
3157
|
+
default4 as pluginYml,
|
|
3380
3158
|
processorPassThrough,
|
|
3381
3159
|
default22 as processorVueBlocks,
|
|
3382
|
-
regexp,
|
|
3383
3160
|
resolveSubOptions,
|
|
3384
|
-
|
|
3385
|
-
specials,
|
|
3386
|
-
stylistic,
|
|
3387
|
-
svgo,
|
|
3388
|
-
test,
|
|
3389
|
-
toArray,
|
|
3390
|
-
toml,
|
|
3391
|
-
typescript,
|
|
3392
|
-
configs as typescriptConfigs,
|
|
3393
|
-
unicorn,
|
|
3394
|
-
unocss,
|
|
3395
|
-
unusedImports,
|
|
3396
|
-
vitest,
|
|
3397
|
-
vue,
|
|
3398
|
-
yml
|
|
3161
|
+
toArray
|
|
3399
3162
|
};
|