@ntnyq/eslint-config 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +14039 -13965
- package/dist/index.js +273 -226
- package/package.json +18 -17
package/dist/index.js
CHANGED
|
@@ -52,10 +52,11 @@ import { default as default14 } from "@vitest/eslint-plugin";
|
|
|
52
52
|
import { default as default15 } from "eslint-plugin-unicorn";
|
|
53
53
|
import { default as default16 } from "eslint-plugin-import-x";
|
|
54
54
|
import { default as default17 } from "eslint-plugin-prettier";
|
|
55
|
-
import { default as default18 } from "eslint-plugin-
|
|
56
|
-
import { default as default19 } from "eslint-plugin-
|
|
57
|
-
import { default as default20 } from "eslint-plugin-
|
|
58
|
-
import { default as default21 } from "
|
|
55
|
+
import { default as default18 } from "eslint-plugin-no-only-tests";
|
|
56
|
+
import { default as default19 } from "eslint-plugin-github-action";
|
|
57
|
+
import { default as default20 } from "eslint-plugin-perfectionist";
|
|
58
|
+
import { default as default21 } from "eslint-plugin-unused-imports";
|
|
59
|
+
import { default as default22 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
59
60
|
|
|
60
61
|
// src/eslint/configs.ts
|
|
61
62
|
import { configs } from "typescript-eslint";
|
|
@@ -67,7 +68,7 @@ var createNodeResolver = default16.createNodeResolver;
|
|
|
67
68
|
// src/eslint/processors.ts
|
|
68
69
|
import { mergeProcessors } from "eslint-merge-processors";
|
|
69
70
|
import { processorPassThrough } from "eslint-merge-processors";
|
|
70
|
-
import { default as
|
|
71
|
+
import { default as default23 } from "eslint-processor-vue-blocks";
|
|
71
72
|
|
|
72
73
|
// src/globs.ts
|
|
73
74
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -123,7 +124,7 @@ var GLOB_LOCKFILE = [
|
|
|
123
124
|
"**/package-lock.json",
|
|
124
125
|
"**/yarn.lock",
|
|
125
126
|
"**/pnpm-lock.yaml",
|
|
126
|
-
"**/bun.
|
|
127
|
+
"**/bun.lock?(b)",
|
|
127
128
|
"**/deno.lock"
|
|
128
129
|
];
|
|
129
130
|
var GLOB_EXCLUDE = [
|
|
@@ -215,7 +216,12 @@ var extensionRules = {
|
|
|
215
216
|
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
216
217
|
"vue/key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
217
218
|
"vue/keyword-spacing": ["error", { before: true, after: true }],
|
|
218
|
-
"vue/no-restricted-syntax": [
|
|
219
|
+
"vue/no-restricted-syntax": [
|
|
220
|
+
"error",
|
|
221
|
+
"DebuggerStatement",
|
|
222
|
+
"LabeledStatement",
|
|
223
|
+
"WithStatement"
|
|
224
|
+
],
|
|
219
225
|
"vue/space-unary-ops": [
|
|
220
226
|
"error",
|
|
221
227
|
{
|
|
@@ -346,7 +352,13 @@ var unCategorizedRules = {
|
|
|
346
352
|
"vue/define-macros-order": [
|
|
347
353
|
"error",
|
|
348
354
|
{
|
|
349
|
-
order: [
|
|
355
|
+
order: [
|
|
356
|
+
"defineProps",
|
|
357
|
+
"defineEmits",
|
|
358
|
+
"defineOptions",
|
|
359
|
+
"defineSlots",
|
|
360
|
+
"defineModel"
|
|
361
|
+
],
|
|
350
362
|
defineExposeLast: true
|
|
351
363
|
}
|
|
352
364
|
],
|
|
@@ -376,7 +388,7 @@ var configVue = (options = {}) => {
|
|
|
376
388
|
if (!sfcBlocks) return processorVueSFC;
|
|
377
389
|
return mergeProcessors2([
|
|
378
390
|
processorVueSFC,
|
|
379
|
-
|
|
391
|
+
default23({
|
|
380
392
|
...sfcBlocks,
|
|
381
393
|
blocks: {
|
|
382
394
|
styles: true,
|
|
@@ -580,7 +592,14 @@ var configSort = (options = {}) => {
|
|
|
580
592
|
"jsonc/sort-keys": [
|
|
581
593
|
"error",
|
|
582
594
|
{
|
|
583
|
-
order: [
|
|
595
|
+
order: [
|
|
596
|
+
"extends",
|
|
597
|
+
"compilerOptions",
|
|
598
|
+
"references",
|
|
599
|
+
"files",
|
|
600
|
+
"include",
|
|
601
|
+
"exclude"
|
|
602
|
+
],
|
|
584
603
|
pathPattern: "^$"
|
|
585
604
|
},
|
|
586
605
|
{
|
|
@@ -941,36 +960,150 @@ var configToml = (options = {}) => [
|
|
|
941
960
|
}
|
|
942
961
|
];
|
|
943
962
|
|
|
944
|
-
// src/
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
963
|
+
// src/utils/env.ts
|
|
964
|
+
import { resolve } from "node:path";
|
|
965
|
+
import process from "node:process";
|
|
966
|
+
import { isPackageExists } from "local-pkg";
|
|
967
|
+
var hasPinia = () => isPackageExists("pinia");
|
|
968
|
+
var hasVitest = () => isPackageExists("vitest");
|
|
969
|
+
var hasTypeScript = () => isPackageExists("typescript");
|
|
970
|
+
var hasShadcnVue = () => isPackageExists("radix-vue") && isPackageExists("clsx");
|
|
971
|
+
var hasUnoCSS = () => isPackageExists("unocss") || isPackageExists("@unocss/postcss") || isPackageExists("@unocss/webpack") || isPackageExists("@unocss/nuxt");
|
|
972
|
+
var hasVue = () => isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vuepress") || isPackageExists("@slidev/cli") || isPackageExists("vue", {
|
|
973
|
+
paths: [
|
|
974
|
+
resolve(process.cwd(), "playground"),
|
|
975
|
+
resolve(process.cwd(), "docs")
|
|
976
|
+
]
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
// src/utils/toArray.ts
|
|
980
|
+
function toArray(val) {
|
|
981
|
+
val = val ?? [];
|
|
982
|
+
return Array.isArray(val) ? val : [val];
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/utils/resolveSubOptions.ts
|
|
986
|
+
function resolveSubOptions(options, key) {
|
|
987
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// src/utils/getOverrides.ts
|
|
991
|
+
function getOverrides(options, key) {
|
|
992
|
+
const subOptions = resolveSubOptions(options, key);
|
|
993
|
+
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// src/utils/combineConfigs.ts
|
|
997
|
+
async function combineConfigs(...configs2) {
|
|
998
|
+
const resolved = await Promise.all(configs2);
|
|
999
|
+
return resolved.flat();
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/utils/ensurePackages.ts
|
|
1003
|
+
import process3 from "node:process";
|
|
1004
|
+
import { fileURLToPath } from "node:url";
|
|
1005
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1006
|
+
|
|
1007
|
+
// src/utils/isInGitHooksOrRunByNanoStagedOrRunByTSX.ts
|
|
1008
|
+
import process2 from "node:process";
|
|
1009
|
+
function isInGitHooksOrRunByNanoStagedOrRunByTSX() {
|
|
1010
|
+
return !!(process2.env.GIT_PARAMS || process2.env.VSCODE_GIT_COMMAND || process2.env.npm_lifecycle_script?.startsWith("nano-staged") || process2.env.npm_lifecycle_script?.startsWith("tsx"));
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// src/utils/ensurePackages.ts
|
|
1014
|
+
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
1015
|
+
var isCwdInScope = isPackageExists2("@ntnyq/eslint-config");
|
|
1016
|
+
function isPackageInScope(name) {
|
|
1017
|
+
return isPackageExists2(name, {
|
|
1018
|
+
paths: [scopeUrl]
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
async function ensurePackages(packages) {
|
|
1022
|
+
if (process3.env.CI || !process3.stdout.isTTY || isInGitHooksOrRunByNanoStagedOrRunByTSX() || !isCwdInScope) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const nonExistingPackages = packages.filter(
|
|
1026
|
+
(pkg) => !!pkg && !isPackageInScope(pkg)
|
|
1027
|
+
);
|
|
1028
|
+
if (nonExistingPackages.length === 0) {
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
const { confirm } = await import("@clack/prompts");
|
|
1032
|
+
const confirmInstall = await confirm({
|
|
1033
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
1034
|
+
});
|
|
1035
|
+
if (confirmInstall) {
|
|
1036
|
+
try {
|
|
1037
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
1038
|
+
await installPackage(nonExistingPackages, { dev: true });
|
|
1039
|
+
} catch (err) {
|
|
1040
|
+
console.log(err);
|
|
954
1041
|
}
|
|
955
1042
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// src/utils/interopDefault.ts
|
|
1046
|
+
async function interopDefault(mod) {
|
|
1047
|
+
const resolved = await mod;
|
|
1048
|
+
return resolved.default || resolved;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/utils/mergePrettierOptions.ts
|
|
1052
|
+
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
1053
|
+
const result = {
|
|
1054
|
+
...options,
|
|
1055
|
+
...overrides,
|
|
1056
|
+
plugins: [
|
|
1057
|
+
// built-in plugins
|
|
1058
|
+
...options.plugins || [],
|
|
1059
|
+
// custom plugins
|
|
1060
|
+
...overrides.plugins || []
|
|
1061
|
+
]
|
|
1062
|
+
};
|
|
1063
|
+
return result;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// src/configs/test.ts
|
|
1067
|
+
var configTest = (options = {}) => {
|
|
1068
|
+
const {
|
|
1069
|
+
// default test files
|
|
1070
|
+
files = [...GLOB_TEST],
|
|
1071
|
+
vitest: enableVitest = hasVitest()
|
|
1072
|
+
} = options;
|
|
1073
|
+
const configs2 = [
|
|
961
1074
|
{
|
|
962
|
-
name: "ntnyq/
|
|
1075
|
+
name: "ntnyq/test/setup",
|
|
1076
|
+
plugins: {
|
|
1077
|
+
"no-only-tests": default18
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
name: "ntnyq/test/base",
|
|
1082
|
+
files,
|
|
1083
|
+
rules: {
|
|
1084
|
+
"no-unused-expressions": "off",
|
|
1085
|
+
"max-lines-per-function": "off",
|
|
1086
|
+
"no-only-tests/no-only-tests": "error",
|
|
1087
|
+
// Overrides rules
|
|
1088
|
+
...options.overrides
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
];
|
|
1092
|
+
if (enableVitest) {
|
|
1093
|
+
configs2.push({
|
|
1094
|
+
name: "ntnyq/test/vitest",
|
|
1095
|
+
files,
|
|
963
1096
|
plugins: {
|
|
964
1097
|
vitest: default14
|
|
965
1098
|
},
|
|
966
|
-
files: [...GLOB_TEST],
|
|
967
1099
|
rules: {
|
|
968
|
-
...
|
|
1100
|
+
...default14.configs.recommended.rules,
|
|
969
1101
|
// Overrides rules
|
|
970
1102
|
...options.overridesVitestRules
|
|
971
1103
|
}
|
|
972
|
-
}
|
|
973
|
-
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
return configs2;
|
|
974
1107
|
};
|
|
975
1108
|
|
|
976
1109
|
// src/configs/svgo.ts
|
|
@@ -1277,153 +1410,32 @@ var configUnoCSS = (options = {}) => [
|
|
|
1277
1410
|
|
|
1278
1411
|
// src/constants.ts
|
|
1279
1412
|
var DEFAULT_PRETTIER_OPTIONS = {
|
|
1280
|
-
// Include parentheses around a sole arrow function parameter
|
|
1281
1413
|
arrowParens: "avoid",
|
|
1282
|
-
// Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)
|
|
1283
1414
|
bracketSameLine: false,
|
|
1284
|
-
// Print spaces between brackets in object literals.
|
|
1285
1415
|
bracketSpacing: true,
|
|
1286
|
-
// Control whether Prettier formats quoted code embedded in the file
|
|
1287
1416
|
embeddedLanguageFormatting: "auto",
|
|
1288
|
-
// End of line
|
|
1289
1417
|
endOfLine: "lf",
|
|
1290
|
-
|
|
1418
|
+
experimentalOperatorPosition: "start",
|
|
1419
|
+
experimentalTernaries: false,
|
|
1291
1420
|
htmlWhitespaceSensitivity: "css",
|
|
1292
|
-
// Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier.
|
|
1293
1421
|
insertPragma: false,
|
|
1294
|
-
// Use single quotes instead of double quotes in JSX
|
|
1295
1422
|
jsxSingleQuote: true,
|
|
1296
|
-
|
|
1297
|
-
printWidth:
|
|
1298
|
-
// By default, Prettier will wrap markdown text as-is since some services use a line-break-sensitive renderer, e.g. GitHub comment and Bitbucket.
|
|
1423
|
+
objectWrap: "preserve",
|
|
1424
|
+
printWidth: 80,
|
|
1299
1425
|
proseWrap: "preserve",
|
|
1300
|
-
// Change when properties in objects are quoted
|
|
1301
1426
|
quoteProps: "as-needed",
|
|
1302
1427
|
rangeEnd: Number.POSITIVE_INFINITY,
|
|
1303
|
-
// Format only a segment of a file.
|
|
1304
1428
|
rangeStart: 0,
|
|
1305
|
-
// Specify which parser to use.
|
|
1306
|
-
// parser: undefined,
|
|
1307
|
-
// Specify the file name to use to infer which parser to use.
|
|
1308
|
-
// filepath: undefined,
|
|
1309
|
-
// Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
|
|
1310
1429
|
requirePragma: false,
|
|
1311
|
-
// Use semicolons or not
|
|
1312
1430
|
semi: false,
|
|
1313
|
-
// Enforce single attribute per line in HTML, Vue and JSX
|
|
1314
1431
|
singleAttributePerLine: true,
|
|
1315
|
-
// Use single quotes instead of double quotes
|
|
1316
1432
|
singleQuote: true,
|
|
1317
|
-
// Specify the number of spaces per indentation-level
|
|
1318
1433
|
tabWidth: 2,
|
|
1319
|
-
// Print trailing commas wherever possible when multi-line
|
|
1320
1434
|
trailingComma: "all",
|
|
1321
|
-
// Indent lines with tabs instead of spaces
|
|
1322
1435
|
useTabs: false,
|
|
1323
|
-
// Whether or not to indent the code inside <script> and <style> tags in Vue files
|
|
1324
1436
|
vueIndentScriptAndStyle: false
|
|
1325
1437
|
};
|
|
1326
1438
|
|
|
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
|
-
|
|
1427
1439
|
// src/configs/format.ts
|
|
1428
1440
|
var configFormat = (options = {}) => {
|
|
1429
1441
|
const {
|
|
@@ -1553,7 +1565,10 @@ var regexper = defineCommand({
|
|
|
1553
1565
|
removeComment: false,
|
|
1554
1566
|
message: "Update the regexper link",
|
|
1555
1567
|
fix(fixer) {
|
|
1556
|
-
return fixer.replaceTextRange(
|
|
1568
|
+
return fixer.replaceTextRange(
|
|
1569
|
+
[indexStart, indexEnd],
|
|
1570
|
+
`@regexper ${url}`
|
|
1571
|
+
);
|
|
1557
1572
|
}
|
|
1558
1573
|
});
|
|
1559
1574
|
}
|
|
@@ -1608,7 +1623,15 @@ var configImportX = (options = {}) => {
|
|
|
1608
1623
|
settings: {
|
|
1609
1624
|
"import-x/resolver-next": [
|
|
1610
1625
|
enableTypeScript && preferTypeScriptResolver ? createTypeScriptImportResolver({
|
|
1611
|
-
extensions: [
|
|
1626
|
+
extensions: [
|
|
1627
|
+
".ts",
|
|
1628
|
+
".tsx",
|
|
1629
|
+
".d.ts",
|
|
1630
|
+
".js",
|
|
1631
|
+
".jsx",
|
|
1632
|
+
".json",
|
|
1633
|
+
".node"
|
|
1634
|
+
]
|
|
1612
1635
|
}) : createNodeResolver({
|
|
1613
1636
|
extensions: [".js", ".mjs", ".ts", ".mts", ".d.ts", ".json"]
|
|
1614
1637
|
})
|
|
@@ -1627,7 +1650,10 @@ var configImportX = (options = {}) => {
|
|
|
1627
1650
|
"import-x/no-duplicates": "error",
|
|
1628
1651
|
"import-x/no-mutable-exports": "error",
|
|
1629
1652
|
"import-x/newline-after-import": "error",
|
|
1630
|
-
"import-x/consistent-type-specifier-style": [
|
|
1653
|
+
"import-x/consistent-type-specifier-style": [
|
|
1654
|
+
"error",
|
|
1655
|
+
"prefer-top-level"
|
|
1656
|
+
],
|
|
1631
1657
|
// Overrides rules
|
|
1632
1658
|
...options.overrides
|
|
1633
1659
|
}
|
|
@@ -1731,7 +1757,7 @@ import globals from "globals";
|
|
|
1731
1757
|
var configSpecials = (options = {}) => {
|
|
1732
1758
|
const {
|
|
1733
1759
|
// Enable shadcn-vue support
|
|
1734
|
-
shadcnVue: enableShadcnVue = hasShadcnVue
|
|
1760
|
+
shadcnVue: enableShadcnVue = hasShadcnVue()
|
|
1735
1761
|
} = options;
|
|
1736
1762
|
const configs2 = [
|
|
1737
1763
|
{
|
|
@@ -1778,7 +1804,7 @@ var configSpecials = (options = {}) => {
|
|
|
1778
1804
|
files: [`**/*.config*.${GLOB_SRC_EXT}`],
|
|
1779
1805
|
plugins: {
|
|
1780
1806
|
"import-x": default16,
|
|
1781
|
-
perfectionist:
|
|
1807
|
+
perfectionist: default20
|
|
1782
1808
|
},
|
|
1783
1809
|
rules: {
|
|
1784
1810
|
"no-console": "off",
|
|
@@ -1801,8 +1827,13 @@ var configSpecials = (options = {}) => {
|
|
|
1801
1827
|
const shadcnOptions = resolveSubOptions(options, "shadcnVue");
|
|
1802
1828
|
configs2.push({
|
|
1803
1829
|
name: "ntnyq/specials/shadcn-vue",
|
|
1804
|
-
files: shadcnOptions.files || [
|
|
1830
|
+
files: shadcnOptions.files || [
|
|
1831
|
+
"**/components/ui/**/*.ts",
|
|
1832
|
+
"**/components/ui/**/*.vue"
|
|
1833
|
+
],
|
|
1805
1834
|
rules: {
|
|
1835
|
+
"vue/define-emits-declaration": "off",
|
|
1836
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
1806
1837
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1807
1838
|
"@typescript-eslint/consistent-type-imports": "off",
|
|
1808
1839
|
// Overrides rules
|
|
@@ -1816,37 +1847,17 @@ var configSpecials = (options = {}) => {
|
|
|
1816
1847
|
return configs2;
|
|
1817
1848
|
};
|
|
1818
1849
|
|
|
1819
|
-
// src/configs/comments.ts
|
|
1820
|
-
var configComments = (options = {}) => [
|
|
1821
|
-
{
|
|
1822
|
-
name: "ntnyq/eslint-comments",
|
|
1823
|
-
plugins: {
|
|
1824
|
-
"@eslint-community/eslint-comments": default21
|
|
1825
|
-
},
|
|
1826
|
-
rules: {
|
|
1827
|
-
...default21.configs.recommended.rules,
|
|
1828
|
-
"@eslint-community/eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
|
|
1829
|
-
// Overrides rules
|
|
1830
|
-
...options.overrides
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
];
|
|
1834
|
-
|
|
1835
1850
|
// src/configs/markdown.ts
|
|
1836
1851
|
var configMarkdown = (options = {}) => {
|
|
1837
1852
|
const {
|
|
1838
1853
|
/**
|
|
1839
1854
|
* code block files
|
|
1840
1855
|
*/
|
|
1841
|
-
files = [
|
|
1856
|
+
files = [GLOB_MARKDOWN_CODE],
|
|
1842
1857
|
/**
|
|
1843
1858
|
* other extensions
|
|
1844
1859
|
*/
|
|
1845
|
-
extensions = []
|
|
1846
|
-
/**
|
|
1847
|
-
* disbale type aware linting
|
|
1848
|
-
*/
|
|
1849
|
-
disableTypeAwareLinting = false
|
|
1860
|
+
extensions = []
|
|
1850
1861
|
} = options;
|
|
1851
1862
|
const configs2 = [
|
|
1852
1863
|
/**
|
|
@@ -1877,17 +1888,20 @@ var configMarkdown = (options = {}) => {
|
|
|
1877
1888
|
}
|
|
1878
1889
|
},
|
|
1879
1890
|
{
|
|
1880
|
-
name: "ntnyq/markdown/disabled
|
|
1891
|
+
name: "ntnyq/markdown/disabled",
|
|
1881
1892
|
files: [
|
|
1882
1893
|
...files,
|
|
1883
|
-
//
|
|
1894
|
+
// more nested extensions to disable
|
|
1884
1895
|
...extensions.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
1885
1896
|
],
|
|
1886
1897
|
languageOptions: {
|
|
1887
1898
|
parserOptions: {
|
|
1888
1899
|
ecmaFeatures: {
|
|
1889
1900
|
impliedStrict: true
|
|
1890
|
-
}
|
|
1901
|
+
},
|
|
1902
|
+
// type-aware lint related parserOptions
|
|
1903
|
+
project: false,
|
|
1904
|
+
projectService: false
|
|
1891
1905
|
}
|
|
1892
1906
|
},
|
|
1893
1907
|
rules: {
|
|
@@ -1911,18 +1925,13 @@ var configMarkdown = (options = {}) => {
|
|
|
1911
1925
|
"@typescript-eslint/no-use-before-define": "off",
|
|
1912
1926
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
1913
1927
|
"@typescript-eslint/consistent-type-imports": "off",
|
|
1928
|
+
// disable all type-aware rules of @typescript-eslint
|
|
1929
|
+
...configs.disableTypeChecked.rules,
|
|
1914
1930
|
// Overrides rules
|
|
1915
1931
|
...options.overrides
|
|
1916
1932
|
}
|
|
1917
1933
|
}
|
|
1918
1934
|
];
|
|
1919
|
-
if (disableTypeAwareLinting) {
|
|
1920
|
-
configs2.push({
|
|
1921
|
-
...configs.disableTypeChecked,
|
|
1922
|
-
name: "ntnyq/markdown/disable/type-aware",
|
|
1923
|
-
files: [GLOB_MARKDOWN_CODE]
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
1935
|
return configs2;
|
|
1927
1936
|
};
|
|
1928
1937
|
|
|
@@ -2059,7 +2068,10 @@ var configJavaScript = (options = {}) => [
|
|
|
2059
2068
|
// disabled in favor of `perfectionist/sort-named-imports`
|
|
2060
2069
|
"sort-imports": "off",
|
|
2061
2070
|
// standard v17.0.0
|
|
2062
|
-
"accessor-pairs": [
|
|
2071
|
+
"accessor-pairs": [
|
|
2072
|
+
"error",
|
|
2073
|
+
{ setWithoutGet: true, enforceForClassMembers: true }
|
|
2074
|
+
],
|
|
2063
2075
|
camelcase: [
|
|
2064
2076
|
"error",
|
|
2065
2077
|
{
|
|
@@ -2072,7 +2084,10 @@ var configJavaScript = (options = {}) => [
|
|
|
2072
2084
|
curly: ["error", "multi-line"],
|
|
2073
2085
|
"default-case-last": "error",
|
|
2074
2086
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
2075
|
-
"new-cap": [
|
|
2087
|
+
"new-cap": [
|
|
2088
|
+
"error",
|
|
2089
|
+
{ newIsCap: true, capIsNew: false, properties: true }
|
|
2090
|
+
],
|
|
2076
2091
|
"no-array-constructor": "error",
|
|
2077
2092
|
"no-async-promise-executor": "error",
|
|
2078
2093
|
"no-caller": "error",
|
|
@@ -2276,9 +2291,12 @@ var typeAwareRules = {
|
|
|
2276
2291
|
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
2277
2292
|
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }]
|
|
2278
2293
|
};
|
|
2279
|
-
var recommendedRules = configs.recommended.reduce(
|
|
2280
|
-
|
|
2281
|
-
|
|
2294
|
+
var recommendedRules = configs.recommended.reduce(
|
|
2295
|
+
(rules, config) => {
|
|
2296
|
+
return { ...rules, ...config.rules || {} };
|
|
2297
|
+
},
|
|
2298
|
+
{}
|
|
2299
|
+
);
|
|
2282
2300
|
var configTypeScript = (options = {}) => {
|
|
2283
2301
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
2284
2302
|
const {
|
|
@@ -2388,7 +2406,10 @@ var configTypeScript = (options = {}) => {
|
|
|
2388
2406
|
],
|
|
2389
2407
|
// Extra rules
|
|
2390
2408
|
"@typescript-eslint/ban-tslint-comment": "error",
|
|
2391
|
-
"@typescript-eslint/consistent-generic-constructors": [
|
|
2409
|
+
"@typescript-eslint/consistent-generic-constructors": [
|
|
2410
|
+
"error",
|
|
2411
|
+
"constructor"
|
|
2412
|
+
],
|
|
2392
2413
|
"@typescript-eslint/ban-ts-comment": [
|
|
2393
2414
|
"error",
|
|
2394
2415
|
{
|
|
@@ -2462,7 +2483,9 @@ var configTypeScript = (options = {}) => {
|
|
|
2462
2483
|
// src/configs/eslintPlugin.ts
|
|
2463
2484
|
var configESLintPlugin = async (options = {}) => {
|
|
2464
2485
|
await ensurePackages(["eslint-plugin-eslint-plugin"]);
|
|
2465
|
-
const pluginESLintPlugin = await interopDefault(
|
|
2486
|
+
const pluginESLintPlugin = await interopDefault(
|
|
2487
|
+
import("eslint-plugin-eslint-plugin")
|
|
2488
|
+
);
|
|
2466
2489
|
return [
|
|
2467
2490
|
{
|
|
2468
2491
|
...pluginESLintPlugin.configs["flat/all"],
|
|
@@ -2482,19 +2505,20 @@ var configESLintPlugin = async (options = {}) => {
|
|
|
2482
2505
|
import { createConfig } from "eslint-plugin-github-action";
|
|
2483
2506
|
var configGitHubAction = (options = {}) => {
|
|
2484
2507
|
const {
|
|
2485
|
-
|
|
2508
|
+
files = [GLOB_GITHUB_ACTION],
|
|
2509
|
+
rules = {},
|
|
2486
2510
|
overrides: overridesRules = {},
|
|
2487
|
-
// Config options
|
|
2488
2511
|
...restOptions
|
|
2489
2512
|
} = options;
|
|
2490
2513
|
return [
|
|
2491
2514
|
createConfig({
|
|
2492
2515
|
name: "ntnyq/github-action",
|
|
2493
|
-
files
|
|
2516
|
+
files,
|
|
2494
2517
|
rules: {
|
|
2495
2518
|
"github-action/no-invalid-key": "error",
|
|
2496
2519
|
"github-action/prefer-file-extension": "error",
|
|
2497
2520
|
"github-action/require-action-name": "error",
|
|
2521
|
+
...rules,
|
|
2498
2522
|
...overridesRules
|
|
2499
2523
|
},
|
|
2500
2524
|
...restOptions
|
|
@@ -2587,7 +2611,7 @@ var configPerfectionist = (options = {}) => {
|
|
|
2587
2611
|
{
|
|
2588
2612
|
name: "ntnyq/perfectionist/common",
|
|
2589
2613
|
plugins: {
|
|
2590
|
-
perfectionist:
|
|
2614
|
+
perfectionist: default20
|
|
2591
2615
|
},
|
|
2592
2616
|
rules: {
|
|
2593
2617
|
"perfectionist/sort-imports": [
|
|
@@ -2673,7 +2697,7 @@ var configPerfectionist = (options = {}) => {
|
|
|
2673
2697
|
name: "ntnyq/perfectionist/enums",
|
|
2674
2698
|
files: [`**/enums/${GLOB_SRC}`, `**/enums.${GLOB_SRC_EXT}`],
|
|
2675
2699
|
plugins: {
|
|
2676
|
-
perfectionist:
|
|
2700
|
+
perfectionist: default20
|
|
2677
2701
|
},
|
|
2678
2702
|
rules: {
|
|
2679
2703
|
"perfectionist/sort-enums": [
|
|
@@ -2698,7 +2722,7 @@ var configPerfectionist = (options = {}) => {
|
|
|
2698
2722
|
name: "ntnyq/perfectionist/types",
|
|
2699
2723
|
files: [...GLOB_TYPES],
|
|
2700
2724
|
plugins: {
|
|
2701
|
-
perfectionist:
|
|
2725
|
+
perfectionist: default20
|
|
2702
2726
|
},
|
|
2703
2727
|
rules: {
|
|
2704
2728
|
"perfectionist/sort-heritage-clauses": [
|
|
@@ -2754,7 +2778,7 @@ var configPerfectionist = (options = {}) => {
|
|
|
2754
2778
|
name: "ntnyq/perfectionist/constants",
|
|
2755
2779
|
files: [`**/constants/${GLOB_SRC}`, `**/constants.${GLOB_SRC_EXT}`],
|
|
2756
2780
|
plugins: {
|
|
2757
|
-
perfectionist:
|
|
2781
|
+
perfectionist: default20
|
|
2758
2782
|
},
|
|
2759
2783
|
rules: {
|
|
2760
2784
|
"perfectionist/sort-maps": [
|
|
@@ -2767,7 +2791,13 @@ var configPerfectionist = (options = {}) => {
|
|
|
2767
2791
|
"error",
|
|
2768
2792
|
{
|
|
2769
2793
|
...getCommonRuleOptions(),
|
|
2770
|
-
groups: [
|
|
2794
|
+
groups: [
|
|
2795
|
+
"property",
|
|
2796
|
+
"multiline-property",
|
|
2797
|
+
"method",
|
|
2798
|
+
"multiline-method",
|
|
2799
|
+
"unknown"
|
|
2800
|
+
]
|
|
2771
2801
|
}
|
|
2772
2802
|
],
|
|
2773
2803
|
"perfectionist/sort-sets": [
|
|
@@ -2795,7 +2825,7 @@ var configUnusedImports = (options = {}) => [
|
|
|
2795
2825
|
{
|
|
2796
2826
|
name: "ntnyq/unused-imports",
|
|
2797
2827
|
plugins: {
|
|
2798
|
-
"unused-imports":
|
|
2828
|
+
"unused-imports": default21
|
|
2799
2829
|
},
|
|
2800
2830
|
rules: {
|
|
2801
2831
|
"@typescript-eslint/no-unused-vars": "off",
|
|
@@ -2819,6 +2849,25 @@ var configUnusedImports = (options = {}) => [
|
|
|
2819
2849
|
}
|
|
2820
2850
|
];
|
|
2821
2851
|
|
|
2852
|
+
// src/configs/eslintComments.ts
|
|
2853
|
+
var configESLintComments = (options = {}) => [
|
|
2854
|
+
{
|
|
2855
|
+
name: "ntnyq/eslint-comments",
|
|
2856
|
+
plugins: {
|
|
2857
|
+
"@eslint-community/eslint-comments": default22
|
|
2858
|
+
},
|
|
2859
|
+
rules: {
|
|
2860
|
+
...default22.configs.recommended.rules,
|
|
2861
|
+
"@eslint-community/eslint-comments/disable-enable-pair": [
|
|
2862
|
+
"error",
|
|
2863
|
+
{ allowWholeFile: true }
|
|
2864
|
+
],
|
|
2865
|
+
// Overrides rules
|
|
2866
|
+
...options.overrides
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
];
|
|
2870
|
+
|
|
2822
2871
|
// src/core.ts
|
|
2823
2872
|
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2824
2873
|
const {
|
|
@@ -2829,11 +2878,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2829
2878
|
/**
|
|
2830
2879
|
* Conditional by deps
|
|
2831
2880
|
*/
|
|
2832
|
-
vue: enableVue = hasVue,
|
|
2833
|
-
pinia: enablePinia = hasPinia,
|
|
2834
|
-
test: enableTest = hasVitest,
|
|
2835
|
-
unocss: enableUnoCSS = hasUnoCSS,
|
|
2836
|
-
typescript: enableTypeScript = hasTypeScript,
|
|
2881
|
+
vue: enableVue = hasVue(),
|
|
2882
|
+
pinia: enablePinia = hasPinia(),
|
|
2883
|
+
test: enableTest = hasVitest(),
|
|
2884
|
+
unocss: enableUnoCSS = hasUnoCSS(),
|
|
2885
|
+
typescript: enableTypeScript = hasTypeScript(),
|
|
2837
2886
|
/**
|
|
2838
2887
|
* Enabled by default
|
|
2839
2888
|
*/
|
|
@@ -2879,8 +2928,8 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2879
2928
|
overrides: getOverrides(options, "jsdoc"),
|
|
2880
2929
|
...resolveSubOptions(options, "jsdoc")
|
|
2881
2930
|
}),
|
|
2882
|
-
|
|
2883
|
-
overrides: getOverrides(options, "
|
|
2931
|
+
configESLintComments({
|
|
2932
|
+
overrides: getOverrides(options, "eslintComments")
|
|
2884
2933
|
}),
|
|
2885
2934
|
configJavaScript({
|
|
2886
2935
|
...resolveSubOptions(options, "javascript"),
|
|
@@ -2963,9 +3012,7 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2963
3012
|
if (enableTest) {
|
|
2964
3013
|
configs2.push(
|
|
2965
3014
|
configTest({
|
|
2966
|
-
|
|
2967
|
-
}),
|
|
2968
|
-
configVitest({
|
|
3015
|
+
...resolveSubOptions(options, "test"),
|
|
2969
3016
|
overrides: getOverrides(options, "test")
|
|
2970
3017
|
})
|
|
2971
3018
|
);
|
|
@@ -3079,8 +3126,8 @@ export {
|
|
|
3079
3126
|
combineConfigs,
|
|
3080
3127
|
configAntfu,
|
|
3081
3128
|
configCommand,
|
|
3082
|
-
configComments,
|
|
3083
3129
|
configDepend,
|
|
3130
|
+
configESLintComments,
|
|
3084
3131
|
configESLintPlugin,
|
|
3085
3132
|
configFormat,
|
|
3086
3133
|
configGitHubAction,
|
|
@@ -3107,7 +3154,6 @@ export {
|
|
|
3107
3154
|
configUnicorn,
|
|
3108
3155
|
configUnoCSS,
|
|
3109
3156
|
configUnusedImports,
|
|
3110
|
-
configVitest,
|
|
3111
3157
|
configVue,
|
|
3112
3158
|
configYml,
|
|
3113
3159
|
configs as configsTypescript,
|
|
@@ -3133,16 +3179,17 @@ export {
|
|
|
3133
3179
|
parserVue,
|
|
3134
3180
|
parserYaml,
|
|
3135
3181
|
default9 as pluginAntfu,
|
|
3136
|
-
|
|
3182
|
+
default22 as pluginComments,
|
|
3137
3183
|
pluginDepend,
|
|
3138
3184
|
default12 as pluginFormat,
|
|
3139
|
-
|
|
3185
|
+
default19 as pluginGitHubAction,
|
|
3140
3186
|
default16 as pluginImportX,
|
|
3141
3187
|
default10 as pluginJsdoc,
|
|
3142
3188
|
default11 as pluginJsonc,
|
|
3143
3189
|
default8 as pluginMarkdown,
|
|
3190
|
+
default18 as pluginNoOnlyTests,
|
|
3144
3191
|
default2 as pluginNode,
|
|
3145
|
-
|
|
3192
|
+
default20 as pluginPerfectionist,
|
|
3146
3193
|
default7 as pluginPinia,
|
|
3147
3194
|
default17 as pluginPrettier,
|
|
3148
3195
|
pluginRegexp,
|
|
@@ -3151,12 +3198,12 @@ export {
|
|
|
3151
3198
|
plugin as pluginTypeScript,
|
|
3152
3199
|
default15 as pluginUnicorn,
|
|
3153
3200
|
default13 as pluginUnoCSS,
|
|
3154
|
-
|
|
3201
|
+
default21 as pluginUnusedImports,
|
|
3155
3202
|
default14 as pluginVitest,
|
|
3156
3203
|
default3 as pluginVue,
|
|
3157
3204
|
default4 as pluginYml,
|
|
3158
3205
|
processorPassThrough,
|
|
3159
|
-
|
|
3206
|
+
default23 as processorVueBlocks,
|
|
3160
3207
|
resolveSubOptions,
|
|
3161
3208
|
toArray
|
|
3162
3209
|
};
|