@ntnyq/eslint-config 3.11.0 → 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 +227 -126
- package/dist/index.d.cts +373 -46
- package/dist/index.d.ts +373 -46
- package/dist/index.js +291 -194
- package/package.json +37 -23
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
> Flat ESLint config for JavaScript, TypeScript, Vue 2, Vue 3, Prettier.
|
|
4
4
|
|
|
5
5
|
[](https://github.com/ntnyq/eslint-config/actions)
|
|
6
|
-
[](https://www.npmjs.com/package/@ntnyq/eslint-config)
|
|
7
6
|
[](https://www.npmjs.com/package/@ntnyq/eslint-config/v/latest)
|
|
7
|
+
[](https://www.npmjs.com/package/@ntnyq/eslint-config)
|
|
8
8
|
[](https://github.com/ntnyq/eslint-config/blob/main/LICENSE)
|
|
9
9
|
|
|
10
10
|
## Features
|
|
@@ -87,7 +87,8 @@ export default defineConfig({
|
|
|
87
87
|
"prettier.enable": true,
|
|
88
88
|
"editor.formatOnSave": true,
|
|
89
89
|
"editor.codeActionsOnSave": {
|
|
90
|
-
"source.fixAll.eslint": "explicit"
|
|
90
|
+
"source.fixAll.eslint": "explicit",
|
|
91
|
+
"source.organizeImports": "never"
|
|
91
92
|
},
|
|
92
93
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
93
94
|
"eslint.validate": [
|
|
@@ -165,12 +166,12 @@ export interface ConfigOptions extends ConfigOptionsInternal, OptionsExtensions
|
|
|
165
166
|
gitignore?: boolean | ConfigGitIgnoreOptions
|
|
166
167
|
jsonc?: boolean | ConfigJsoncOptions
|
|
167
168
|
markdown?: boolean | ConfigMarkdownOptions
|
|
169
|
+
ntnyq?: boolean | ConfigNtnyqOptions
|
|
168
170
|
perfectionist?: boolean | ConfigPerfectionistOptions
|
|
169
171
|
pinia?: boolean | ConfigPiniaOptions
|
|
170
172
|
prettier?: boolean | ConfigPrettierOptions
|
|
171
173
|
regexp?: boolean | ConfigRegexpOptions
|
|
172
174
|
sort?: boolean | ConfigSortOptions
|
|
173
|
-
stylistic?: boolean | ConfigStylisticOptions
|
|
174
175
|
test?: boolean | ConfigTestOptions
|
|
175
176
|
toml?: boolean | ConfigTomlOptions
|
|
176
177
|
typescript?: boolean | ConfigTypeScriptOptions
|
|
@@ -180,9 +181,23 @@ export interface ConfigOptions extends ConfigOptionsInternal, OptionsExtensions
|
|
|
180
181
|
yml?: boolean | ConfigYmlOptions
|
|
181
182
|
|
|
182
183
|
/**
|
|
183
|
-
*
|
|
184
|
+
* disabled by default
|
|
184
185
|
*/
|
|
185
186
|
svgo?: boolean | ConfigSVGOOptions
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* disabled by default
|
|
190
|
+
*
|
|
191
|
+
* require `eslint-plugin-eslint-plugin` installed mannally
|
|
192
|
+
*/
|
|
193
|
+
eslintPlugin?: boolean | ConfigESLintPluginOptions
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* disabled by default
|
|
197
|
+
*
|
|
198
|
+
* require `@stylistic/eslint-plugin` installed mannally
|
|
199
|
+
*/
|
|
200
|
+
stylistic?: boolean | ConfigStylisticOptions
|
|
186
201
|
}
|
|
187
202
|
```
|
|
188
203
|
|
package/dist/index.cjs
CHANGED
|
@@ -68,13 +68,16 @@ __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,
|
|
@@ -88,11 +91,11 @@ __export(index_exports, {
|
|
|
88
91
|
ignores: () => ignores,
|
|
89
92
|
importX: () => importX,
|
|
90
93
|
interopDefault: () => interopDefault,
|
|
94
|
+
isInGitHooksOrRunByNanoStagedOrRunByTSX: () => isInGitHooksOrRunByNanoStagedOrRunByTSX,
|
|
91
95
|
javascript: () => javascript,
|
|
92
96
|
jsdoc: () => jsdoc,
|
|
93
97
|
jsonc: () => jsonc,
|
|
94
98
|
jsx: () => jsx,
|
|
95
|
-
loadPlugin: () => loadPlugin,
|
|
96
99
|
markdown: () => markdown,
|
|
97
100
|
mergePrettierOptions: () => mergePrettierOptions,
|
|
98
101
|
mergeProcessors: () => import_eslint_merge_processors.mergeProcessors,
|
|
@@ -109,7 +112,6 @@ __export(index_exports, {
|
|
|
109
112
|
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
110
113
|
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
111
114
|
pluginDepend: () => pluginDepend,
|
|
112
|
-
pluginEsX: () => import_eslint_plugin_es_x.default,
|
|
113
115
|
pluginFormat: () => import_eslint_plugin_format.default,
|
|
114
116
|
pluginGitHubAction: () => import_eslint_plugin_github_action.default,
|
|
115
117
|
pluginImportX: () => import_eslint_plugin_import_x.default,
|
|
@@ -117,12 +119,10 @@ __export(index_exports, {
|
|
|
117
119
|
pluginJsonc: () => import_eslint_plugin_jsonc.default,
|
|
118
120
|
pluginMarkdown: () => import_markdown.default,
|
|
119
121
|
pluginNode: () => import_eslint_plugin_n.default,
|
|
120
|
-
pluginNtnyq: () => import_eslint_plugin_ntnyq.default,
|
|
121
122
|
pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
|
|
122
123
|
pluginPinia: () => import_eslint_plugin_pinia.default,
|
|
123
124
|
pluginPrettier: () => import_eslint_plugin_prettier.default,
|
|
124
125
|
pluginRegexp: () => pluginRegexp,
|
|
125
|
-
pluginStylistic: () => import_eslint_plugin3.default,
|
|
126
126
|
pluginSvgo: () => import_eslint_plugin_svgo.default,
|
|
127
127
|
pluginToml: () => import_eslint_plugin_toml.default,
|
|
128
128
|
pluginTypeScript: () => import_typescript_eslint2.plugin,
|
|
@@ -155,6 +155,10 @@ __export(index_exports, {
|
|
|
155
155
|
});
|
|
156
156
|
module.exports = __toCommonJS(index_exports);
|
|
157
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
|
+
|
|
158
162
|
// src/core.ts
|
|
159
163
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
160
164
|
|
|
@@ -194,12 +198,10 @@ var pluginRegexp = __toESM(require("eslint-plugin-regexp"), 1);
|
|
|
194
198
|
var pluginDepend = __toESM(require("eslint-plugin-depend"), 1);
|
|
195
199
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
196
200
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
197
|
-
var import_eslint_plugin_es_x = __toESM(require("eslint-plugin-es-x"), 1);
|
|
198
201
|
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
199
202
|
var import_eslint_plugin_svgo = __toESM(require("eslint-plugin-svgo"), 1);
|
|
200
203
|
var import_eslint_plugin_toml = __toESM(require("eslint-plugin-toml"), 1);
|
|
201
204
|
var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
|
|
202
|
-
var import_eslint_plugin_ntnyq = __toESM(require("eslint-plugin-ntnyq"), 1);
|
|
203
205
|
var import_markdown = __toESM(require("@eslint/markdown"), 1);
|
|
204
206
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
205
207
|
var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
|
|
@@ -211,7 +213,6 @@ var import_eslint_plugin2 = __toESM(require("@vitest/eslint-plugin"), 1);
|
|
|
211
213
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
212
214
|
var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
|
|
213
215
|
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
214
|
-
var import_eslint_plugin3 = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
215
216
|
var import_eslint_plugin_github_action = __toESM(require("eslint-plugin-github-action"), 1);
|
|
216
217
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
217
218
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
@@ -328,7 +329,11 @@ var GLOB_EXCLUDE = [
|
|
|
328
329
|
"**/.wrangler",
|
|
329
330
|
"**/.changeset",
|
|
330
331
|
"**/.npmrc",
|
|
331
|
-
"**/.yarnrc"
|
|
332
|
+
"**/.yarnrc",
|
|
333
|
+
"**/.husky",
|
|
334
|
+
// tauri
|
|
335
|
+
"**/src-tauri/gen",
|
|
336
|
+
"**/src-tauri/target"
|
|
332
337
|
];
|
|
333
338
|
|
|
334
339
|
// src/configs/vue.ts
|
|
@@ -707,19 +712,123 @@ var yml = (options = {}) => [
|
|
|
707
712
|
}
|
|
708
713
|
];
|
|
709
714
|
|
|
710
|
-
// src/
|
|
711
|
-
var
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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);
|
|
720
790
|
}
|
|
721
791
|
}
|
|
722
|
-
|
|
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
|
+
};
|
|
723
832
|
|
|
724
833
|
// src/configs/node.ts
|
|
725
834
|
var node = (options = {}) => [
|
|
@@ -1203,20 +1312,33 @@ var jsdoc = (options = {}) => [
|
|
|
1203
1312
|
"jsdoc/text-escaping": "off",
|
|
1204
1313
|
// No need
|
|
1205
1314
|
// Fixable rules
|
|
1206
|
-
"jsdoc/check-alignment": "error",
|
|
1207
|
-
"jsdoc/check-line-alignment": "error",
|
|
1208
|
-
"jsdoc/check-param-names": "error",
|
|
1209
|
-
"jsdoc/check-property-names": "error",
|
|
1210
|
-
"jsdoc/check-types": "error",
|
|
1211
1315
|
"jsdoc/empty-tags": "error",
|
|
1212
|
-
"jsdoc/multiline-blocks": "error",
|
|
1213
|
-
"jsdoc/no-bad-blocks": "error",
|
|
1214
|
-
"jsdoc/no-blank-block-descriptions": "error",
|
|
1215
|
-
"jsdoc/no-blank-blocks": "error",
|
|
1216
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",
|
|
1217
1322
|
"jsdoc/no-multi-asterisks": "error",
|
|
1323
|
+
"jsdoc/check-line-alignment": "error",
|
|
1324
|
+
"jsdoc/check-property-names": "error",
|
|
1218
1325
|
"jsdoc/require-asterisk-prefix": "error",
|
|
1326
|
+
"jsdoc/no-blank-block-descriptions": "error",
|
|
1219
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
|
+
],
|
|
1220
1342
|
"jsdoc/check-tag-names": [
|
|
1221
1343
|
"error",
|
|
1222
1344
|
{
|
|
@@ -1494,17 +1616,17 @@ var pinia = (options = {}) => {
|
|
|
1494
1616
|
};
|
|
1495
1617
|
|
|
1496
1618
|
// src/configs/ntnyq.ts
|
|
1619
|
+
var import_eslint_plugin_ntnyq = require("eslint-plugin-ntnyq");
|
|
1497
1620
|
var ntnyq = (options = {}) => [
|
|
1498
1621
|
{
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
}
|
|
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"
|
|
1508
1630
|
}
|
|
1509
1631
|
];
|
|
1510
1632
|
|
|
@@ -1640,66 +1762,6 @@ var DEFAULT_PRETTIER_OPTIONS = {
|
|
|
1640
1762
|
vueIndentScriptAndStyle: false
|
|
1641
1763
|
};
|
|
1642
1764
|
|
|
1643
|
-
// src/utils/env.ts
|
|
1644
|
-
var import_node_path = require("path");
|
|
1645
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
1646
|
-
var import_local_pkg = require("local-pkg");
|
|
1647
|
-
var hasTypeScript = (0, import_local_pkg.isPackageExists)("typescript");
|
|
1648
|
-
var hasVitest = (0, import_local_pkg.isPackageExists)("vitest");
|
|
1649
|
-
var hasShadcnVue = (0, import_local_pkg.isPackageExists)("radix-vue") && (0, import_local_pkg.isPackageExists)("clsx");
|
|
1650
|
-
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", {
|
|
1651
|
-
paths: [(0, import_node_path.resolve)(import_node_process.default.cwd(), "playground")]
|
|
1652
|
-
});
|
|
1653
|
-
var hasPinia = (0, import_local_pkg.isPackageExists)("pinia");
|
|
1654
|
-
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");
|
|
1655
|
-
|
|
1656
|
-
// src/utils/toArray.ts
|
|
1657
|
-
function toArray(val) {
|
|
1658
|
-
val = val ?? [];
|
|
1659
|
-
return Array.isArray(val) ? val : [val];
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
// src/utils/interopDefault.ts
|
|
1663
|
-
async function interopDefault(mod) {
|
|
1664
|
-
const resolved = await mod;
|
|
1665
|
-
return resolved.default || resolved;
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// src/utils/loadPlugin.ts
|
|
1669
|
-
async function loadPlugin(name) {
|
|
1670
|
-
const mod = await import(name).catch((err) => {
|
|
1671
|
-
console.error(err);
|
|
1672
|
-
throw new Error(`Failed to load ESLint plugin '${name}'. Please install it!.`);
|
|
1673
|
-
});
|
|
1674
|
-
return interopDefault(mod);
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
// src/utils/resolveSubOptions.ts
|
|
1678
|
-
function resolveSubOptions(options, key) {
|
|
1679
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
// src/utils/getOverrides.ts
|
|
1683
|
-
function getOverrides(options, key) {
|
|
1684
|
-
const subOptions = resolveSubOptions(options, key);
|
|
1685
|
-
return "overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {};
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
// src/utils/mergePrettierOptions.ts
|
|
1689
|
-
function mergePrettierOptions(options = {}, overrides = {}) {
|
|
1690
|
-
const result = {
|
|
1691
|
-
...options,
|
|
1692
|
-
...overrides,
|
|
1693
|
-
plugins: [
|
|
1694
|
-
// built-in plugins
|
|
1695
|
-
...options.plugins || [],
|
|
1696
|
-
// custom plugins
|
|
1697
|
-
...overrides.plugins || []
|
|
1698
|
-
]
|
|
1699
|
-
};
|
|
1700
|
-
return result;
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
1765
|
// src/configs/format.ts
|
|
1704
1766
|
var format = (options = {}) => {
|
|
1705
1767
|
const {
|
|
@@ -2264,20 +2326,24 @@ var prettier = (options = {}) => {
|
|
|
2264
2326
|
};
|
|
2265
2327
|
|
|
2266
2328
|
// src/configs/stylistic.ts
|
|
2267
|
-
var stylistic = (options = {}) =>
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
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
|
+
}
|
|
2278
2344
|
}
|
|
2279
|
-
|
|
2280
|
-
|
|
2345
|
+
];
|
|
2346
|
+
};
|
|
2281
2347
|
|
|
2282
2348
|
// src/configs/gitignore.ts
|
|
2283
2349
|
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
@@ -2523,7 +2589,7 @@ var jsx = () => [
|
|
|
2523
2589
|
];
|
|
2524
2590
|
|
|
2525
2591
|
// src/configs/typescript.ts
|
|
2526
|
-
var
|
|
2592
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
2527
2593
|
var typeAwareRules = {
|
|
2528
2594
|
"dot-notation": "off",
|
|
2529
2595
|
"require-await": "off",
|
|
@@ -2582,7 +2648,7 @@ var typescript = (options = {}) => {
|
|
|
2582
2648
|
allowDefaultProject: ["./*.js"],
|
|
2583
2649
|
defaultProject: options.tsconfigPath
|
|
2584
2650
|
},
|
|
2585
|
-
tsconfigRootDir:
|
|
2651
|
+
tsconfigRootDir: import_node_process4.default.cwd()
|
|
2586
2652
|
} : {},
|
|
2587
2653
|
...parserOptions
|
|
2588
2654
|
};
|
|
@@ -2738,6 +2804,25 @@ var typescript = (options = {}) => {
|
|
|
2738
2804
|
];
|
|
2739
2805
|
};
|
|
2740
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
|
+
|
|
2741
2826
|
// src/configs/githubAction.ts
|
|
2742
2827
|
var import_eslint_plugin_github_action2 = require("eslint-plugin-github-action");
|
|
2743
2828
|
var githubAction = (options = {}) => {
|
|
@@ -3121,17 +3206,19 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3121
3206
|
toml: enableTOML = true,
|
|
3122
3207
|
jsonc: enableJSONC = true,
|
|
3123
3208
|
antfu: enableAntfu = true,
|
|
3209
|
+
ntnyq: enableNtnyq = true,
|
|
3124
3210
|
depend: enableDepend = true,
|
|
3125
3211
|
regexp: enableRegexp = true,
|
|
3126
3212
|
unicorn: enableUnicorn = true,
|
|
3127
3213
|
prettier: enablePrettier = true,
|
|
3128
3214
|
markdown: enableMarkdown = true,
|
|
3129
|
-
stylistic: enableStylistic = true,
|
|
3130
3215
|
gitignore: enableGitIgnore = true,
|
|
3131
3216
|
githubAction: enableGitHubAction = true,
|
|
3132
3217
|
perfectionist: enablePerfectionist = true,
|
|
3133
3218
|
// disabled by default
|
|
3134
|
-
svgo: enableSVGO = false
|
|
3219
|
+
svgo: enableSVGO = false,
|
|
3220
|
+
stylistic: enableStylistic = false,
|
|
3221
|
+
eslintPlugin: enableESLintPlugin = false
|
|
3135
3222
|
} = options;
|
|
3136
3223
|
const configs2 = [];
|
|
3137
3224
|
if (enableVue) {
|
|
@@ -3279,13 +3366,6 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3279
3366
|
})
|
|
3280
3367
|
);
|
|
3281
3368
|
}
|
|
3282
|
-
if (enableStylistic) {
|
|
3283
|
-
configs2.push(
|
|
3284
|
-
...stylistic({
|
|
3285
|
-
overrides: getOverrides(options, "stylistic")
|
|
3286
|
-
})
|
|
3287
|
-
);
|
|
3288
|
-
}
|
|
3289
3369
|
if (enableDepend) {
|
|
3290
3370
|
configs2.push(
|
|
3291
3371
|
...depend({
|
|
@@ -3294,13 +3374,34 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3294
3374
|
})
|
|
3295
3375
|
);
|
|
3296
3376
|
}
|
|
3377
|
+
if (enableNtnyq) {
|
|
3378
|
+
configs2.push(
|
|
3379
|
+
ntnyq({
|
|
3380
|
+
overrides: getOverrides(options, "ntnyq")
|
|
3381
|
+
})
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3297
3384
|
if (enableGitHubAction) {
|
|
3298
3385
|
configs2.push(
|
|
3299
|
-
|
|
3386
|
+
githubAction({
|
|
3300
3387
|
overrides: getOverrides(options, "githubAction")
|
|
3301
3388
|
})
|
|
3302
3389
|
);
|
|
3303
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
|
+
}
|
|
3304
3405
|
if (enableSVGO) {
|
|
3305
3406
|
configs2.push(
|
|
3306
3407
|
...svgo({
|
|
@@ -3363,13 +3464,16 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3363
3464
|
GLOB_VUE,
|
|
3364
3465
|
GLOB_YAML,
|
|
3365
3466
|
antfu,
|
|
3467
|
+
combineConfigs,
|
|
3366
3468
|
command,
|
|
3367
3469
|
comments,
|
|
3368
3470
|
createNodeResolver,
|
|
3369
3471
|
createTypeScriptImportResolver,
|
|
3370
3472
|
defineESLintConfig,
|
|
3371
3473
|
depend,
|
|
3474
|
+
ensurePackages,
|
|
3372
3475
|
esX,
|
|
3476
|
+
eslintPlugin,
|
|
3373
3477
|
format,
|
|
3374
3478
|
getOverrides,
|
|
3375
3479
|
githubAction,
|
|
@@ -3383,11 +3487,11 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3383
3487
|
ignores,
|
|
3384
3488
|
importX,
|
|
3385
3489
|
interopDefault,
|
|
3490
|
+
isInGitHooksOrRunByNanoStagedOrRunByTSX,
|
|
3386
3491
|
javascript,
|
|
3387
3492
|
jsdoc,
|
|
3388
3493
|
jsonc,
|
|
3389
3494
|
jsx,
|
|
3390
|
-
loadPlugin,
|
|
3391
3495
|
markdown,
|
|
3392
3496
|
mergePrettierOptions,
|
|
3393
3497
|
mergeProcessors,
|
|
@@ -3404,7 +3508,6 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3404
3508
|
pluginAntfu,
|
|
3405
3509
|
pluginComments,
|
|
3406
3510
|
pluginDepend,
|
|
3407
|
-
pluginEsX,
|
|
3408
3511
|
pluginFormat,
|
|
3409
3512
|
pluginGitHubAction,
|
|
3410
3513
|
pluginImportX,
|
|
@@ -3412,12 +3515,10 @@ function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
3412
3515
|
pluginJsonc,
|
|
3413
3516
|
pluginMarkdown,
|
|
3414
3517
|
pluginNode,
|
|
3415
|
-
pluginNtnyq,
|
|
3416
3518
|
pluginPerfectionist,
|
|
3417
3519
|
pluginPinia,
|
|
3418
3520
|
pluginPrettier,
|
|
3419
3521
|
pluginRegexp,
|
|
3420
|
-
pluginStylistic,
|
|
3421
3522
|
pluginSvgo,
|
|
3422
3523
|
pluginToml,
|
|
3423
3524
|
pluginTypeScript,
|