@coderwyd/eslint-config 4.9.1 → 4.10.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.mjs +1 -1
- package/dist/index.d.mts +783 -1444
- package/dist/index.mjs +38 -50
- package/package.json +23 -25
- /package/bin/{index.js → index.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { fileURLToPath } from "node:url";
|
|
|
11
11
|
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
12
12
|
import globals from "globals";
|
|
13
13
|
import prettierRules from "eslint-config-prettier";
|
|
14
|
-
import { configs } from "eslint-plugin-regexp";
|
|
14
|
+
import { configs as configs$1 } from "eslint-plugin-regexp";
|
|
15
15
|
|
|
16
16
|
//#region src/configs/command.ts
|
|
17
17
|
function command() {
|
|
@@ -122,8 +122,8 @@ const isCwdInScope = isPackageExists("@coderwyd/eslint-config");
|
|
|
122
122
|
/**
|
|
123
123
|
* Combine array and non-array configs into a single array.
|
|
124
124
|
*/
|
|
125
|
-
async function combine(...configs
|
|
126
|
-
return (await Promise.all(configs
|
|
125
|
+
async function combine(...configs) {
|
|
126
|
+
return (await Promise.all(configs)).flat();
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Rename plugin prefixes in a rule object.
|
|
@@ -163,8 +163,8 @@ function renameRules(rules, map) {
|
|
|
163
163
|
* })
|
|
164
164
|
* ```
|
|
165
165
|
*/
|
|
166
|
-
function renamePluginInConfigs(configs
|
|
167
|
-
return configs
|
|
166
|
+
function renamePluginInConfigs(configs, map) {
|
|
167
|
+
return configs.map((i) => {
|
|
168
168
|
const clone = { ...i };
|
|
169
169
|
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
170
170
|
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
@@ -243,7 +243,7 @@ async function imports() {
|
|
|
243
243
|
//#endregion
|
|
244
244
|
//#region src/configs/javascript.ts
|
|
245
245
|
function javascript(options = {}) {
|
|
246
|
-
const { isInEditor
|
|
246
|
+
const { isInEditor = false, overrides = {} } = options;
|
|
247
247
|
return [{
|
|
248
248
|
languageOptions: {
|
|
249
249
|
ecmaVersion: "latest",
|
|
@@ -444,7 +444,7 @@ function javascript(options = {}) {
|
|
|
444
444
|
"require-yield": "error",
|
|
445
445
|
"symbol-description": "error",
|
|
446
446
|
"unicode-bom": ["error", "never"],
|
|
447
|
-
"unused-imports/no-unused-imports": isInEditor
|
|
447
|
+
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
448
448
|
"unused-imports/no-unused-vars": ["error", {
|
|
449
449
|
args: "after-used",
|
|
450
450
|
argsIgnorePattern: "^_",
|
|
@@ -637,10 +637,7 @@ async function pnpm() {
|
|
|
637
637
|
name: "coderwyd/pnpm/pnpm-workspace-yaml",
|
|
638
638
|
plugins: { pnpm: pluginPnpm },
|
|
639
639
|
rules: {
|
|
640
|
-
"pnpm/yaml-enforce-settings": ["error", { settings: {
|
|
641
|
-
shellEmulator: true,
|
|
642
|
-
trustPolicy: "no-downgrade"
|
|
643
|
-
} }],
|
|
640
|
+
"pnpm/yaml-enforce-settings": ["error", { settings: { shellEmulator: true } }],
|
|
644
641
|
"pnpm/yaml-no-duplicate-catalog-item": "error",
|
|
645
642
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
646
643
|
}
|
|
@@ -836,7 +833,7 @@ async function react(options = {}) {
|
|
|
836
833
|
//#endregion
|
|
837
834
|
//#region src/configs/regexp.ts
|
|
838
835
|
function regexp(options = {}) {
|
|
839
|
-
const config = configs["flat/recommended"];
|
|
836
|
+
const config = configs$1["flat/recommended"];
|
|
840
837
|
const rules = { ...config.rules };
|
|
841
838
|
if (options.level === "warn") Object.keys(rules).forEach((key) => {
|
|
842
839
|
if (rules[key] === "error") rules[key] = "warn";
|
|
@@ -1299,7 +1296,7 @@ async function tailwindcss(options = {}) {
|
|
|
1299
1296
|
//#region src/configs/test.ts
|
|
1300
1297
|
let _pluginTest;
|
|
1301
1298
|
async function test(options = {}) {
|
|
1302
|
-
const { files = GLOB_TESTS, isInEditor
|
|
1299
|
+
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
1303
1300
|
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
|
|
1304
1301
|
_pluginTest = _pluginTest || {
|
|
1305
1302
|
...pluginVitest,
|
|
@@ -1322,7 +1319,7 @@ async function test(options = {}) {
|
|
|
1322
1319
|
}],
|
|
1323
1320
|
"test/no-identical-title": "error",
|
|
1324
1321
|
"test/no-import-node-test": "error",
|
|
1325
|
-
"test/no-only-tests": isInEditor
|
|
1322
|
+
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
1326
1323
|
"test/prefer-hooks-in-order": "error",
|
|
1327
1324
|
"test/prefer-lowercase-title": "error",
|
|
1328
1325
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1397,10 +1394,10 @@ async function typescript(options = {}) {
|
|
|
1397
1394
|
"ts/unbound-method": "error"
|
|
1398
1395
|
};
|
|
1399
1396
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1400
|
-
function makeParser(typeAware, files
|
|
1397
|
+
function makeParser(typeAware, files, ignores) {
|
|
1401
1398
|
return {
|
|
1402
|
-
files
|
|
1403
|
-
...ignores
|
|
1399
|
+
files,
|
|
1400
|
+
...ignores ? { ignores } : {},
|
|
1404
1401
|
languageOptions: {
|
|
1405
1402
|
parser: parserTs,
|
|
1406
1403
|
parserOptions: {
|
|
@@ -1646,15 +1643,6 @@ async function vue(options = {}) {
|
|
|
1646
1643
|
"defineSlots"
|
|
1647
1644
|
] }],
|
|
1648
1645
|
"vue/eqeqeq": ["error", "smart"],
|
|
1649
|
-
"vue/html-self-closing": ["error", {
|
|
1650
|
-
html: {
|
|
1651
|
-
component: "always",
|
|
1652
|
-
normal: "always",
|
|
1653
|
-
void: "any"
|
|
1654
|
-
},
|
|
1655
|
-
math: "always",
|
|
1656
|
-
svg: "always"
|
|
1657
|
-
}],
|
|
1658
1646
|
"vue/max-attributes-per-line": "off",
|
|
1659
1647
|
"vue/multi-word-component-names": "off",
|
|
1660
1648
|
"vue/no-constant-condition": "warn",
|
|
@@ -1809,69 +1797,69 @@ const defaultPluginRenaming = {
|
|
|
1809
1797
|
*/
|
|
1810
1798
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
1811
1799
|
const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, pnpm: enableCatalogs = false, react: enableReact = false, regexp: enableRegexp = true, svelte: enableSvelte = false, tailwindcss: enableTailwindCSS = false, typescript: enableTypeScript = isUsingTypeScript, unocss: enableUnoCSS = false, vue: enableVue = isUsingVue } = options;
|
|
1812
|
-
let isInEditor
|
|
1813
|
-
if (isInEditor
|
|
1814
|
-
isInEditor
|
|
1815
|
-
if (isInEditor
|
|
1800
|
+
let isInEditor = options.isInEditor;
|
|
1801
|
+
if (isInEditor == null) {
|
|
1802
|
+
isInEditor = isInEditorEnv();
|
|
1803
|
+
if (isInEditor) console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
|
|
1816
1804
|
}
|
|
1817
|
-
const configs
|
|
1818
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
1805
|
+
const configs = [];
|
|
1806
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
1819
1807
|
...enableGitignore,
|
|
1820
1808
|
name: "coderwyd/gitignore"
|
|
1821
1809
|
})]));
|
|
1822
|
-
else configs
|
|
1810
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
1823
1811
|
name: "coderwyd/gitignore",
|
|
1824
1812
|
strict: false
|
|
1825
1813
|
})]));
|
|
1826
1814
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
1827
1815
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
1828
|
-
configs
|
|
1829
|
-
isInEditor
|
|
1816
|
+
configs.push(ignores(options.ignores), javascript({
|
|
1817
|
+
isInEditor,
|
|
1830
1818
|
overrides: getOverrides(options, "javascript")
|
|
1831
1819
|
}), comments(), node(), jsdoc(), imports(), unicorn(), command(), deMorgan(), perfectionist(), sortPnpmWorkspace());
|
|
1832
1820
|
if (enableVue) componentExts.push("vue");
|
|
1833
|
-
if (enableTypeScript) configs
|
|
1821
|
+
if (enableTypeScript) configs.push(typescript({
|
|
1834
1822
|
...typescriptOptions,
|
|
1835
1823
|
componentExts,
|
|
1836
1824
|
overrides: getOverrides(options, "typescript")
|
|
1837
1825
|
}));
|
|
1838
|
-
if (enableRegexp) configs
|
|
1839
|
-
if (options.test ?? true) configs
|
|
1840
|
-
isInEditor
|
|
1826
|
+
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1827
|
+
if (options.test ?? true) configs.push(test({
|
|
1828
|
+
isInEditor,
|
|
1841
1829
|
overrides: getOverrides(options, "test")
|
|
1842
1830
|
}));
|
|
1843
|
-
if (enableVue) configs
|
|
1831
|
+
if (enableVue) configs.push(vue({
|
|
1844
1832
|
...resolveSubOptions(options, "vue"),
|
|
1845
1833
|
overrides: getOverrides(options, "typescript"),
|
|
1846
1834
|
typescript: !!enableTypeScript
|
|
1847
1835
|
}));
|
|
1848
|
-
if (enableReact) configs
|
|
1836
|
+
if (enableReact) configs.push(react({
|
|
1849
1837
|
overrides: getOverrides(options, "react"),
|
|
1850
1838
|
tsconfigPath
|
|
1851
1839
|
}));
|
|
1852
|
-
if (enableSvelte) configs
|
|
1840
|
+
if (enableSvelte) configs.push(svelte({
|
|
1853
1841
|
overrides: getOverrides(options, "svelte"),
|
|
1854
1842
|
typescript: !!enableTypeScript
|
|
1855
1843
|
}));
|
|
1856
|
-
if (enableUnoCSS) configs
|
|
1844
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
1857
1845
|
...resolveSubOptions(options, "unocss"),
|
|
1858
1846
|
overrides: getOverrides(options, "unocss")
|
|
1859
1847
|
}));
|
|
1860
|
-
if (enableTailwindCSS) configs
|
|
1848
|
+
if (enableTailwindCSS) configs.push(tailwindcss({
|
|
1861
1849
|
...resolveSubOptions(options, "tailwindcss"),
|
|
1862
1850
|
overrides: getOverrides(options, "tailwindcss")
|
|
1863
1851
|
}));
|
|
1864
|
-
if (options.jsonc ?? true) configs
|
|
1865
|
-
if (enableCatalogs) configs
|
|
1866
|
-
if (options.yaml ?? true) configs
|
|
1867
|
-
configs
|
|
1852
|
+
if (options.jsonc ?? true) configs.push(jsonc({ overrides: getOverrides(options, "jsonc") }), sortPackageJson(), sortTsconfig());
|
|
1853
|
+
if (enableCatalogs) configs.push(pnpm());
|
|
1854
|
+
if (options.yaml ?? true) configs.push(yaml({ overrides: getOverrides(options, "yaml") }));
|
|
1855
|
+
configs.push(specials(), prettier());
|
|
1868
1856
|
if ("files" in options) 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.");
|
|
1869
1857
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1870
1858
|
if (key in options) acc[key] = options[key];
|
|
1871
1859
|
return acc;
|
|
1872
1860
|
}, {});
|
|
1873
|
-
if (Object.keys(fusedConfig).length > 0) configs
|
|
1874
|
-
const merged = await combine(...configs
|
|
1861
|
+
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
1862
|
+
const merged = await combine(...configs, ...userConfigs);
|
|
1875
1863
|
if (autoRenamePlugins) return renamePluginInConfigs(merged, defaultPluginRenaming);
|
|
1876
1864
|
return merged;
|
|
1877
1865
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.10.0",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -25,10 +25,8 @@
|
|
|
25
25
|
"./cli": "./dist/cli.mjs",
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
|
-
"main": "./dist/index.mjs",
|
|
29
|
-
"module": "./dist/index.mjs",
|
|
30
28
|
"types": "./dist/index.d.mts",
|
|
31
|
-
"bin": "./bin/index.
|
|
29
|
+
"bin": "./bin/index.mjs",
|
|
32
30
|
"files": [
|
|
33
31
|
"bin",
|
|
34
32
|
"dist"
|
|
@@ -74,10 +72,10 @@
|
|
|
74
72
|
},
|
|
75
73
|
"dependencies": {
|
|
76
74
|
"@antfu/install-pkg": "^1.1.0",
|
|
77
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
79
|
-
"@typescript-eslint/parser": "^8.
|
|
80
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
75
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
77
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
78
|
+
"@vitest/eslint-plugin": "^1.6.6",
|
|
81
79
|
"cac": "^6.7.14",
|
|
82
80
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
83
81
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -87,47 +85,47 @@
|
|
|
87
85
|
"eslint-plugin-import-lite": "^0.5.0",
|
|
88
86
|
"eslint-plugin-jsdoc": "61.4.1",
|
|
89
87
|
"eslint-plugin-jsonc": "^2.21.0",
|
|
90
|
-
"eslint-plugin-n": "^17.23.
|
|
88
|
+
"eslint-plugin-n": "^17.23.2",
|
|
91
89
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
92
|
-
"eslint-plugin-perfectionist": "^5.
|
|
93
|
-
"eslint-plugin-pnpm": "^1.
|
|
94
|
-
"eslint-plugin-regexp": "^
|
|
90
|
+
"eslint-plugin-perfectionist": "^5.4.0",
|
|
91
|
+
"eslint-plugin-pnpm": "^1.5.0",
|
|
92
|
+
"eslint-plugin-regexp": "^3.0.0",
|
|
95
93
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
96
94
|
"eslint-plugin-unused-imports": "^4.3.0",
|
|
97
|
-
"eslint-plugin-vue": "^10.
|
|
98
|
-
"eslint-plugin-yml": "^
|
|
99
|
-
"globals": "^17.
|
|
95
|
+
"eslint-plugin-vue": "^10.7.0",
|
|
96
|
+
"eslint-plugin-yml": "^3.0.0",
|
|
97
|
+
"globals": "^17.1.0",
|
|
100
98
|
"jsonc-eslint-parser": "^2.4.2",
|
|
101
99
|
"local-pkg": "^1.1.2",
|
|
102
100
|
"parse-gitignore": "^2.0.0",
|
|
103
101
|
"prompts": "^2.4.2",
|
|
104
102
|
"vue-eslint-parser": "^10.2.0",
|
|
105
|
-
"yaml-eslint-parser": "^
|
|
103
|
+
"yaml-eslint-parser": "^2.0.0"
|
|
106
104
|
},
|
|
107
105
|
"devDependencies": {
|
|
108
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
106
|
+
"@eslint-react/eslint-plugin": "^2.7.2",
|
|
109
107
|
"@eslint/config-inspector": "^1.4.2",
|
|
110
108
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
111
|
-
"@types/node": "^25.0.
|
|
109
|
+
"@types/node": "^25.0.10",
|
|
112
110
|
"@types/prompts": "^2.4.9",
|
|
113
111
|
"@typescript/native-preview": "7.0.0-dev.20260107.1",
|
|
114
|
-
"@unocss/eslint-plugin": "^66.
|
|
115
|
-
"bumpp": "^10.
|
|
112
|
+
"@unocss/eslint-plugin": "^66.6.0",
|
|
113
|
+
"bumpp": "^10.4.0",
|
|
116
114
|
"eslint": "^9.39.2",
|
|
117
115
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
118
116
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
119
|
-
"eslint-plugin-svelte": "^3.
|
|
117
|
+
"eslint-plugin-svelte": "^3.14.0",
|
|
120
118
|
"eslint-plugin-tailwindcss": "^3.18.2",
|
|
121
119
|
"eslint-typegen": "^2.3.0",
|
|
122
120
|
"jiti": "^2.6.1",
|
|
123
121
|
"nano-staged": "^0.9.0",
|
|
124
|
-
"prettier": "^3.
|
|
125
|
-
"publint": "^0.3.
|
|
122
|
+
"prettier": "^3.8.1",
|
|
123
|
+
"publint": "^0.3.17",
|
|
126
124
|
"simple-git-hooks": "^2.13.1",
|
|
127
125
|
"svelte-eslint-parser": "^1.4.1",
|
|
128
|
-
"tsdown": "^0.
|
|
126
|
+
"tsdown": "^0.20.1",
|
|
129
127
|
"typescript": "^5.9.3",
|
|
130
|
-
"unplugin-unused": "^0.5.
|
|
128
|
+
"unplugin-unused": "^0.5.7"
|
|
131
129
|
},
|
|
132
130
|
"simple-git-hooks": {
|
|
133
131
|
"pre-commit": "pnpm exec nano-staged"
|
|
File without changes
|