@coderwyd/eslint-config 4.0.1 → 4.2.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.js +14 -14
- package/dist/index.d.ts +528 -230
- package/dist/index.js +108 -12
- package/package.json +31 -28
package/dist/index.js
CHANGED
|
@@ -12,11 +12,12 @@ function command() {
|
|
|
12
12
|
// src/plugins/index.ts
|
|
13
13
|
import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
|
|
14
14
|
import { default as default3 } from "eslint-plugin-antfu";
|
|
15
|
+
import { default as default4 } from "eslint-plugin-de-morgan";
|
|
15
16
|
import * as pluginImport from "eslint-plugin-import-x";
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
17
|
+
import { default as default5 } from "eslint-plugin-n";
|
|
18
|
+
import { default as default6 } from "eslint-plugin-perfectionist";
|
|
19
|
+
import { default as default7 } from "eslint-plugin-unicorn";
|
|
20
|
+
import { default as default8 } from "eslint-plugin-unused-imports";
|
|
20
21
|
|
|
21
22
|
// src/configs/comments.ts
|
|
22
23
|
function comments() {
|
|
@@ -36,6 +37,22 @@ function comments() {
|
|
|
36
37
|
];
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
// src/configs/de-morgan.ts
|
|
41
|
+
function deMorgan() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
name: "coderwyd/de-morgan/rules",
|
|
45
|
+
plugins: {
|
|
46
|
+
"de-morgan": default4
|
|
47
|
+
},
|
|
48
|
+
rules: {
|
|
49
|
+
"de-morgan/no-negated-conjunction": "error",
|
|
50
|
+
"de-morgan/no-negated-disjunction": "error"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
// src/constants/glob.ts
|
|
40
57
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
41
58
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
@@ -49,6 +66,7 @@ var GLOB_JSON = "**/*.json";
|
|
|
49
66
|
var GLOB_JSON5 = "**/*.json5";
|
|
50
67
|
var GLOB_JSONC = "**/*.jsonc";
|
|
51
68
|
var GLOB_MARKDOWN = "**/*.md";
|
|
69
|
+
var GLOB_YAML = "**/*.y?(a)ml";
|
|
52
70
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
53
71
|
var GLOB_TESTS = [
|
|
54
72
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -159,7 +177,7 @@ function javascript(options = {}) {
|
|
|
159
177
|
{
|
|
160
178
|
name: "coderwyd/javascript/rules",
|
|
161
179
|
plugins: {
|
|
162
|
-
"unused-imports":
|
|
180
|
+
"unused-imports": default8
|
|
163
181
|
},
|
|
164
182
|
rules: {
|
|
165
183
|
"accessor-pairs": [
|
|
@@ -436,9 +454,9 @@ function resolveSubOptions(options, key) {
|
|
|
436
454
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
437
455
|
}
|
|
438
456
|
function getOverrides(options, key) {
|
|
439
|
-
const
|
|
457
|
+
const subOptions = resolveSubOptions(options, key);
|
|
440
458
|
return {
|
|
441
|
-
..."overrides" in
|
|
459
|
+
..."overrides" in subOptions && subOptions.overrides ? subOptions.overrides : {}
|
|
442
460
|
};
|
|
443
461
|
}
|
|
444
462
|
function isInEditorEnv() {
|
|
@@ -540,7 +558,7 @@ function node() {
|
|
|
540
558
|
{
|
|
541
559
|
name: "coderwyd/node/rules",
|
|
542
560
|
plugins: {
|
|
543
|
-
node:
|
|
561
|
+
node: default5
|
|
544
562
|
},
|
|
545
563
|
rules: {
|
|
546
564
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
@@ -563,7 +581,7 @@ function perfectionist() {
|
|
|
563
581
|
{
|
|
564
582
|
name: "coderwyd/perfectionist/rules",
|
|
565
583
|
plugins: {
|
|
566
|
-
perfectionist:
|
|
584
|
+
perfectionist: default6
|
|
567
585
|
},
|
|
568
586
|
rules: {
|
|
569
587
|
"perfectionist/sort-exports": [
|
|
@@ -896,6 +914,7 @@ function sortPackageJson() {
|
|
|
896
914
|
"husky",
|
|
897
915
|
"simple-git-hooks",
|
|
898
916
|
"lint-staged",
|
|
917
|
+
"nano-staged",
|
|
899
918
|
"eslintConfig"
|
|
900
919
|
],
|
|
901
920
|
pathPattern: "^$"
|
|
@@ -1438,7 +1457,7 @@ function unicorn() {
|
|
|
1438
1457
|
{
|
|
1439
1458
|
name: "coderwyd/unicorn/rules",
|
|
1440
1459
|
plugins: {
|
|
1441
|
-
unicorn:
|
|
1460
|
+
unicorn: default7
|
|
1442
1461
|
},
|
|
1443
1462
|
rules: {
|
|
1444
1463
|
// 'unicorn/better-regex': 'error',
|
|
@@ -1548,7 +1567,7 @@ async function vue(options = {}) {
|
|
|
1548
1567
|
interopDefault(import("vue-eslint-parser"))
|
|
1549
1568
|
]);
|
|
1550
1569
|
const isVue3 = getVueVersion() === 3;
|
|
1551
|
-
const configKeys = isVue3 ? ["
|
|
1570
|
+
const configKeys = isVue3 ? ["essential", "strongly-recommended", "recommended"] : ["vue2-essential", "vue2-strongly-recommended", "vue2-recommended"];
|
|
1552
1571
|
const vueRules = configKeys.reduce((preRules, key) => {
|
|
1553
1572
|
const config = pluginVue.configs[key];
|
|
1554
1573
|
return {
|
|
@@ -1683,6 +1702,75 @@ async function vue(options = {}) {
|
|
|
1683
1702
|
];
|
|
1684
1703
|
}
|
|
1685
1704
|
|
|
1705
|
+
// src/configs/yaml.ts
|
|
1706
|
+
async function yaml(options = {}) {
|
|
1707
|
+
const { files = [GLOB_YAML], overrides = {} } = options;
|
|
1708
|
+
const [pluginYaml, parserYaml] = await Promise.all([
|
|
1709
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1710
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1711
|
+
]);
|
|
1712
|
+
return [
|
|
1713
|
+
{
|
|
1714
|
+
name: "coderwyd/yaml/setup",
|
|
1715
|
+
plugins: {
|
|
1716
|
+
yaml: pluginYaml
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
files,
|
|
1721
|
+
languageOptions: {
|
|
1722
|
+
parser: parserYaml
|
|
1723
|
+
},
|
|
1724
|
+
name: "coderwyd/yaml/rules",
|
|
1725
|
+
rules: {
|
|
1726
|
+
"yaml/block-mapping": "error",
|
|
1727
|
+
"yaml/block-sequence": "error",
|
|
1728
|
+
"yaml/no-empty-key": "error",
|
|
1729
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
1730
|
+
"yaml/no-irregular-whitespace": "error",
|
|
1731
|
+
"yaml/plain-scalar": "error",
|
|
1732
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
1733
|
+
...overrides
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
{
|
|
1737
|
+
files: ["pnpm-workspace.yaml"],
|
|
1738
|
+
name: "coderwyd/yaml/pnpm-workspace",
|
|
1739
|
+
rules: {
|
|
1740
|
+
"yaml/sort-keys": [
|
|
1741
|
+
"error",
|
|
1742
|
+
{
|
|
1743
|
+
order: [
|
|
1744
|
+
"packages",
|
|
1745
|
+
"overrides",
|
|
1746
|
+
"patchedDependencies",
|
|
1747
|
+
"hoistPattern",
|
|
1748
|
+
"catalog",
|
|
1749
|
+
"catalogs",
|
|
1750
|
+
"allowedDeprecatedVersions",
|
|
1751
|
+
"allowNonAppliedPatches",
|
|
1752
|
+
"configDependencies",
|
|
1753
|
+
"ignoredBuiltDependencies",
|
|
1754
|
+
"ignoredOptionalDependencies",
|
|
1755
|
+
"neverBuiltDependencies",
|
|
1756
|
+
"onlyBuiltDependencies",
|
|
1757
|
+
"onlyBuiltDependenciesFile",
|
|
1758
|
+
"packageExtensions",
|
|
1759
|
+
"peerDependencyRules",
|
|
1760
|
+
"supportedArchitectures"
|
|
1761
|
+
],
|
|
1762
|
+
pathPattern: "^$"
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
order: { type: "asc" },
|
|
1766
|
+
pathPattern: ".*"
|
|
1767
|
+
}
|
|
1768
|
+
]
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
];
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1686
1774
|
// src/index.ts
|
|
1687
1775
|
var flatConfigProps = [
|
|
1688
1776
|
"name",
|
|
@@ -1758,8 +1846,9 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1758
1846
|
imports(),
|
|
1759
1847
|
unicorn(),
|
|
1760
1848
|
command(),
|
|
1761
|
-
|
|
1849
|
+
deMorgan(),
|
|
1762
1850
|
perfectionist()
|
|
1851
|
+
// Optional plugins (installed but not enabled by default)
|
|
1763
1852
|
);
|
|
1764
1853
|
if (enableVue) componentExts.push("vue");
|
|
1765
1854
|
if (enableTypeScript) {
|
|
@@ -1831,6 +1920,13 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1831
1920
|
sortTsconfig()
|
|
1832
1921
|
);
|
|
1833
1922
|
}
|
|
1923
|
+
if (options.yaml ?? true) {
|
|
1924
|
+
configs2.push(
|
|
1925
|
+
yaml({
|
|
1926
|
+
overrides: getOverrides(options, "yaml")
|
|
1927
|
+
})
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1834
1930
|
configs2.push(specials(), prettier());
|
|
1835
1931
|
if ("files" in options) {
|
|
1836
1932
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,58 +69,61 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@antfu/install-pkg": "^1.0.0",
|
|
71
71
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
73
|
-
"@typescript-eslint/parser": "^8.
|
|
74
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
73
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
74
|
+
"@vitest/eslint-plugin": "^1.1.38",
|
|
75
75
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
76
|
-
"eslint-config-prettier": "^10.
|
|
77
|
-
"eslint-plugin-antfu": "^3.1.
|
|
76
|
+
"eslint-config-prettier": "^10.1.1",
|
|
77
|
+
"eslint-plugin-antfu": "^3.1.1",
|
|
78
78
|
"eslint-plugin-command": "^3.1.0",
|
|
79
|
+
"eslint-plugin-de-morgan": "^1.2.1",
|
|
79
80
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
80
|
-
"eslint-plugin-import-x": "^4.
|
|
81
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
81
|
+
"eslint-plugin-import-x": "^4.8.0",
|
|
82
|
+
"eslint-plugin-jsdoc": "^50.6.8",
|
|
82
83
|
"eslint-plugin-jsonc": "^2.19.1",
|
|
83
|
-
"eslint-plugin-n": "^17.
|
|
84
|
+
"eslint-plugin-n": "^17.16.2",
|
|
84
85
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
85
|
-
"eslint-plugin-perfectionist": "^4.
|
|
86
|
+
"eslint-plugin-perfectionist": "^4.10.1",
|
|
86
87
|
"eslint-plugin-regexp": "^2.7.0",
|
|
87
88
|
"eslint-plugin-unicorn": "^57.0.0",
|
|
88
89
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
89
|
-
"eslint-plugin-vue": "^
|
|
90
|
-
"eslint-
|
|
90
|
+
"eslint-plugin-vue": "^10.0.0",
|
|
91
|
+
"eslint-plugin-yml": "^1.17.0",
|
|
92
|
+
"eslint-typegen": "^2.1.0",
|
|
91
93
|
"globals": "^16.0.0",
|
|
92
94
|
"jsonc-eslint-parser": "^2.4.0",
|
|
93
|
-
"local-pkg": "^1.
|
|
95
|
+
"local-pkg": "^1.1.1",
|
|
94
96
|
"parse-gitignore": "^2.0.0",
|
|
95
97
|
"picocolors": "^1.1.1",
|
|
96
|
-
"prettier": "^3.5.
|
|
98
|
+
"prettier": "^3.5.3",
|
|
97
99
|
"prompts": "^2.4.2",
|
|
98
|
-
"vue-eslint-parser": "^
|
|
100
|
+
"vue-eslint-parser": "^10.1.1",
|
|
101
|
+
"yaml-eslint-parser": "^1.3.0",
|
|
99
102
|
"yargs": "^17.7.2"
|
|
100
103
|
},
|
|
101
104
|
"devDependencies": {
|
|
102
|
-
"@antfu/ni": "^
|
|
103
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
104
|
-
"@eslint/config-inspector": "^1.0.
|
|
105
|
+
"@antfu/ni": "^24.2.0",
|
|
106
|
+
"@eslint-react/eslint-plugin": "^1.35.0",
|
|
107
|
+
"@eslint/config-inspector": "^1.0.2",
|
|
105
108
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
106
|
-
"@types/node": "^22.13.
|
|
109
|
+
"@types/node": "^22.13.10",
|
|
107
110
|
"@types/prompts": "^2.4.9",
|
|
108
111
|
"@types/yargs": "^17.0.33",
|
|
109
|
-
"@unocss/eslint-plugin": "^66.0.
|
|
110
|
-
"bumpp": "^10.0
|
|
111
|
-
"eslint": "^9.
|
|
112
|
+
"@unocss/eslint-plugin": "^66.1.0-beta.5",
|
|
113
|
+
"bumpp": "^10.1.0",
|
|
114
|
+
"eslint": "^9.22.0",
|
|
112
115
|
"eslint-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
|
|
113
|
-
"eslint-plugin-react-hooks": "^5.
|
|
116
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
114
117
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
115
|
-
"eslint-plugin-svelte": "^
|
|
118
|
+
"eslint-plugin-svelte": "^3.3.0",
|
|
116
119
|
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
117
120
|
"jiti": "^2.4.2",
|
|
118
121
|
"nano-staged": "^0.8.0",
|
|
119
122
|
"simple-git-hooks": "^2.11.1",
|
|
120
|
-
"svelte": "^5.
|
|
121
|
-
"svelte-eslint-parser": "^
|
|
122
|
-
"tsup": "^8.
|
|
123
|
-
"typescript": "^5.
|
|
123
|
+
"svelte": "^5.23.1",
|
|
124
|
+
"svelte-eslint-parser": "^1.1.0",
|
|
125
|
+
"tsup": "^8.4.0",
|
|
126
|
+
"typescript": "^5.8.2"
|
|
124
127
|
},
|
|
125
128
|
"simple-git-hooks": {
|
|
126
129
|
"pre-commit": "pnpm exec nano-staged"
|