@kirklin/eslint-config 2.5.0 → 2.6.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 +127 -15
- package/README.zh-cn.md +129 -19
- package/dist/cli.cjs +64 -61
- package/dist/cli.js +64 -61
- package/dist/index.cjs +115 -34
- package/dist/index.d.cts +839 -1223
- package/dist/index.d.ts +839 -1223
- package/dist/index.js +107 -34
- package/package.json +54 -51
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import c from "picocolors";
|
|
|
19
19
|
var package_default = {
|
|
20
20
|
name: "@kirklin/eslint-config",
|
|
21
21
|
type: "module",
|
|
22
|
-
version: "2.
|
|
22
|
+
version: "2.6.0",
|
|
23
23
|
packageManager: "pnpm@9.4.0",
|
|
24
24
|
description: "Kirk Lin's ESLint config",
|
|
25
25
|
author: "Kirk Lin (https://github.com/kirklin/)",
|
|
@@ -48,8 +48,8 @@ var package_default = {
|
|
|
48
48
|
dev: "npx @eslint/config-inspector --config eslint.config.ts",
|
|
49
49
|
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
50
50
|
watch: "tsup --format esm,cjs --watch",
|
|
51
|
-
lint: "eslint .",
|
|
52
|
-
"lint:fix": "eslint . --fix",
|
|
51
|
+
lint: "eslint --flag unstable_ts_config .",
|
|
52
|
+
"lint:fix": "eslint --flag unstable_ts_config . --fix",
|
|
53
53
|
typegen: "esno scripts/typegen.ts",
|
|
54
54
|
prepack: "nr build",
|
|
55
55
|
release: "bumpp && pnpm publish",
|
|
@@ -115,33 +115,33 @@ var package_default = {
|
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
dependencies: {
|
|
118
|
-
"@antfu/install-pkg": "^0.
|
|
118
|
+
"@antfu/install-pkg": "^0.4.1",
|
|
119
119
|
"@clack/prompts": "^0.7.0",
|
|
120
|
-
"@
|
|
121
|
-
"@
|
|
122
|
-
"@typescript-eslint/
|
|
123
|
-
"eslint
|
|
124
|
-
"eslint-
|
|
120
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
121
|
+
"@stylistic/eslint-plugin": "^2.6.4",
|
|
122
|
+
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
123
|
+
"@typescript-eslint/parser": "^8.3.0",
|
|
124
|
+
"@vitest/eslint-plugin": "^1.0.5",
|
|
125
|
+
"eslint-config-flat-gitignore": "^0.1.8",
|
|
126
|
+
"eslint-flat-config-utils": "^0.3.1",
|
|
125
127
|
"eslint-merge-processors": "^0.1.0",
|
|
126
128
|
"eslint-plugin-command": "^0.2.3",
|
|
127
|
-
"eslint-plugin-
|
|
128
|
-
"eslint-plugin-
|
|
129
|
-
"eslint-plugin-jsdoc": "^48.5.0",
|
|
129
|
+
"eslint-plugin-import-x": "^4.0.0",
|
|
130
|
+
"eslint-plugin-jsdoc": "^50.2.2",
|
|
130
131
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
131
132
|
"eslint-plugin-kirklin": "^1.3.0",
|
|
132
|
-
"eslint-plugin-markdown": "^5.
|
|
133
|
-
"eslint-plugin-n": "^17.
|
|
134
|
-
"eslint-plugin-no-only-tests": "^3.
|
|
135
|
-
"eslint-plugin-perfectionist": "^2.
|
|
133
|
+
"eslint-plugin-markdown": "^5.1.0",
|
|
134
|
+
"eslint-plugin-n": "^17.10.2",
|
|
135
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
136
|
+
"eslint-plugin-perfectionist": "^3.2.0",
|
|
136
137
|
"eslint-plugin-regexp": "^2.6.0",
|
|
137
138
|
"eslint-plugin-toml": "^0.11.1",
|
|
138
|
-
"eslint-plugin-unicorn": "^
|
|
139
|
-
"eslint-plugin-unused-imports": "^4.
|
|
140
|
-
"eslint-plugin-
|
|
141
|
-
"eslint-plugin-vue": "^9.26.0",
|
|
139
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
140
|
+
"eslint-plugin-unused-imports": "^4.1.3",
|
|
141
|
+
"eslint-plugin-vue": "^9.27.0",
|
|
142
142
|
"eslint-plugin-yml": "^1.14.0",
|
|
143
143
|
"eslint-processor-vue-blocks": "^0.1.2",
|
|
144
|
-
globals: "^15.
|
|
144
|
+
globals: "^15.9.0",
|
|
145
145
|
"jsonc-eslint-parser": "^2.4.0",
|
|
146
146
|
"local-pkg": "^0.5.0",
|
|
147
147
|
"parse-gitignore": "^2.0.0",
|
|
@@ -152,54 +152,57 @@ var package_default = {
|
|
|
152
152
|
yargs: "^17.7.2"
|
|
153
153
|
},
|
|
154
154
|
devDependencies: {
|
|
155
|
-
"@antfu/ni": "^0.
|
|
156
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
157
|
-
"@eslint/config-inspector": "^0.5.
|
|
155
|
+
"@antfu/ni": "^0.22.4",
|
|
156
|
+
"@eslint-react/eslint-plugin": "^1.12.1",
|
|
157
|
+
"@eslint/config-inspector": "^0.5.4",
|
|
158
158
|
"@kirklin/eslint-config": "workspace:*",
|
|
159
159
|
"@prettier/plugin-xml": "^3.4.1",
|
|
160
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
161
|
-
"@types/eslint": "^
|
|
160
|
+
"@stylistic/eslint-plugin-migrate": "^2.6.4",
|
|
161
|
+
"@types/eslint": "^9.6.1",
|
|
162
162
|
"@types/fs-extra": "^11.0.4",
|
|
163
|
-
"@types/node": "^
|
|
163
|
+
"@types/node": "^22.5.0",
|
|
164
164
|
"@types/prompts": "^2.4.9",
|
|
165
|
-
"@types/yargs": "^17.0.
|
|
166
|
-
"@unocss/eslint-plugin": "^0.
|
|
165
|
+
"@types/yargs": "^17.0.33",
|
|
166
|
+
"@unocss/eslint-plugin": "^0.62.3",
|
|
167
167
|
"astro-eslint-parser": "^1.0.2",
|
|
168
|
-
bumpp: "^9.
|
|
169
|
-
eslint: "
|
|
170
|
-
"eslint-plugin-astro": "^1.2.
|
|
168
|
+
bumpp: "^9.5.2",
|
|
169
|
+
eslint: "^9.9.1",
|
|
170
|
+
"eslint-plugin-astro": "^1.2.3",
|
|
171
171
|
"eslint-plugin-format": "^0.1.2",
|
|
172
172
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
173
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
174
|
-
"eslint-plugin-solid": "^0.14.
|
|
175
|
-
"eslint-plugin-svelte": "^2.
|
|
176
|
-
"eslint-
|
|
177
|
-
"eslint-typegen": "^0.2.4",
|
|
173
|
+
"eslint-plugin-react-refresh": "^0.4.11",
|
|
174
|
+
"eslint-plugin-solid": "^0.14.2",
|
|
175
|
+
"eslint-plugin-svelte": "^2.43.0",
|
|
176
|
+
"eslint-typegen": "^0.3.1",
|
|
178
177
|
esno: "^4.7.0",
|
|
179
|
-
execa: "^9.3.
|
|
178
|
+
execa: "^9.3.1",
|
|
180
179
|
"fast-glob": "^3.3.2",
|
|
181
180
|
"fs-extra": "^11.2.0",
|
|
182
|
-
|
|
183
|
-
"
|
|
181
|
+
jiti: "^1.21.6",
|
|
182
|
+
"lint-staged": "^15.2.9",
|
|
183
|
+
"prettier-plugin-astro": "^0.14.1",
|
|
184
184
|
"prettier-plugin-slidev": "^1.0.5",
|
|
185
|
-
rimraf: "^
|
|
185
|
+
rimraf: "^6.0.1",
|
|
186
186
|
"simple-git-hooks": "^2.11.1",
|
|
187
|
-
svelte: "^4.2.
|
|
188
|
-
"svelte-eslint-parser": "^0.
|
|
189
|
-
tsup: "^8.
|
|
190
|
-
tsx: "^4.
|
|
191
|
-
typescript: "^5.5.
|
|
192
|
-
vitest: "^
|
|
193
|
-
vue: "^3.4.
|
|
187
|
+
svelte: "^4.2.19",
|
|
188
|
+
"svelte-eslint-parser": "^0.41.0",
|
|
189
|
+
tsup: "^8.2.4",
|
|
190
|
+
tsx: "^4.18.0",
|
|
191
|
+
typescript: "^5.5.4",
|
|
192
|
+
vitest: "^2.0.5",
|
|
193
|
+
vue: "^3.4.38"
|
|
194
194
|
},
|
|
195
195
|
resolutions: {
|
|
196
|
-
|
|
196
|
+
"@eslint-community/eslint-utils": "^4.4.0",
|
|
197
|
+
"@typescript-eslint/utils": "^8.3.0",
|
|
198
|
+
eslint: "^9.9.1",
|
|
199
|
+
tsx: "^4.18.0"
|
|
197
200
|
},
|
|
198
201
|
"simple-git-hooks": {
|
|
199
202
|
"pre-commit": "npx lint-staged"
|
|
200
203
|
},
|
|
201
204
|
"lint-staged": {
|
|
202
|
-
"*": "eslint --fix"
|
|
205
|
+
"*": "eslint --flag unstable_ts_config --fix"
|
|
203
206
|
}
|
|
204
207
|
};
|
|
205
208
|
|
|
@@ -217,16 +220,16 @@ var vscodeSettingsString = `
|
|
|
217
220
|
|
|
218
221
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
219
222
|
"eslint.rules.customizations": [
|
|
220
|
-
{ "rule": "style/*", "severity": "off" },
|
|
221
|
-
{ "rule": "format/*", "severity": "off" },
|
|
222
|
-
{ "rule": "*-indent", "severity": "off" },
|
|
223
|
-
{ "rule": "*-spacing", "severity": "off" },
|
|
224
|
-
{ "rule": "*-spaces", "severity": "off" },
|
|
225
|
-
{ "rule": "*-order", "severity": "off" },
|
|
226
|
-
{ "rule": "*-dangle", "severity": "off" },
|
|
227
|
-
{ "rule": "*-newline", "severity": "off" },
|
|
228
|
-
{ "rule": "*quotes", "severity": "off" },
|
|
229
|
-
{ "rule": "*semi", "severity": "off" }
|
|
223
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
224
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
225
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
226
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
227
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
228
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
229
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
230
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
231
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
232
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
230
233
|
],
|
|
231
234
|
|
|
232
235
|
// Enable eslint for all supported languages
|
|
@@ -321,7 +324,7 @@ function isGitClean() {
|
|
|
321
324
|
try {
|
|
322
325
|
execSync("git diff-index --quiet HEAD --");
|
|
323
326
|
return true;
|
|
324
|
-
} catch
|
|
327
|
+
} catch {
|
|
325
328
|
return false;
|
|
326
329
|
}
|
|
327
330
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(src_exports, {
|
|
|
52
52
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
53
53
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
54
54
|
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
55
|
+
GLOB_SVG: () => GLOB_SVG,
|
|
55
56
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
56
57
|
GLOB_TOML: () => GLOB_TOML,
|
|
57
58
|
GLOB_TS: () => GLOB_TS,
|
|
@@ -72,6 +73,9 @@ __export(src_exports, {
|
|
|
72
73
|
ignores: () => ignores,
|
|
73
74
|
imports: () => imports,
|
|
74
75
|
interopDefault: () => interopDefault,
|
|
76
|
+
isInEditorEnv: () => isInEditorEnv,
|
|
77
|
+
isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
|
|
78
|
+
isPackageInScope: () => isPackageInScope,
|
|
75
79
|
javascript: () => javascript,
|
|
76
80
|
jsdoc: () => jsdoc,
|
|
77
81
|
jsonc: () => jsonc,
|
|
@@ -102,9 +106,11 @@ __export(src_exports, {
|
|
|
102
106
|
});
|
|
103
107
|
module.exports = __toCommonJS(src_exports);
|
|
104
108
|
|
|
109
|
+
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.18.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
110
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
111
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
112
|
+
|
|
105
113
|
// src/factory.ts
|
|
106
|
-
var import_node_process3 = __toESM(require("process"), 1);
|
|
107
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
108
114
|
var import_local_pkg4 = require("local-pkg");
|
|
109
115
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
110
116
|
|
|
@@ -130,6 +136,7 @@ var GLOB_VUE = "**/*.vue";
|
|
|
130
136
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
131
137
|
var GLOB_TOML = "**/*.toml";
|
|
132
138
|
var GLOB_XML = "**/*.xml";
|
|
139
|
+
var GLOB_SVG = "**/*.svg";
|
|
133
140
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
134
141
|
var GLOB_ASTRO = "**/*.astro";
|
|
135
142
|
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
@@ -171,6 +178,7 @@ var GLOB_EXCLUDE = [
|
|
|
171
178
|
"**/.vitepress/cache",
|
|
172
179
|
"**/.nuxt",
|
|
173
180
|
"**/.next",
|
|
181
|
+
"**/.svelte-kit",
|
|
174
182
|
"**/.vercel",
|
|
175
183
|
"**/.changeset",
|
|
176
184
|
"**/.idea",
|
|
@@ -189,7 +197,10 @@ var GLOB_EXCLUDE = [
|
|
|
189
197
|
|
|
190
198
|
// src/utils.ts
|
|
191
199
|
var import_node_process = __toESM(require("process"), 1);
|
|
200
|
+
var import_node_url = require("url");
|
|
192
201
|
var import_local_pkg = require("local-pkg");
|
|
202
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
203
|
+
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@kirklin/eslint-config");
|
|
193
204
|
var parserPlain = {
|
|
194
205
|
meta: {
|
|
195
206
|
name: "parser-plain"
|
|
@@ -252,11 +263,14 @@ async function interopDefault(m) {
|
|
|
252
263
|
const resolved = await m;
|
|
253
264
|
return resolved.default || resolved;
|
|
254
265
|
}
|
|
266
|
+
function isPackageInScope(name) {
|
|
267
|
+
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
268
|
+
}
|
|
255
269
|
async function ensurePackages(packages) {
|
|
256
|
-
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false) {
|
|
270
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false) {
|
|
257
271
|
return;
|
|
258
272
|
}
|
|
259
|
-
const nonExistingPackages = packages.filter((i) => i && !(
|
|
273
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
260
274
|
if (nonExistingPackages.length === 0) {
|
|
261
275
|
return;
|
|
262
276
|
}
|
|
@@ -268,6 +282,18 @@ async function ensurePackages(packages) {
|
|
|
268
282
|
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
269
283
|
}
|
|
270
284
|
}
|
|
285
|
+
function isInEditorEnv() {
|
|
286
|
+
if (import_node_process.default.env.CI) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
if (isInGitHooksOrLintStaged()) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
|
|
293
|
+
}
|
|
294
|
+
function isInGitHooksOrLintStaged() {
|
|
295
|
+
return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
296
|
+
}
|
|
271
297
|
|
|
272
298
|
// src/configs/astro.ts
|
|
273
299
|
async function astro(options = {}) {
|
|
@@ -343,7 +369,7 @@ async function command() {
|
|
|
343
369
|
|
|
344
370
|
// src/plugins.ts
|
|
345
371
|
var import_eslint_plugin_kirklin = __toESM(require("eslint-plugin-kirklin"), 1);
|
|
346
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
372
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
347
373
|
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
348
374
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
349
375
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
@@ -427,21 +453,23 @@ async function stylistic(options = {}) {
|
|
|
427
453
|
// src/configs/formatters.ts
|
|
428
454
|
async function formatters(options = {}, stylistic2 = {}) {
|
|
429
455
|
if (options === true) {
|
|
456
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
430
457
|
options = {
|
|
431
|
-
astro: (
|
|
458
|
+
astro: isPackageInScope("prettier-plugin-astro"),
|
|
432
459
|
css: true,
|
|
433
460
|
graphql: true,
|
|
434
461
|
html: true,
|
|
435
462
|
markdown: true,
|
|
436
463
|
slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli"),
|
|
437
|
-
|
|
464
|
+
svg: isPrettierPluginXmlInScope,
|
|
465
|
+
xml: isPrettierPluginXmlInScope
|
|
438
466
|
};
|
|
439
467
|
}
|
|
440
468
|
await ensurePackages([
|
|
441
469
|
"eslint-plugin-format",
|
|
442
470
|
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
443
471
|
options.astro ? "prettier-plugin-astro" : void 0,
|
|
444
|
-
options.xml ? "@prettier/plugin-xml" : void 0
|
|
472
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
445
473
|
]);
|
|
446
474
|
if (options.slidev && options.markdown !== true && options.markdown !== "prettier") {
|
|
447
475
|
throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
@@ -457,6 +485,7 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
457
485
|
const prettierOptions = Object.assign(
|
|
458
486
|
{
|
|
459
487
|
endOfLine: "auto",
|
|
488
|
+
printWidth: 120,
|
|
460
489
|
semi,
|
|
461
490
|
singleQuote: quotes === "single",
|
|
462
491
|
tabWidth: typeof indent === "number" ? indent : 2,
|
|
@@ -580,6 +609,28 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
580
609
|
}
|
|
581
610
|
});
|
|
582
611
|
}
|
|
612
|
+
if (options.svg) {
|
|
613
|
+
configs2.push({
|
|
614
|
+
files: [GLOB_SVG],
|
|
615
|
+
languageOptions: {
|
|
616
|
+
parser: parserPlain
|
|
617
|
+
},
|
|
618
|
+
name: "kirklin/formatter/svg",
|
|
619
|
+
rules: {
|
|
620
|
+
"format/prettier": [
|
|
621
|
+
"error",
|
|
622
|
+
{
|
|
623
|
+
...prettierXmlOptions,
|
|
624
|
+
...prettierOptions,
|
|
625
|
+
parser: "xml",
|
|
626
|
+
plugins: [
|
|
627
|
+
"@prettier/plugin-xml"
|
|
628
|
+
]
|
|
629
|
+
}
|
|
630
|
+
]
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
583
634
|
if (options.markdown) {
|
|
584
635
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
585
636
|
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
@@ -594,7 +645,6 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
594
645
|
[`format/${formater}`]: [
|
|
595
646
|
"error",
|
|
596
647
|
formater === "prettier" ? {
|
|
597
|
-
printWidth: 120,
|
|
598
648
|
...prettierOptions,
|
|
599
649
|
embeddedLanguageFormatting: "off",
|
|
600
650
|
parser: "markdown"
|
|
@@ -616,7 +666,6 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
616
666
|
"format/prettier": [
|
|
617
667
|
"error",
|
|
618
668
|
{
|
|
619
|
-
printWidth: 120,
|
|
620
669
|
...prettierOptions,
|
|
621
670
|
embeddedLanguageFormatting: "off",
|
|
622
671
|
parser: "slidev",
|
|
@@ -657,7 +706,9 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
657
706
|
"style/block-spacing": "off",
|
|
658
707
|
"style/comma-dangle": "off",
|
|
659
708
|
"style/indent": "off",
|
|
660
|
-
"style/no-multi-spaces": "off"
|
|
709
|
+
"style/no-multi-spaces": "off",
|
|
710
|
+
"style/quotes": "off",
|
|
711
|
+
"style/semi": "off"
|
|
661
712
|
}
|
|
662
713
|
});
|
|
663
714
|
}
|
|
@@ -687,8 +738,6 @@ async function ignores() {
|
|
|
687
738
|
return [
|
|
688
739
|
{
|
|
689
740
|
ignores: GLOB_EXCLUDE
|
|
690
|
-
// Awaits https://github.com/humanwhocodes/config-array/pull/131
|
|
691
|
-
// name: 'kirklin/ignores',
|
|
692
741
|
}
|
|
693
742
|
];
|
|
694
743
|
}
|
|
@@ -1151,6 +1200,7 @@ async function markdown(options = {}) {
|
|
|
1151
1200
|
"ts/no-namespace": "off",
|
|
1152
1201
|
"ts/no-redeclare": "off",
|
|
1153
1202
|
"ts/no-require-imports": "off",
|
|
1203
|
+
"ts/no-unused-expressions": "off",
|
|
1154
1204
|
"ts/no-unused-vars": "off",
|
|
1155
1205
|
"ts/no-use-before-define": "off",
|
|
1156
1206
|
"ts/no-var-requires": "off",
|
|
@@ -1213,7 +1263,7 @@ var NextJsPackages = [
|
|
|
1213
1263
|
];
|
|
1214
1264
|
async function react(options = {}) {
|
|
1215
1265
|
const {
|
|
1216
|
-
files = [
|
|
1266
|
+
files = [GLOB_SRC],
|
|
1217
1267
|
overrides = {}
|
|
1218
1268
|
} = options;
|
|
1219
1269
|
await ensurePackages([
|
|
@@ -1640,6 +1690,7 @@ function sortTsconfig() {
|
|
|
1640
1690
|
"allowSyntheticDefaultImports",
|
|
1641
1691
|
"esModuleInterop",
|
|
1642
1692
|
"forceConsistentCasingInFileNames",
|
|
1693
|
+
"isolatedDeclarations",
|
|
1643
1694
|
"isolatedModules",
|
|
1644
1695
|
"preserveSymlinks",
|
|
1645
1696
|
"verbatimModuleSyntax",
|
|
@@ -1724,11 +1775,15 @@ async function svelte(options = {}) {
|
|
|
1724
1775
|
"svelte/no-useless-mustaches": "error",
|
|
1725
1776
|
"svelte/require-store-callbacks-use-set-param": "error",
|
|
1726
1777
|
"svelte/system": "error",
|
|
1727
|
-
"svelte/valid-compile": "error",
|
|
1728
1778
|
"svelte/valid-each-key": "error",
|
|
1729
1779
|
"unused-imports/no-unused-vars": [
|
|
1730
1780
|
"error",
|
|
1731
|
-
{
|
|
1781
|
+
{
|
|
1782
|
+
args: "after-used",
|
|
1783
|
+
argsIgnorePattern: "^_",
|
|
1784
|
+
vars: "all",
|
|
1785
|
+
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1786
|
+
}
|
|
1732
1787
|
],
|
|
1733
1788
|
...stylistic2 ? {
|
|
1734
1789
|
"style/indent": "off",
|
|
@@ -1762,7 +1817,7 @@ async function test(options = {}) {
|
|
|
1762
1817
|
pluginVitest,
|
|
1763
1818
|
pluginNoOnlyTests
|
|
1764
1819
|
] = await Promise.all([
|
|
1765
|
-
interopDefault(import("eslint-plugin
|
|
1820
|
+
interopDefault(import("@vitest/eslint-plugin")),
|
|
1766
1821
|
// @ts-expect-error missing types
|
|
1767
1822
|
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1768
1823
|
]);
|
|
@@ -1792,6 +1847,7 @@ async function test(options = {}) {
|
|
|
1792
1847
|
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1793
1848
|
"test/prefer-hooks-in-order": "error",
|
|
1794
1849
|
"test/prefer-lowercase-title": "error",
|
|
1850
|
+
"ts/explicit-function-return-type": "off",
|
|
1795
1851
|
...overrides
|
|
1796
1852
|
}
|
|
1797
1853
|
}
|
|
@@ -1863,7 +1919,9 @@ async function typescript(options = {}) {
|
|
|
1863
1919
|
const {
|
|
1864
1920
|
componentExts = [],
|
|
1865
1921
|
overrides = {},
|
|
1866
|
-
|
|
1922
|
+
overridesTypeAware = {},
|
|
1923
|
+
parserOptions = {},
|
|
1924
|
+
type = "app"
|
|
1867
1925
|
} = options;
|
|
1868
1926
|
const files = options.files ?? [
|
|
1869
1927
|
GLOB_TS,
|
|
@@ -1875,19 +1933,17 @@ async function typescript(options = {}) {
|
|
|
1875
1933
|
`${GLOB_MARKDOWN}/**`,
|
|
1876
1934
|
GLOB_ASTRO_TS
|
|
1877
1935
|
];
|
|
1878
|
-
const tsconfigPath = options?.tsconfigPath ?
|
|
1936
|
+
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1879
1937
|
const isTypeAware = !!tsconfigPath;
|
|
1880
1938
|
const typeAwareRules = {
|
|
1881
1939
|
"dot-notation": "off",
|
|
1882
1940
|
"no-implied-eval": "off",
|
|
1883
|
-
"no-throw-literal": "off",
|
|
1884
1941
|
"ts/await-thenable": "error",
|
|
1885
1942
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1886
1943
|
"ts/no-floating-promises": "error",
|
|
1887
1944
|
"ts/no-for-in-array": "error",
|
|
1888
1945
|
"ts/no-implied-eval": "error",
|
|
1889
1946
|
"ts/no-misused-promises": "error",
|
|
1890
|
-
"ts/no-throw-literal": "error",
|
|
1891
1947
|
"ts/no-unnecessary-type-assertion": "error",
|
|
1892
1948
|
"ts/no-unsafe-argument": "error",
|
|
1893
1949
|
"ts/no-unsafe-assignment": "error",
|
|
@@ -1919,7 +1975,10 @@ async function typescript(options = {}) {
|
|
|
1919
1975
|
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
1920
1976
|
sourceType: "module",
|
|
1921
1977
|
...typeAware ? {
|
|
1922
|
-
|
|
1978
|
+
projectService: {
|
|
1979
|
+
allowDefaultProject: ["./*.js"],
|
|
1980
|
+
defaultProject: tsconfigPath
|
|
1981
|
+
},
|
|
1923
1982
|
tsconfigRootDir: import_node_process2.default.cwd()
|
|
1924
1983
|
} : {},
|
|
1925
1984
|
...parserOptions
|
|
@@ -1939,8 +1998,8 @@ async function typescript(options = {}) {
|
|
|
1939
1998
|
},
|
|
1940
1999
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
1941
2000
|
...isTypeAware ? [
|
|
1942
|
-
makeParser(
|
|
1943
|
-
makeParser(
|
|
2001
|
+
makeParser(false, files),
|
|
2002
|
+
makeParser(true, filesTypeAware, ignoresTypeAware)
|
|
1944
2003
|
] : [
|
|
1945
2004
|
makeParser(false, files)
|
|
1946
2005
|
],
|
|
@@ -1961,14 +2020,17 @@ async function typescript(options = {}) {
|
|
|
1961
2020
|
"no-redeclare": "off",
|
|
1962
2021
|
"no-use-before-define": "off",
|
|
1963
2022
|
"no-useless-constructor": "off",
|
|
1964
|
-
"ts/ban-ts-comment": ["error", { "ts-
|
|
1965
|
-
"ts/ban-types": ["error", { types: { Function: false } }],
|
|
2023
|
+
"ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
1966
2024
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1967
|
-
"ts/consistent-type-imports": ["error", {
|
|
2025
|
+
"ts/consistent-type-imports": ["error", {
|
|
2026
|
+
disallowTypeAnnotations: false,
|
|
2027
|
+
prefer: "type-imports"
|
|
2028
|
+
}],
|
|
1968
2029
|
"ts/method-signature-style": ["error", "property"],
|
|
1969
2030
|
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
1970
2031
|
"ts/no-dupe-class-members": "error",
|
|
1971
2032
|
"ts/no-dynamic-delete": "off",
|
|
2033
|
+
"ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
|
|
1972
2034
|
"ts/no-explicit-any": "off",
|
|
1973
2035
|
"ts/no-extraneous-class": "off",
|
|
1974
2036
|
"ts/no-import-type-side-effects": "error",
|
|
@@ -1980,9 +2042,16 @@ async function typescript(options = {}) {
|
|
|
1980
2042
|
"ts/no-unused-vars": "off",
|
|
1981
2043
|
"ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
1982
2044
|
"ts/no-useless-constructor": "off",
|
|
1983
|
-
"ts/
|
|
2045
|
+
"ts/no-wrapper-object-types": "error",
|
|
1984
2046
|
"ts/triple-slash-reference": "off",
|
|
1985
2047
|
"ts/unified-signatures": "off",
|
|
2048
|
+
...type === "lib" ? {
|
|
2049
|
+
"ts/explicit-function-return-type": ["error", {
|
|
2050
|
+
allowExpressions: true,
|
|
2051
|
+
allowHigherOrderFunctions: true,
|
|
2052
|
+
allowIIFEs: true
|
|
2053
|
+
}]
|
|
2054
|
+
} : {},
|
|
1986
2055
|
...overrides
|
|
1987
2056
|
}
|
|
1988
2057
|
},
|
|
@@ -1990,7 +2059,10 @@ async function typescript(options = {}) {
|
|
|
1990
2059
|
files: filesTypeAware,
|
|
1991
2060
|
ignores: ignoresTypeAware,
|
|
1992
2061
|
name: "kirklin/typescript/rules-type-aware",
|
|
1993
|
-
rules:
|
|
2062
|
+
rules: {
|
|
2063
|
+
...typeAwareRules,
|
|
2064
|
+
...overridesTypeAware
|
|
2065
|
+
}
|
|
1994
2066
|
}] : [],
|
|
1995
2067
|
{
|
|
1996
2068
|
files: ["**/*.d.?([cm])ts"],
|
|
@@ -2386,7 +2458,6 @@ function kirklin(options = {}, ...userConfigs) {
|
|
|
2386
2458
|
autoRenamePlugins = true,
|
|
2387
2459
|
componentExts = [],
|
|
2388
2460
|
gitignore: enableGitignore = true,
|
|
2389
|
-
isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.VSCODE_CWD || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM || import_node_process3.default.env.NVIM) && !import_node_process3.default.env.CI),
|
|
2390
2461
|
jsx: enableJsx = true,
|
|
2391
2462
|
react: enableReact = false,
|
|
2392
2463
|
regexp: enableRegexp = true,
|
|
@@ -2396,6 +2467,13 @@ function kirklin(options = {}, ...userConfigs) {
|
|
|
2396
2467
|
unocss: enableUnoCSS = false,
|
|
2397
2468
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2398
2469
|
} = options;
|
|
2470
|
+
let isInEditor = options.isInEditor;
|
|
2471
|
+
if (isInEditor == null) {
|
|
2472
|
+
isInEditor = isInEditorEnv();
|
|
2473
|
+
if (isInEditor) {
|
|
2474
|
+
console.log("[@kirklin/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2399
2477
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2400
2478
|
if (stylisticOptions && !("jsx" in stylisticOptions)) {
|
|
2401
2479
|
stylisticOptions.jsx = enableJsx;
|
|
@@ -2405,9 +2483,7 @@ function kirklin(options = {}, ...userConfigs) {
|
|
|
2405
2483
|
if (typeof enableGitignore !== "boolean") {
|
|
2406
2484
|
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
2407
2485
|
} else {
|
|
2408
|
-
|
|
2409
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
2410
|
-
}
|
|
2486
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
|
|
2411
2487
|
}
|
|
2412
2488
|
}
|
|
2413
2489
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
@@ -2441,7 +2517,8 @@ function kirklin(options = {}, ...userConfigs) {
|
|
|
2441
2517
|
configs2.push(typescript({
|
|
2442
2518
|
...typescriptOptions,
|
|
2443
2519
|
componentExts,
|
|
2444
|
-
overrides: getOverrides(options, "typescript")
|
|
2520
|
+
overrides: getOverrides(options, "typescript"),
|
|
2521
|
+
type: options.type
|
|
2445
2522
|
}));
|
|
2446
2523
|
}
|
|
2447
2524
|
if (stylisticOptions) {
|
|
@@ -2594,6 +2671,7 @@ var src_default = kirklin;
|
|
|
2594
2671
|
GLOB_SRC_EXT,
|
|
2595
2672
|
GLOB_STYLE,
|
|
2596
2673
|
GLOB_SVELTE,
|
|
2674
|
+
GLOB_SVG,
|
|
2597
2675
|
GLOB_TESTS,
|
|
2598
2676
|
GLOB_TOML,
|
|
2599
2677
|
GLOB_TS,
|
|
@@ -2613,6 +2691,9 @@ var src_default = kirklin;
|
|
|
2613
2691
|
ignores,
|
|
2614
2692
|
imports,
|
|
2615
2693
|
interopDefault,
|
|
2694
|
+
isInEditorEnv,
|
|
2695
|
+
isInGitHooksOrLintStaged,
|
|
2696
|
+
isPackageInScope,
|
|
2616
2697
|
javascript,
|
|
2617
2698
|
jsdoc,
|
|
2618
2699
|
jsonc,
|