@ntnyq/eslint-config 3.10.4 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/dist/index.cjs +338 -200
- package/dist/index.d.cts +398 -53
- package/dist/index.d.ts +398 -53
- package/dist/index.js +399 -266
- package/package.json +37 -23
package/dist/index.cjs
CHANGED
|
@@ -68,18 +68,22 @@ __export(index_exports, {
|
|
|
68
68
|
GLOB_VUE: () => GLOB_VUE,
|
|
69
69
|
GLOB_YAML: () => GLOB_YAML,
|
|
70
70
|
antfu: () => antfu,
|
|
71
|
+
combineConfigs: () => combineConfigs,
|
|
71
72
|
command: () => command,
|
|
72
73
|
comments: () => comments,
|
|
73
74
|
createNodeResolver: () => createNodeResolver,
|
|
74
75
|
createTypeScriptImportResolver: () => import_eslint_import_resolver_typescript.createTypeScriptImportResolver,
|
|
75
76
|
defineESLintConfig: () => defineESLintConfig,
|
|
76
77
|
depend: () => depend,
|
|
78
|
+
ensurePackages: () => ensurePackages,
|
|
77
79
|
esX: () => esX,
|
|
80
|
+
eslintPlugin: () => eslintPlugin,
|
|
78
81
|
format: () => format,
|
|
79
82
|
getOverrides: () => getOverrides,
|
|
80
83
|
githubAction: () => githubAction,
|
|
81
84
|
gitignore: () => gitignore,
|
|
82
85
|
hasPinia: () => hasPinia,
|
|
86
|
+
hasShadcnVue: () => hasShadcnVue,
|
|
83
87
|
hasTypeScript: () => hasTypeScript,
|
|
84
88
|
hasUnoCSS: () => hasUnoCSS,
|
|
85
89
|
hasVitest: () => hasVitest,
|
|
@@ -87,11 +91,11 @@ __export(index_exports, {
|
|
|
87
91
|
ignores: () => ignores,
|
|
88
92
|
importX: () => importX,
|
|
89
93
|
interopDefault: () => interopDefault,
|
|
94
|
+
isInGitHooksOrRunByNanoStagedOrRunByTSX: () => isInGitHooksOrRunByNanoStagedOrRunByTSX,
|
|
90
95
|
javascript: () => javascript,
|
|
91
96
|
jsdoc: () => jsdoc,
|
|
92
97
|
jsonc: () => jsonc,
|
|
93
98
|
jsx: () => jsx,
|
|
94
|
-
loadPlugin: () => loadPlugin,
|
|
95
99
|
markdown: () => markdown,
|
|
96
100
|
mergePrettierOptions: () => mergePrettierOptions,
|
|
97
101
|
mergeProcessors: () => import_eslint_merge_processors.mergeProcessors,
|
|
@@ -108,7 +112,6 @@ __export(index_exports, {
|
|
|
108
112
|
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
109
113
|
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
110
114
|
pluginDepend: () => pluginDepend,
|
|
111
|
-
pluginEsX: () => import_eslint_plugin_es_x.default,
|
|
112
115
|
pluginFormat: () => import_eslint_plugin_format.default,
|
|
113
116
|
pluginGitHubAction: () => import_eslint_plugin_github_action.default,
|
|
114
117
|
pluginImportX: () => import_eslint_plugin_import_x.default,
|
|
@@ -116,12 +119,10 @@ __export(index_exports, {
|
|
|
116
119
|
pluginJsonc: () => import_eslint_plugin_jsonc.default,
|
|
117
120
|
pluginMarkdown: () => import_markdown.default,
|
|
118
121
|
pluginNode: () => import_eslint_plugin_n.default,
|
|
119
|
-
pluginNtnyq: () => import_eslint_plugin_ntnyq.default,
|
|
120
122
|
pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
|
|
121
123
|
pluginPinia: () => import_eslint_plugin_pinia.default,
|
|
122
124
|
pluginPrettier: () => import_eslint_plugin_prettier.default,
|
|
123
125
|
pluginRegexp: () => pluginRegexp,
|
|
124
|
-
pluginStylistic: () => import_eslint_plugin3.default,
|
|
125
126
|
pluginSvgo: () => import_eslint_plugin_svgo.default,
|
|
126
127
|
pluginToml: () => import_eslint_plugin_toml.default,
|
|
127
128
|
pluginTypeScript: () => import_typescript_eslint2.plugin,
|
|
@@ -154,6 +155,10 @@ __export(index_exports, {
|
|
|
154
155
|
});
|
|
155
156
|
module.exports = __toCommonJS(index_exports);
|
|
156
157
|
|
|
158
|
+
// node_modules/.pnpm/tsup@8.3.5_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/cjs_shims.js
|
|
159
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
160
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
161
|
+
|
|
157
162
|
// src/core.ts
|
|
158
163
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
159
164
|
|
|
@@ -193,12 +198,10 @@ var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
|
|
|
193
198
|
var pluginDepend = __toESM(require("eslint-plugin-depend"), 1);
|
|
194
199
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
195
200
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
196
|
-
var import_eslint_plugin_es_x = __toESM(require("eslint-plugin-es-x"), 1);
|
|
197
201
|
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
198
202
|
var import_eslint_plugin_svgo = __toESM(require("eslint-plugin-svgo"), 1);
|
|
199
203
|
var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
|
|
200
204
|
var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
|
|
201
|
-
var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
|
|
202
205
|
var import_markdown = __toESM(require("@eslint/markdown"), 1);
|
|
203
206
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
204
207
|
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
@@ -210,7 +213,6 @@ var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
|
|
|
210
213
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
211
214
|
var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
|
|
212
215
|
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
213
|
-
var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
214
216
|
var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
|
|
215
217
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
216
218
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
@@ -327,7 +329,11 @@ var GLOB_EXCLUDE = [
|
|
|
327
329
|
"**/.wrangler",
|
|
328
330
|
"**/.changeset",
|
|
329
331
|
"**/.npmrc",
|
|
330
|
-
"**/.yarnrc"
|
|
332
|
+
"**/.yarnrc",
|
|
333
|
+
"**/.husky",
|
|
334
|
+
// tauri
|
|
335
|
+
"**/src-tauri/gen",
|
|
336
|
+
"**/src-tauri/target"
|
|
331
337
|
];
|
|
332
338
|
|
|
333
339
|
// src/configs/vue.ts
|
|
@@ -706,19 +712,123 @@ var yml = (options = {}) => [
|
|
|
706
712
|
}
|
|
707
713
|
];
|
|
708
714
|
|
|
709
|
-
// src/
|
|
710
|
-
var
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
715
|
+
// src/utils/env.ts
|
|
716
|
+
var import_node_path = require("path");
|
|
717
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
718
|
+
var import_local_pkg = require("local-pkg");
|
|
719
|
+
var hasPinia = (0, import_local_pkg.isPackageExists)("pinia");
|
|
720
|
+
var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
|
|
721
|
+
var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
|
|
722
|
+
var hasShadcnVue = (0, import_local_pkg.isPackageExists)("radix-vue") && (0, import_local_pkg.isPackageExists)("clsx");
|
|
723
|
+
var hasUnoCSS = (0, import_local_pkg.isPackageExists)("unocss") || (0, import_local_pkg.isPackageExists)("@unocss/postcss") || (0, import_local_pkg.isPackageExists)("@unocss/webpack") || (0, import_local_pkg.isPackageExists)("@unocss/nuxt");
|
|
724
|
+
var hasVue = (0, import_local_pkg.isPackageExists)("vue") || (0, import_local_pkg.isPackageExists)("nuxt") || (0, import_local_pkg.isPackageExists)("vitepress") || (0, import_local_pkg.isPackageExists)("vuepress") || (0, import_local_pkg.isPackageExists)("@slidev/cli") || (0, import_local_pkg.isPackageExists)("vue", {
|
|
725
|
+
paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground"), (0, import_node_path.resolve)(import_node_process.default.cwd(), "docs")]
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// src/utils/toArray.ts
|
|
729
|
+
function toArray(val) {
|
|
730
|
+
val = val ?? [];
|
|
731
|
+
return Array.isArray(val) ? val : [val];
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/utils/resolveSubOptions.ts
|
|
735
|
+
function resolveSubOptions(options, key) {
|
|
736
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/utils/getOverrides.ts
|
|
740
|
+
function getOverrides(options, key) {
|
|
741
|
+
const subOptions = resolveSubOptions(options, key);
|
|
742
|
+
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// src/utils/combineConfigs.ts
|
|
746
|
+
async function combineConfigs(...configs2) {
|
|
747
|
+
const resolved = await Promise.all(configs2);
|
|
748
|
+
return resolved.flat();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/utils/ensurePackages.ts
|
|
752
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
753
|
+
var import_node_url = require("url");
|
|
754
|
+
var import_local_pkg2 = require("local-pkg");
|
|
755
|
+
|
|
756
|
+
// src/utils/isInGitHooksOrRunByNanoStagedOrRunByTSX.ts
|
|
757
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
758
|
+
function isInGitHooksOrRunByNanoStagedOrRunByTSX() {
|
|
759
|
+
return !!(import_node_process2.default.env.GIT_PARAMS || import_node_process2.default.env.VSCODE_GIT_COMMAND || // lint staged files
|
|
760
|
+
import_node_process2.default.env.npm_lifecycle_script?.startsWith("nano-staged") || // run `scripts/generateType.ts`
|
|
761
|
+
import_node_process2.default.env.npm_lifecycle_script?.startsWith("tsx"));
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// src/utils/ensurePackages.ts
|
|
765
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
766
|
+
var isCwdInScope = (0, import_local_pkg2.isPackageExists)("@ntnyq/eslint-config");
|
|
767
|
+
function isPackageInScope(name) {
|
|
768
|
+
return (0, import_local_pkg2.isPackageExists)(name, {
|
|
769
|
+
paths: [scopeUrl]
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
async function ensurePackages(packages) {
|
|
773
|
+
if (import_node_process3.default.env.CI || !import_node_process3.default.stdout.isTTY || isInGitHooksOrRunByNanoStagedOrRunByTSX() || !isCwdInScope) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const nonExistingPackages = packages.filter((pkg) => !!pkg && isPackageInScope(pkg));
|
|
777
|
+
if (nonExistingPackages.length === 0) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const { confirm } = await import("@clack/prompts");
|
|
781
|
+
const confirmInstall = await confirm({
|
|
782
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
783
|
+
});
|
|
784
|
+
if (confirmInstall) {
|
|
785
|
+
try {
|
|
786
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
787
|
+
await installPackage(nonExistingPackages, { dev: true });
|
|
788
|
+
} catch (err) {
|
|
789
|
+
console.log(err);
|
|
719
790
|
}
|
|
720
791
|
}
|
|
721
|
-
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// src/utils/interopDefault.ts
|
|
795
|
+
async function interopDefault(mod) {
|
|
796
|
+
const resolved = await mod;
|
|
797
|
+
return resolved.default || resolved;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// src/utils/mergePrettierOptions.ts
|
|
801
|
+
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
802
|
+
const result = {
|
|
803
|
+
...options,
|
|
804
|
+
...overrides,
|
|
805
|
+
plugins: [
|
|
806
|
+
// built-in plugins
|
|
807
|
+
...options.plugins || [],
|
|
808
|
+
// custom plugins
|
|
809
|
+
...overrides.plugins || []
|
|
810
|
+
]
|
|
811
|
+
};
|
|
812
|
+
return result;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/configs/esX.ts
|
|
816
|
+
var esX = async (options = {}) => {
|
|
817
|
+
await ensurePackages(["eslint-plugin-es-x"]);
|
|
818
|
+
const pluginEsX = await interopDefault(import("eslint-plugin-es-x"));
|
|
819
|
+
return [
|
|
820
|
+
{
|
|
821
|
+
name: "ntnyq/es-x",
|
|
822
|
+
plugins: {
|
|
823
|
+
"es-x": pluginEsX
|
|
824
|
+
},
|
|
825
|
+
rules: {
|
|
826
|
+
// Overrides rules
|
|
827
|
+
...options.overrides
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
];
|
|
831
|
+
};
|
|
722
832
|
|
|
723
833
|
// src/configs/node.ts
|
|
724
834
|
var node = (options = {}) => [
|
|
@@ -1202,20 +1312,33 @@ var jsdoc = (options = {}) => [
|
|
|
1202
1312
|
"jsdoc/text-escaping": "off",
|
|
1203
1313
|
// No need
|
|
1204
1314
|
// Fixable rules
|
|
1205
|
-
"jsdoc/check-alignment": "error",
|
|
1206
|
-
"jsdoc/check-line-alignment": "error",
|
|
1207
|
-
"jsdoc/check-param-names": "error",
|
|
1208
|
-
"jsdoc/check-property-names": "error",
|
|
1209
|
-
"jsdoc/check-types": "error",
|
|
1210
1315
|
"jsdoc/empty-tags": "error",
|
|
1211
|
-
"jsdoc/multiline-blocks": "error",
|
|
1212
|
-
"jsdoc/no-bad-blocks": "error",
|
|
1213
|
-
"jsdoc/no-blank-block-descriptions": "error",
|
|
1214
|
-
"jsdoc/no-blank-blocks": "error",
|
|
1215
1316
|
"jsdoc/no-defaults": "error",
|
|
1317
|
+
"jsdoc/check-types": "error",
|
|
1318
|
+
"jsdoc/no-blank-blocks": "error",
|
|
1319
|
+
"jsdoc/check-alignment": "error",
|
|
1320
|
+
"jsdoc/multiline-blocks": "error",
|
|
1321
|
+
"jsdoc/check-param-names": "error",
|
|
1216
1322
|
"jsdoc/no-multi-asterisks": "error",
|
|
1323
|
+
"jsdoc/check-line-alignment": "error",
|
|
1324
|
+
"jsdoc/check-property-names": "error",
|
|
1217
1325
|
"jsdoc/require-asterisk-prefix": "error",
|
|
1326
|
+
"jsdoc/no-blank-block-descriptions": "error",
|
|
1218
1327
|
"jsdoc/require-hyphen-before-param-description": "error",
|
|
1328
|
+
"jsdoc/no-bad-blocks": [
|
|
1329
|
+
"error",
|
|
1330
|
+
{
|
|
1331
|
+
ignore: [
|
|
1332
|
+
// built-in default
|
|
1333
|
+
"ts-check",
|
|
1334
|
+
"ts-expect-error",
|
|
1335
|
+
"ts-ignore",
|
|
1336
|
+
"ts-nocheck",
|
|
1337
|
+
// useful
|
|
1338
|
+
"vite-ignore"
|
|
1339
|
+
]
|
|
1340
|
+
}
|
|
1341
|
+
],
|
|
1219
1342
|
"jsdoc/check-tag-names": [
|
|
1220
1343
|
"error",
|
|
1221
1344
|
{
|
|
@@ -1493,17 +1616,17 @@ var pinia = (options = {}) => {
|
|
|
1493
1616
|
};
|
|
1494
1617
|
|
|
1495
1618
|
// src/configs/ntnyq.ts
|
|
1619
|
+
var import_eslint_plugin_ntnyq = require("eslint-plugin-ntnyq");
|
|
1496
1620
|
var ntnyq = (options = {}) => [
|
|
1497
1621
|
{
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
}
|
|
1622
|
+
...(0, import_eslint_plugin_ntnyq.createConfig)({
|
|
1623
|
+
rules: {
|
|
1624
|
+
"ntnyq/prefer-newline-after-file-header": "error",
|
|
1625
|
+
// Overrides rules
|
|
1626
|
+
...options.overrides
|
|
1627
|
+
}
|
|
1628
|
+
}),
|
|
1629
|
+
name: "ntnyq/ntnyq"
|
|
1507
1630
|
}
|
|
1508
1631
|
];
|
|
1509
1632
|
|
|
@@ -1639,65 +1762,6 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1639
1762
|
vueIndentScriptAndStyle: false
|
|
1640
1763
|
};
|
|
1641
1764
|
|
|
1642
|
-
// src/utils/env.ts
|
|
1643
|
-
var import_node_path = require("path");
|
|
1644
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
1645
|
-
var import_local_pkg = require("local-pkg");
|
|
1646
|
-
var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
|
|
1647
|
-
var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
|
|
1648
|
-
var hasVue = (0, import_local_pkg.isPackageExists)("vue") || (0, import_local_pkg.isPackageExists)("nuxt") || (0, import_local_pkg.isPackageExists)("vitepress") || (0, import_local_pkg.isPackageExists)("@slidev/cli") || (0, import_local_pkg.isPackageExists)("vue", {
|
|
1649
|
-
paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground")]
|
|
1650
|
-
});
|
|
1651
|
-
var hasPinia = (0, import_local_pkg.isPackageExists)("pinia");
|
|
1652
|
-
var hasUnoCSS = (0, import_local_pkg.isPackageExists)("unocss") || (0, import_local_pkg.isPackageExists)("@unocss/postcss") || (0, import_local_pkg.isPackageExists)("@unocss/webpack") || (0, import_local_pkg.isPackageExists)("@unocss/nuxt");
|
|
1653
|
-
|
|
1654
|
-
// src/utils/toArray.ts
|
|
1655
|
-
function toArray(val) {
|
|
1656
|
-
val = val ?? [];
|
|
1657
|
-
return Array.isArray(val) ? val : [val];
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
// src/utils/interopDefault.ts
|
|
1661
|
-
async function interopDefault(mod) {
|
|
1662
|
-
const resolved = await mod;
|
|
1663
|
-
return resolved.default || resolved;
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
// src/utils/loadPlugin.ts
|
|
1667
|
-
async function loadPlugin(name) {
|
|
1668
|
-
const mod = await import(name).catch((err) => {
|
|
1669
|
-
console.error(err);
|
|
1670
|
-
throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
|
|
1671
|
-
});
|
|
1672
|
-
return interopDefault(mod);
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
// src/utils/resolveSubOptions.ts
|
|
1676
|
-
function resolveSubOptions(options, key) {
|
|
1677
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
// src/utils/getOverrides.ts
|
|
1681
|
-
function getOverrides(options, key) {
|
|
1682
|
-
const sub = resolveSubOptions(options, key);
|
|
1683
|
-
return "overrides" in sub && sub.overrides ? sub.overrides : {};
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
// src/utils/mergePrettierOptions.ts
|
|
1687
|
-
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
1688
|
-
const result = {
|
|
1689
|
-
...options,
|
|
1690
|
-
...overrides,
|
|
1691
|
-
plugins: [
|
|
1692
|
-
// built-in plugins
|
|
1693
|
-
...options.plugins || [],
|
|
1694
|
-
// custom plugins
|
|
1695
|
-
...overrides.plugins || []
|
|
1696
|
-
]
|
|
1697
|
-
};
|
|
1698
|
-
return result;
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
1765
|
// src/configs/format.ts
|
|
1702
1766
|
var format = (options = {}) => {
|
|
1703
1767
|
const {
|
|
@@ -2001,73 +2065,93 @@ var unicorn = (options = {}) => [
|
|
|
2001
2065
|
|
|
2002
2066
|
// src/configs/specials.ts
|
|
2003
2067
|
var import_globals = __toESM(require("globals"), 1);
|
|
2004
|
-
var specials = (options = {}) =>
|
|
2005
|
-
{
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
rules: {
|
|
2019
|
-
"no-console": "off",
|
|
2020
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2021
|
-
// Overrides rules
|
|
2022
|
-
...options.overridesCliRules
|
|
2023
|
-
}
|
|
2024
|
-
},
|
|
2025
|
-
{
|
|
2026
|
-
name: "ntnyq/specials/userscript",
|
|
2027
|
-
files: [`**/*.user.${GLOB_SRC_EXT}`],
|
|
2028
|
-
languageOptions: {
|
|
2029
|
-
globals: {
|
|
2030
|
-
...import_globals.default.greasemonkey
|
|
2068
|
+
var specials = (options = {}) => {
|
|
2069
|
+
const {
|
|
2070
|
+
// Enable shadcn-vue support
|
|
2071
|
+
shadcnVue: enableShadcnVue = hasShadcnVue
|
|
2072
|
+
} = options;
|
|
2073
|
+
const configs2 = [
|
|
2074
|
+
{
|
|
2075
|
+
name: "ntnyq/specials/scripts",
|
|
2076
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
2077
|
+
rules: {
|
|
2078
|
+
"no-console": "off",
|
|
2079
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2080
|
+
// Overrides rules
|
|
2081
|
+
...options.overridesScriptsRules
|
|
2031
2082
|
}
|
|
2032
2083
|
},
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
}
|
|
2043
|
-
},
|
|
2044
|
-
{
|
|
2045
|
-
name: "ntnyq/specials/config-file",
|
|
2046
|
-
files: [`**/*.config*.${GLOB_SRC_EXT}`],
|
|
2047
|
-
plugins: {
|
|
2048
|
-
"import-x": import_eslint_plugin_import_x.default,
|
|
2049
|
-
perfectionist: import_eslint_plugin_perfectionist.default
|
|
2084
|
+
{
|
|
2085
|
+
name: "ntnyq/specials/cli",
|
|
2086
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
2087
|
+
rules: {
|
|
2088
|
+
"no-console": "off",
|
|
2089
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2090
|
+
// Overrides rules
|
|
2091
|
+
...options.overridesCliRules
|
|
2092
|
+
}
|
|
2050
2093
|
},
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
{
|
|
2058
|
-
type: "alphabetical",
|
|
2059
|
-
order: "asc",
|
|
2060
|
-
partitionByComment: true,
|
|
2061
|
-
groups: ["unknown", "method", "multiline"]
|
|
2094
|
+
{
|
|
2095
|
+
name: "ntnyq/specials/userscript",
|
|
2096
|
+
files: [`**/*.user.${GLOB_SRC_EXT}`],
|
|
2097
|
+
languageOptions: {
|
|
2098
|
+
globals: {
|
|
2099
|
+
...import_globals.default.greasemonkey
|
|
2062
2100
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2101
|
+
},
|
|
2102
|
+
rules: {
|
|
2103
|
+
camelcase: [
|
|
2104
|
+
"error",
|
|
2105
|
+
{
|
|
2106
|
+
allow: ["^GM_.+"]
|
|
2107
|
+
}
|
|
2108
|
+
],
|
|
2109
|
+
// Overrides rules
|
|
2110
|
+
...options.overridesUserScriptsRules
|
|
2111
|
+
}
|
|
2112
|
+
},
|
|
2113
|
+
{
|
|
2114
|
+
name: "ntnyq/specials/config-file",
|
|
2115
|
+
files: [`**/*.config*.${GLOB_SRC_EXT}`],
|
|
2116
|
+
plugins: {
|
|
2117
|
+
"import-x": import_eslint_plugin_import_x.default,
|
|
2118
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
2119
|
+
},
|
|
2120
|
+
rules: {
|
|
2121
|
+
"no-console": "off",
|
|
2122
|
+
"import-x/no-default-export": "off",
|
|
2123
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2124
|
+
"perfectionist/sort-objects": [
|
|
2125
|
+
"error",
|
|
2126
|
+
{
|
|
2127
|
+
type: "alphabetical",
|
|
2128
|
+
order: "asc",
|
|
2129
|
+
partitionByComment: true,
|
|
2130
|
+
groups: ["unknown", "method", "multiline"]
|
|
2131
|
+
}
|
|
2132
|
+
],
|
|
2133
|
+
...options.overridesConfigFileRules
|
|
2134
|
+
}
|
|
2065
2135
|
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2136
|
+
];
|
|
2137
|
+
if (enableShadcnVue) {
|
|
2138
|
+
const shadcnOptions = resolveSubOptions(options, "shadcnVue");
|
|
2139
|
+
configs2.push({
|
|
2140
|
+
name: "ntnyq/specials/shadcn-vue",
|
|
2141
|
+
files: shadcnOptions.files || ["**/components/ui/**/*.ts", "**/components/ui/**/*.vue"],
|
|
2142
|
+
rules: {
|
|
2143
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
2144
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
2145
|
+
// Overrides rules
|
|
2146
|
+
...shadcnOptions.overridesRules
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
if (options.specialCaseConfigs) {
|
|
2151
|
+
configs2.push(...options.specialCaseConfigs);
|
|
2152
|
+
}
|
|
2153
|
+
return configs2;
|
|
2154
|
+
};
|
|
2071
2155
|
|
|
2072
2156
|
// src/configs/comments.ts
|
|
2073
2157
|
var comments = (options = {}) => [
|
|
@@ -2242,20 +2326,24 @@ var prettier = (options = {}) => {
|
|
|
2242
2326
|
};
|
|
2243
2327
|
|
|
2244
2328
|
// src/configs/stylistic.ts
|
|
2245
|
-
var stylistic = (options = {}) =>
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2329
|
+
var stylistic = async (options = {}) => {
|
|
2330
|
+
await ensurePackages(["@stylistic/eslint-plugin"]);
|
|
2331
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
2332
|
+
return [
|
|
2333
|
+
{
|
|
2334
|
+
name: "ntnyq/stylistic",
|
|
2335
|
+
plugins: {
|
|
2336
|
+
"@stylistic": pluginStylistic
|
|
2337
|
+
},
|
|
2338
|
+
rules: {
|
|
2339
|
+
// Only rules are not conflicted with Prettier
|
|
2340
|
+
// Use stylistic config to provide type support
|
|
2341
|
+
// Overrides rules
|
|
2342
|
+
...options.overrides
|
|
2343
|
+
}
|
|
2256
2344
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2345
|
+
];
|
|
2346
|
+
};
|
|
2259
2347
|
|
|
2260
2348
|
// src/configs/gitignore.ts
|
|
2261
2349
|
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
@@ -2501,7 +2589,7 @@ var jsx = () => [
|
|
|
2501
2589
|
];
|
|
2502
2590
|
|
|
2503
2591
|
// src/configs/typescript.ts
|
|
2504
|
-
var
|
|
2592
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
2505
2593
|
var typeAwareRules = {
|
|
2506
2594
|
"dot-notation": "off",
|
|
2507
2595
|
"require-await": "off",
|
|
@@ -2560,7 +2648,7 @@ var typescript = (options = {}) => {
|
|
|
2560
2648
|
allowDefaultProject: ["./*.js"],
|
|
2561
2649
|
defaultProject: options.tsconfigPath
|
|
2562
2650
|
},
|
|
2563
|
-
tsconfigRootDir:
|
|
2651
|
+
tsconfigRootDir: import_node_process4.default.cwd()
|
|
2564
2652
|
} : {},
|
|
2565
2653
|
...parserOptions
|
|
2566
2654
|
};
|
|
@@ -2592,11 +2680,24 @@ var typescript = (options = {}) => {
|
|
|
2592
2680
|
files,
|
|
2593
2681
|
rules: {
|
|
2594
2682
|
...recommendedRules,
|
|
2595
|
-
|
|
2683
|
+
"@typescript-eslint/no-namespace": "off",
|
|
2684
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
2685
|
+
"@typescript-eslint/naming-convention": "off",
|
|
2686
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
2687
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
2688
|
+
"@typescript-eslint/triple-slash-reference": "off",
|
|
2689
|
+
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
2690
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2691
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
2692
|
+
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
2693
|
+
"@typescript-eslint/prefer-as-const": "warn",
|
|
2694
|
+
// Disabled in favor of enhanced ts rules
|
|
2596
2695
|
"no-redeclare": "off",
|
|
2597
2696
|
"no-unused-vars": "off",
|
|
2697
|
+
"default-param-last": "off",
|
|
2598
2698
|
"no-use-before-define": "off",
|
|
2599
2699
|
"no-useless-constructor": "off",
|
|
2700
|
+
"@typescript-eslint/default-param-last": "error",
|
|
2600
2701
|
"@typescript-eslint/no-useless-constructor": "error",
|
|
2601
2702
|
"@typescript-eslint/no-redeclare": [
|
|
2602
2703
|
"error",
|
|
@@ -2630,6 +2731,19 @@ var typescript = (options = {}) => {
|
|
|
2630
2731
|
ignoreRestSiblings: true
|
|
2631
2732
|
}
|
|
2632
2733
|
],
|
|
2734
|
+
// Extra rules
|
|
2735
|
+
"@typescript-eslint/ban-tslint-comment": "error",
|
|
2736
|
+
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
|
|
2737
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
2738
|
+
"error",
|
|
2739
|
+
{
|
|
2740
|
+
minimumDescriptionLength: 1,
|
|
2741
|
+
"ts-check": false,
|
|
2742
|
+
"ts-expect-error": "allow-with-description",
|
|
2743
|
+
"ts-ignore": "allow-with-description",
|
|
2744
|
+
"ts-nocheck": "allow-with-description"
|
|
2745
|
+
}
|
|
2746
|
+
],
|
|
2633
2747
|
"@typescript-eslint/no-unused-expressions": [
|
|
2634
2748
|
"error",
|
|
2635
2749
|
{
|
|
@@ -2660,18 +2774,6 @@ var typescript = (options = {}) => {
|
|
|
2660
2774
|
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
2661
2775
|
}
|
|
2662
2776
|
],
|
|
2663
|
-
"@typescript-eslint/prefer-as-const": "warn",
|
|
2664
|
-
"@typescript-eslint/no-namespace": "off",
|
|
2665
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
2666
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
2667
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
2668
|
-
"@typescript-eslint/naming-convention": "off",
|
|
2669
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
2670
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
2671
|
-
"@typescript-eslint/explicit-member-accessibility": "off",
|
|
2672
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
2673
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
2674
|
-
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
2675
2777
|
// Overrides rules
|
|
2676
2778
|
...options.overrides
|
|
2677
2779
|
}
|
|
@@ -2702,6 +2804,25 @@ var typescript = (options = {}) => {
|
|
|
2702
2804
|
];
|
|
2703
2805
|
};
|
|
2704
2806
|
|
|
2807
|
+
// src/configs/eslintPlugin.ts
|
|
2808
|
+
var eslintPlugin = async (options = {}) => {
|
|
2809
|
+
await ensurePackages(["eslint-plugin-eslint-plugin"]);
|
|
2810
|
+
const pluginESLintPlugin = await interopDefault(import("eslint-plugin-eslint-plugin"));
|
|
2811
|
+
return [
|
|
2812
|
+
{
|
|
2813
|
+
...pluginESLintPlugin.configs["flat/all"],
|
|
2814
|
+
name: "ntnyq/eslint-plugin",
|
|
2815
|
+
rules: {
|
|
2816
|
+
...pluginESLintPlugin.configs["flat/all"].rules,
|
|
2817
|
+
// injected by `createRule`
|
|
2818
|
+
"eslint-plugin/require-meta-docs-url": "off",
|
|
2819
|
+
// Overrides rules
|
|
2820
|
+
...options.overrides
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
];
|
|
2824
|
+
};
|
|
2825
|
+
|
|
2705
2826
|
// src/configs/githubAction.ts
|
|
2706
2827
|
var import_eslint_plugin_github_action2 = require("eslint-plugin-github-action");
|
|
2707
2828
|
var githubAction = (options = {}) => {
|
|
@@ -3085,17 +3206,19 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3085
3206
|
toml: enableTOML = true,
|
|
3086
3207
|
jsonc: enableJSONC = true,
|
|
3087
3208
|
antfu: enableAntfu = true,
|
|
3209
|
+
ntnyq: enableNtnyq = true,
|
|
3088
3210
|
depend: enableDepend = true,
|
|
3089
3211
|
regexp: enableRegexp = true,
|
|
3090
3212
|
unicorn: enableUnicorn = true,
|
|
3091
3213
|
prettier: enablePrettier = true,
|
|
3092
3214
|
markdown: enableMarkdown = true,
|
|
3093
|
-
stylistic: enableStylistic = true,
|
|
3094
3215
|
gitignore: enableGitIgnore = true,
|
|
3095
3216
|
githubAction: enableGitHubAction = true,
|
|
3096
3217
|
perfectionist: enablePerfectionist = true,
|
|
3097
3218
|
// disabled by default
|
|
3098
|
-
svgo: enableSVGO = false
|
|
3219
|
+
svgo: enableSVGO = false,
|
|
3220
|
+
stylistic: enableStylistic = false,
|
|
3221
|
+
eslintPlugin: enableESLintPlugin = false
|
|
3099
3222
|
} = options;
|
|
3100
3223
|
const configs2 = [];
|
|
3101
3224
|
if (enableVue) {
|
|
@@ -3243,13 +3366,6 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3243
3366
|
})
|
|
3244
3367
|
);
|
|
3245
3368
|
}
|
|
3246
|
-
if (enableStylistic) {
|
|
3247
|
-
configs2.push(
|
|
3248
|
-
...stylistic({
|
|
3249
|
-
overrides: getOverrides(options, "stylistic")
|
|
3250
|
-
})
|
|
3251
|
-
);
|
|
3252
|
-
}
|
|
3253
3369
|
if (enableDepend) {
|
|
3254
3370
|
configs2.push(
|
|
3255
3371
|
...depend({
|
|
@@ -3258,13 +3374,34 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3258
3374
|
})
|
|
3259
3375
|
);
|
|
3260
3376
|
}
|
|
3377
|
+
if (enableNtnyq) {
|
|
3378
|
+
configs2.push(
|
|
3379
|
+
ntnyq({
|
|
3380
|
+
overrides: getOverrides(options, "ntnyq")
|
|
3381
|
+
})
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3261
3384
|
if (enableGitHubAction) {
|
|
3262
3385
|
configs2.push(
|
|
3263
|
-
|
|
3386
|
+
githubAction({
|
|
3264
3387
|
overrides: getOverrides(options, "githubAction")
|
|
3265
3388
|
})
|
|
3266
3389
|
);
|
|
3267
3390
|
}
|
|
3391
|
+
if (enableESLintPlugin) {
|
|
3392
|
+
configs2.push(
|
|
3393
|
+
eslintPlugin({
|
|
3394
|
+
overrides: getOverrides(options, "eslintPlugin")
|
|
3395
|
+
})
|
|
3396
|
+
);
|
|
3397
|
+
}
|
|
3398
|
+
if (enableStylistic) {
|
|
3399
|
+
configs2.push(
|
|
3400
|
+
stylistic({
|
|
3401
|
+
overrides: getOverrides(options, "stylistic")
|
|
3402
|
+
})
|
|
3403
|
+
);
|
|
3404
|
+
}
|
|
3268
3405
|
if (enableSVGO) {
|
|
3269
3406
|
configs2.push(
|
|
3270
3407
|
...svgo({
|
|
@@ -3327,18 +3464,22 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3327
3464
|
GLOB_VUE,
|
|
3328
3465
|
GLOB_YAML,
|
|
3329
3466
|
antfu,
|
|
3467
|
+
combineConfigs,
|
|
3330
3468
|
command,
|
|
3331
3469
|
comments,
|
|
3332
3470
|
createNodeResolver,
|
|
3333
3471
|
createTypeScriptImportResolver,
|
|
3334
3472
|
defineESLintConfig,
|
|
3335
3473
|
depend,
|
|
3474
|
+
ensurePackages,
|
|
3336
3475
|
esX,
|
|
3476
|
+
eslintPlugin,
|
|
3337
3477
|
format,
|
|
3338
3478
|
getOverrides,
|
|
3339
3479
|
githubAction,
|
|
3340
3480
|
gitignore,
|
|
3341
3481
|
hasPinia,
|
|
3482
|
+
hasShadcnVue,
|
|
3342
3483
|
hasTypeScript,
|
|
3343
3484
|
hasUnoCSS,
|
|
3344
3485
|
hasVitest,
|
|
@@ -3346,11 +3487,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3346
3487
|
ignores,
|
|
3347
3488
|
importX,
|
|
3348
3489
|
interopDefault,
|
|
3490
|
+
isInGitHooksOrRunByNanoStagedOrRunByTSX,
|
|
3349
3491
|
javascript,
|
|
3350
3492
|
jsdoc,
|
|
3351
3493
|
jsonc,
|
|
3352
3494
|
jsx,
|
|
3353
|
-
loadPlugin,
|
|
3354
3495
|
markdown,
|
|
3355
3496
|
mergePrettierOptions,
|
|
3356
3497
|
mergeProcessors,
|
|
@@ -3367,7 +3508,6 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3367
3508
|
pluginAntfu,
|
|
3368
3509
|
pluginComments,
|
|
3369
3510
|
pluginDepend,
|
|
3370
|
-
pluginEsX,
|
|
3371
3511
|
pluginFormat,
|
|
3372
3512
|
pluginGitHubAction,
|
|
3373
3513
|
pluginImportX,
|
|
@@ -3375,12 +3515,10 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3375
3515
|
pluginJsonc,
|
|
3376
3516
|
pluginMarkdown,
|
|
3377
3517
|
pluginNode,
|
|
3378
|
-
pluginNtnyq,
|
|
3379
3518
|
pluginPerfectionist,
|
|
3380
3519
|
pluginPinia,
|
|
3381
3520
|
pluginPrettier,
|
|
3382
3521
|
pluginRegexp,
|
|
3383
|
-
pluginStylistic,
|
|
3384
3522
|
pluginSvgo,
|
|
3385
3523
|
pluginToml,
|
|
3386
3524
|
pluginTypeScript,
|