@coderwyd/eslint-config 2.6.4 → 2.7.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/dist/cli.cjs +16 -15
- package/dist/cli.js +16 -15
- package/dist/index.cjs +55 -19
- package/dist/index.d.cts +151 -74
- package/dist/index.d.ts +151 -74
- package/dist/index.js +48 -19
- package/package.json +32 -30
package/dist/cli.cjs
CHANGED
|
@@ -37,34 +37,35 @@ var import_helpers = require("yargs/helpers");
|
|
|
37
37
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
38
38
|
|
|
39
39
|
// package.json
|
|
40
|
-
var version = "2.
|
|
40
|
+
var version = "2.7.0";
|
|
41
41
|
var devDependencies = {
|
|
42
|
-
"@antfu/ni": "^0.
|
|
43
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
44
|
-
"@eslint/config-inspector": "^0.5.
|
|
45
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
46
|
-
"@types/eslint": "^9.6.
|
|
42
|
+
"@antfu/ni": "^0.23.0",
|
|
43
|
+
"@eslint-react/eslint-plugin": "^1.12.3",
|
|
44
|
+
"@eslint/config-inspector": "^0.5.4",
|
|
45
|
+
"@stylistic/eslint-plugin-migrate": "^2.7.1",
|
|
46
|
+
"@types/eslint": "^9.6.1",
|
|
47
47
|
"@types/fs-extra": "^11.0.4",
|
|
48
|
-
"@types/node": "^20.
|
|
48
|
+
"@types/node": "^20.16.2",
|
|
49
49
|
"@types/prompts": "^2.4.9",
|
|
50
50
|
"@types/yargs": "^17.0.33",
|
|
51
|
-
"@unocss/eslint-plugin": "^0.
|
|
52
|
-
bumpp: "^9.
|
|
53
|
-
eslint: "^9.9.
|
|
51
|
+
"@unocss/eslint-plugin": "^0.62.3",
|
|
52
|
+
bumpp: "^9.5.2",
|
|
53
|
+
eslint: "^9.9.1",
|
|
54
54
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
55
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
55
|
+
"eslint-plugin-react-refresh": "^0.4.11",
|
|
56
56
|
"eslint-plugin-svelte": "2.43.0",
|
|
57
57
|
"eslint-plugin-tailwindcss": "^3.17.4",
|
|
58
|
-
execa: "^9.3.
|
|
58
|
+
execa: "^9.3.1",
|
|
59
59
|
"fast-glob": "^3.3.2",
|
|
60
60
|
"fs-extra": "^11.2.0",
|
|
61
|
-
|
|
61
|
+
jiti: "^1.21.6",
|
|
62
|
+
"lint-staged": "^15.2.9",
|
|
62
63
|
rimraf: "^6.0.1",
|
|
63
64
|
"simple-git-hooks": "^2.11.1",
|
|
64
|
-
svelte: "^4.2.
|
|
65
|
+
svelte: "^4.2.19",
|
|
65
66
|
"svelte-eslint-parser": "^0.41.0",
|
|
66
67
|
tsup: "^8.2.4",
|
|
67
|
-
tsx: "^4.
|
|
68
|
+
tsx: "^4.19.0",
|
|
68
69
|
typescript: "^5.5.4"
|
|
69
70
|
};
|
|
70
71
|
|
package/dist/cli.js
CHANGED
|
@@ -8,34 +8,35 @@ import { hideBin } from "yargs/helpers";
|
|
|
8
8
|
import c from "picocolors";
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "2.
|
|
11
|
+
var version = "2.7.0";
|
|
12
12
|
var devDependencies = {
|
|
13
|
-
"@antfu/ni": "^0.
|
|
14
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
15
|
-
"@eslint/config-inspector": "^0.5.
|
|
16
|
-
"@stylistic/eslint-plugin-migrate": "^2.
|
|
17
|
-
"@types/eslint": "^9.6.
|
|
13
|
+
"@antfu/ni": "^0.23.0",
|
|
14
|
+
"@eslint-react/eslint-plugin": "^1.12.3",
|
|
15
|
+
"@eslint/config-inspector": "^0.5.4",
|
|
16
|
+
"@stylistic/eslint-plugin-migrate": "^2.7.1",
|
|
17
|
+
"@types/eslint": "^9.6.1",
|
|
18
18
|
"@types/fs-extra": "^11.0.4",
|
|
19
|
-
"@types/node": "^20.
|
|
19
|
+
"@types/node": "^20.16.2",
|
|
20
20
|
"@types/prompts": "^2.4.9",
|
|
21
21
|
"@types/yargs": "^17.0.33",
|
|
22
|
-
"@unocss/eslint-plugin": "^0.
|
|
23
|
-
bumpp: "^9.
|
|
24
|
-
eslint: "^9.9.
|
|
22
|
+
"@unocss/eslint-plugin": "^0.62.3",
|
|
23
|
+
bumpp: "^9.5.2",
|
|
24
|
+
eslint: "^9.9.1",
|
|
25
25
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
26
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
26
|
+
"eslint-plugin-react-refresh": "^0.4.11",
|
|
27
27
|
"eslint-plugin-svelte": "2.43.0",
|
|
28
28
|
"eslint-plugin-tailwindcss": "^3.17.4",
|
|
29
|
-
execa: "^9.3.
|
|
29
|
+
execa: "^9.3.1",
|
|
30
30
|
"fast-glob": "^3.3.2",
|
|
31
31
|
"fs-extra": "^11.2.0",
|
|
32
|
-
|
|
32
|
+
jiti: "^1.21.6",
|
|
33
|
+
"lint-staged": "^15.2.9",
|
|
33
34
|
rimraf: "^6.0.1",
|
|
34
35
|
"simple-git-hooks": "^2.11.1",
|
|
35
|
-
svelte: "^4.2.
|
|
36
|
+
svelte: "^4.2.19",
|
|
36
37
|
"svelte-eslint-parser": "^0.41.0",
|
|
37
38
|
tsup: "^8.2.4",
|
|
38
|
-
tsx: "^4.
|
|
39
|
+
tsx: "^4.19.0",
|
|
39
40
|
typescript: "^5.5.4"
|
|
40
41
|
};
|
|
41
42
|
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,9 @@ __export(src_exports, {
|
|
|
37
37
|
getOverrides: () => getOverrides,
|
|
38
38
|
getVueVersion: () => getVueVersion,
|
|
39
39
|
interopDefault: () => interopDefault,
|
|
40
|
+
isInEditorEnv: () => isInEditorEnv,
|
|
41
|
+
isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
|
|
42
|
+
isPackageInScope: () => isPackageInScope,
|
|
40
43
|
parserPlain: () => parserPlain,
|
|
41
44
|
renamePluginInConfigs: () => renamePluginInConfigs,
|
|
42
45
|
renameRules: () => renameRules,
|
|
@@ -45,9 +48,13 @@ __export(src_exports, {
|
|
|
45
48
|
});
|
|
46
49
|
module.exports = __toCommonJS(src_exports);
|
|
47
50
|
|
|
51
|
+
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.39_tsx@4.19.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
52
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
53
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
54
|
+
|
|
48
55
|
// src/plugins/index.ts
|
|
49
56
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
50
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
57
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
51
58
|
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
52
59
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
53
60
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
@@ -137,10 +144,14 @@ var GLOB_EXCLUDE = [
|
|
|
137
144
|
];
|
|
138
145
|
|
|
139
146
|
// src/configs/ignores.ts
|
|
140
|
-
function ignores() {
|
|
147
|
+
function ignores(userIgnores = []) {
|
|
141
148
|
return [
|
|
142
149
|
{
|
|
143
|
-
ignores:
|
|
150
|
+
ignores: [
|
|
151
|
+
...GLOB_EXCLUDE,
|
|
152
|
+
...userIgnores
|
|
153
|
+
],
|
|
154
|
+
name: "coderwyd/ignores"
|
|
144
155
|
}
|
|
145
156
|
];
|
|
146
157
|
}
|
|
@@ -315,9 +326,6 @@ function javascript(options = {}) {
|
|
|
315
326
|
],
|
|
316
327
|
"no-restricted-syntax": [
|
|
317
328
|
"error",
|
|
318
|
-
"DebuggerStatement",
|
|
319
|
-
"LabeledStatement",
|
|
320
|
-
"WithStatement",
|
|
321
329
|
"TSEnumDeclaration[const=true]",
|
|
322
330
|
"TSExportAssignment"
|
|
323
331
|
],
|
|
@@ -433,7 +441,10 @@ function javascript(options = {}) {
|
|
|
433
441
|
|
|
434
442
|
// src/shared/index.ts
|
|
435
443
|
var import_node_process = __toESM(require("process"), 1);
|
|
444
|
+
var import_node_url = require("url");
|
|
436
445
|
var import_local_pkg = require("local-pkg");
|
|
446
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
447
|
+
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
|
|
437
448
|
var parserPlain = {
|
|
438
449
|
meta: {
|
|
439
450
|
name: "parser-plain"
|
|
@@ -499,10 +510,13 @@ async function interopDefault(m) {
|
|
|
499
510
|
const resolved = await m;
|
|
500
511
|
return resolved.default || resolved;
|
|
501
512
|
}
|
|
513
|
+
function isPackageInScope(name) {
|
|
514
|
+
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
515
|
+
}
|
|
502
516
|
async function ensurePackages(packages) {
|
|
503
|
-
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false)
|
|
517
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
|
|
504
518
|
return;
|
|
505
|
-
const nonExistingPackages = packages.filter((i) => !(
|
|
519
|
+
const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
|
|
506
520
|
if (nonExistingPackages.length === 0)
|
|
507
521
|
return;
|
|
508
522
|
const { default: prompts } = await import("prompts");
|
|
@@ -528,6 +542,16 @@ function getOverrides(options, key) {
|
|
|
528
542
|
..."overrides" in sub ? sub.overrides || {} : {}
|
|
529
543
|
};
|
|
530
544
|
}
|
|
545
|
+
function isInEditorEnv() {
|
|
546
|
+
if (import_node_process.default.env.CI)
|
|
547
|
+
return false;
|
|
548
|
+
if (isInGitHooksOrLintStaged())
|
|
549
|
+
return false;
|
|
550
|
+
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 || false);
|
|
551
|
+
}
|
|
552
|
+
function isInGitHooksOrLintStaged() {
|
|
553
|
+
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") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
|
|
554
|
+
}
|
|
531
555
|
|
|
532
556
|
// src/configs/jsdoc.ts
|
|
533
557
|
async function jsdoc(options = {}) {
|
|
@@ -942,7 +966,7 @@ async function stylistic(options = {}) {
|
|
|
942
966
|
// src/configs/typescript.ts
|
|
943
967
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
944
968
|
async function typescript(options = {}) {
|
|
945
|
-
const { componentExts = [], overrides = {}, parserOptions = {} } = options;
|
|
969
|
+
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {} } = options;
|
|
946
970
|
const files = options.files ?? [
|
|
947
971
|
GLOB_TS,
|
|
948
972
|
GLOB_TSX,
|
|
@@ -1015,8 +1039,8 @@ async function typescript(options = {}) {
|
|
|
1015
1039
|
},
|
|
1016
1040
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
1017
1041
|
...isTypeAware ? [
|
|
1018
|
-
makeParser(
|
|
1019
|
-
makeParser(
|
|
1042
|
+
makeParser(false, files),
|
|
1043
|
+
makeParser(true, filesTypeAware, ignoresTypeAware)
|
|
1020
1044
|
] : [makeParser(false, files)],
|
|
1021
1045
|
{
|
|
1022
1046
|
files,
|
|
@@ -1083,8 +1107,8 @@ async function typescript(options = {}) {
|
|
|
1083
1107
|
ignores: ignoresTypeAware,
|
|
1084
1108
|
name: "coderwyd/typescript/rules-type-aware",
|
|
1085
1109
|
rules: {
|
|
1086
|
-
...
|
|
1087
|
-
...
|
|
1110
|
+
...typeAwareRules,
|
|
1111
|
+
...overridesTypeAware
|
|
1088
1112
|
}
|
|
1089
1113
|
}
|
|
1090
1114
|
] : [],
|
|
@@ -1971,8 +1995,6 @@ function jsx() {
|
|
|
1971
1995
|
// src/index.ts
|
|
1972
1996
|
var flatConfigProps = [
|
|
1973
1997
|
"name",
|
|
1974
|
-
"files",
|
|
1975
|
-
"ignores",
|
|
1976
1998
|
"languageOptions",
|
|
1977
1999
|
"linterOptions",
|
|
1978
2000
|
"processor",
|
|
@@ -2001,7 +2023,6 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2001
2023
|
html: true
|
|
2002
2024
|
},
|
|
2003
2025
|
gitignore: enableGitignore = true,
|
|
2004
|
-
isInEditor: isInEditor2 = isInEditor,
|
|
2005
2026
|
jsx: enableJsx = true,
|
|
2006
2027
|
react: enableReact = false,
|
|
2007
2028
|
regexp: enableRegexp = true,
|
|
@@ -2011,6 +2032,12 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2011
2032
|
unocss: enableUnoCSS = false,
|
|
2012
2033
|
vue: enableVue = hasVue
|
|
2013
2034
|
} = options;
|
|
2035
|
+
let isInEditor2 = options.isInEditor;
|
|
2036
|
+
if (isInEditor2 == null) {
|
|
2037
|
+
isInEditor2 = isInEditorEnv();
|
|
2038
|
+
if (isInEditor2)
|
|
2039
|
+
console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2040
|
+
}
|
|
2014
2041
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2015
2042
|
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2016
2043
|
stylisticOptions.jsx = enableJsx;
|
|
@@ -2019,17 +2046,20 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2019
2046
|
if (typeof enableGitignore !== "boolean") {
|
|
2020
2047
|
configs2.push(
|
|
2021
2048
|
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
2022
|
-
r(
|
|
2049
|
+
r({
|
|
2050
|
+
...enableGitignore,
|
|
2051
|
+
name: "coderwyd/gitignore"
|
|
2052
|
+
})
|
|
2023
2053
|
])
|
|
2024
2054
|
);
|
|
2025
2055
|
} else {
|
|
2026
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
|
|
2056
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ name: "coderwyd/gitignore", strict: false })]));
|
|
2027
2057
|
}
|
|
2028
2058
|
}
|
|
2029
2059
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2030
2060
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2031
2061
|
configs2.push(
|
|
2032
|
-
ignores(),
|
|
2062
|
+
ignores(options.ignores),
|
|
2033
2063
|
javascript({
|
|
2034
2064
|
isInEditor: isInEditor2,
|
|
2035
2065
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2140,6 +2170,9 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2140
2170
|
)
|
|
2141
2171
|
);
|
|
2142
2172
|
}
|
|
2173
|
+
if ("files" in options) {
|
|
2174
|
+
throw new Error('[@coderwyd/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
|
|
2175
|
+
}
|
|
2143
2176
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2144
2177
|
if (key in options)
|
|
2145
2178
|
acc[key] = options[key];
|
|
@@ -2161,6 +2194,9 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2161
2194
|
getOverrides,
|
|
2162
2195
|
getVueVersion,
|
|
2163
2196
|
interopDefault,
|
|
2197
|
+
isInEditorEnv,
|
|
2198
|
+
isInGitHooksOrLintStaged,
|
|
2199
|
+
isPackageInScope,
|
|
2164
2200
|
parserPlain,
|
|
2165
2201
|
renamePluginInConfigs,
|
|
2166
2202
|
renameRules,
|