@coderwyd/eslint-config 4.1.1 → 4.2.1
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 +12 -12
- package/dist/index.d.ts +690 -451
- package/dist/index.js +138 -52
- package/package.json +30 -28
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ var GLOB_JSON = "**/*.json";
|
|
|
66
66
|
var GLOB_JSON5 = "**/*.json5";
|
|
67
67
|
var GLOB_JSONC = "**/*.jsonc";
|
|
68
68
|
var GLOB_MARKDOWN = "**/*.md";
|
|
69
|
+
var GLOB_YAML = "**/*.y?(a)ml";
|
|
69
70
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
70
71
|
var GLOB_TESTS = [
|
|
71
72
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -133,6 +134,7 @@ function imports() {
|
|
|
133
134
|
"antfu/no-import-node-modules-by-path": "error",
|
|
134
135
|
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
135
136
|
"import/first": "error",
|
|
137
|
+
"import/newline-after-import": ["error", { count: 1 }],
|
|
136
138
|
"import/no-duplicates": "error",
|
|
137
139
|
"import/no-mutable-exports": "error",
|
|
138
140
|
"import/no-named-default": "error",
|
|
@@ -726,22 +728,73 @@ async function react(options = {}) {
|
|
|
726
728
|
name: "coderwyd/react/rules",
|
|
727
729
|
rules: {
|
|
728
730
|
"react-compiler/react-compiler": "warn",
|
|
729
|
-
// recommended rules from
|
|
730
|
-
"react
|
|
731
|
+
// recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
|
|
732
|
+
"react/no-access-state-in-setstate": "error",
|
|
733
|
+
"react/no-array-index-key": "warn",
|
|
734
|
+
"react/no-children-count": "warn",
|
|
735
|
+
"react/no-children-for-each": "warn",
|
|
736
|
+
"react/no-children-map": "warn",
|
|
737
|
+
"react/no-children-only": "warn",
|
|
738
|
+
"react/no-children-to-array": "warn",
|
|
739
|
+
"react/no-clone-element": "warn",
|
|
740
|
+
"react/no-comment-textnodes": "warn",
|
|
741
|
+
"react/no-component-will-mount": "error",
|
|
742
|
+
"react/no-component-will-receive-props": "error",
|
|
743
|
+
"react/no-component-will-update": "error",
|
|
744
|
+
"react/no-context-provider": "warn",
|
|
745
|
+
"react/no-create-ref": "error",
|
|
746
|
+
"react/no-default-props": "error",
|
|
747
|
+
"react/no-direct-mutation-state": "error",
|
|
748
|
+
"react/no-duplicate-jsx-props": "warn",
|
|
749
|
+
"react/no-duplicate-key": "warn",
|
|
750
|
+
"react/no-forward-ref": "warn",
|
|
751
|
+
"react/no-implicit-key": "warn",
|
|
752
|
+
"react/no-missing-key": "error",
|
|
753
|
+
"react/no-nested-component-definitions": "error",
|
|
754
|
+
"react/no-prop-types": "error",
|
|
755
|
+
"react/no-redundant-should-component-update": "error",
|
|
756
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
757
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
758
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
759
|
+
"react/no-string-refs": "error",
|
|
760
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
761
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
762
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
763
|
+
"react/no-unstable-context-value": "warn",
|
|
764
|
+
"react/no-unstable-default-props": "warn",
|
|
765
|
+
"react/no-unused-class-component-members": "warn",
|
|
766
|
+
"react/no-unused-state": "warn",
|
|
767
|
+
"react/no-use-context": "warn",
|
|
768
|
+
"react/no-useless-forward-ref": "warn",
|
|
769
|
+
"react/use-jsx-vars": "warn",
|
|
770
|
+
// recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
|
|
731
771
|
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
732
772
|
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
733
773
|
"react-dom/no-find-dom-node": "error",
|
|
774
|
+
"react-dom/no-flush-sync": "error",
|
|
775
|
+
"react-dom/no-hydrate": "error",
|
|
734
776
|
"react-dom/no-missing-button-type": "warn",
|
|
735
777
|
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
736
778
|
"react-dom/no-namespace": "error",
|
|
779
|
+
"react-dom/no-render": "error",
|
|
737
780
|
"react-dom/no-render-return-value": "error",
|
|
738
781
|
"react-dom/no-script-url": "warn",
|
|
739
782
|
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
740
783
|
"react-dom/no-unsafe-target-blank": "warn",
|
|
741
|
-
|
|
784
|
+
"react-dom/no-use-form-state": "error",
|
|
785
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
786
|
+
// recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
|
|
742
787
|
"react-hooks/exhaustive-deps": "warn",
|
|
743
788
|
"react-hooks/rules-of-hooks": "error",
|
|
744
|
-
// react
|
|
789
|
+
// recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
|
|
790
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
791
|
+
"react-hooks-extra/no-unnecessary-use-prefix": "warn",
|
|
792
|
+
// recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
|
|
793
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
794
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
795
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
796
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
797
|
+
// preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
|
|
745
798
|
"react-refresh/only-export-components": [
|
|
746
799
|
"warn",
|
|
747
800
|
{
|
|
@@ -766,52 +819,6 @@ async function react(options = {}) {
|
|
|
766
819
|
]
|
|
767
820
|
}
|
|
768
821
|
],
|
|
769
|
-
// recommended rules from @eslint-react/web-api
|
|
770
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
771
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
772
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
773
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
774
|
-
// recommended rules from @eslint-react
|
|
775
|
-
"react/ensure-forward-ref-using-ref": "warn",
|
|
776
|
-
"react/jsx-no-duplicate-props": "warn",
|
|
777
|
-
"react/jsx-uses-vars": "warn",
|
|
778
|
-
"react/no-access-state-in-setstate": "error",
|
|
779
|
-
"react/no-array-index-key": "warn",
|
|
780
|
-
"react/no-children-count": "warn",
|
|
781
|
-
"react/no-children-for-each": "warn",
|
|
782
|
-
"react/no-children-map": "warn",
|
|
783
|
-
"react/no-children-only": "warn",
|
|
784
|
-
"react/no-children-to-array": "warn",
|
|
785
|
-
"react/no-clone-element": "warn",
|
|
786
|
-
"react/no-comment-textnodes": "warn",
|
|
787
|
-
"react/no-component-will-mount": "error",
|
|
788
|
-
"react/no-component-will-receive-props": "error",
|
|
789
|
-
"react/no-component-will-update": "error",
|
|
790
|
-
"react/no-context-provider": "warn",
|
|
791
|
-
"react/no-create-ref": "error",
|
|
792
|
-
"react/no-default-props": "error",
|
|
793
|
-
"react/no-direct-mutation-state": "error",
|
|
794
|
-
"react/no-duplicate-key": "error",
|
|
795
|
-
"react/no-forward-ref": "warn",
|
|
796
|
-
"react/no-implicit-key": "warn",
|
|
797
|
-
"react/no-missing-key": "error",
|
|
798
|
-
"react/no-nested-components": "error",
|
|
799
|
-
"react/no-prop-types": "error",
|
|
800
|
-
"react/no-redundant-should-component-update": "error",
|
|
801
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
802
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
803
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
804
|
-
"react/no-string-refs": "error",
|
|
805
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
806
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
807
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
808
|
-
"react/no-unstable-context-value": "warn",
|
|
809
|
-
"react/no-unstable-default-props": "warn",
|
|
810
|
-
"react/no-unused-class-component-members": "warn",
|
|
811
|
-
"react/no-unused-state": "warn",
|
|
812
|
-
"react/prefer-destructuring-assignment": "warn",
|
|
813
|
-
"react/prefer-shorthand-boolean": "warn",
|
|
814
|
-
"react/prefer-shorthand-fragment": "warn",
|
|
815
822
|
// overrides
|
|
816
823
|
...overrides
|
|
817
824
|
}
|
|
@@ -820,7 +827,7 @@ async function react(options = {}) {
|
|
|
820
827
|
{
|
|
821
828
|
files: filesTypeAware,
|
|
822
829
|
ignores: ignoresTypeAware,
|
|
823
|
-
name: "
|
|
830
|
+
name: "antfu/react/type-aware-rules",
|
|
824
831
|
rules: {
|
|
825
832
|
...typeAwareRules
|
|
826
833
|
}
|
|
@@ -913,6 +920,7 @@ function sortPackageJson() {
|
|
|
913
920
|
"husky",
|
|
914
921
|
"simple-git-hooks",
|
|
915
922
|
"lint-staged",
|
|
923
|
+
"nano-staged",
|
|
916
924
|
"eslintConfig"
|
|
917
925
|
],
|
|
918
926
|
pathPattern: "^$"
|
|
@@ -991,6 +999,7 @@ function sortTsconfig() {
|
|
|
991
999
|
"useDefineForClassFields",
|
|
992
1000
|
"emitDecoratorMetadata",
|
|
993
1001
|
"experimentalDecorators",
|
|
1002
|
+
"libReplacement",
|
|
994
1003
|
/* Modules */
|
|
995
1004
|
"baseUrl",
|
|
996
1005
|
"rootDir",
|
|
@@ -1065,6 +1074,7 @@ function sortTsconfig() {
|
|
|
1065
1074
|
"isolatedModules",
|
|
1066
1075
|
"preserveSymlinks",
|
|
1067
1076
|
"verbatimModuleSyntax",
|
|
1077
|
+
"erasableSyntaxOnly",
|
|
1068
1078
|
/* Completeness */
|
|
1069
1079
|
"skipDefaultLibCheck",
|
|
1070
1080
|
"skipLibCheck"
|
|
@@ -1565,7 +1575,7 @@ async function vue(options = {}) {
|
|
|
1565
1575
|
interopDefault(import("vue-eslint-parser"))
|
|
1566
1576
|
]);
|
|
1567
1577
|
const isVue3 = getVueVersion() === 3;
|
|
1568
|
-
const configKeys = isVue3 ? ["
|
|
1578
|
+
const configKeys = isVue3 ? ["essential", "strongly-recommended", "recommended"] : ["vue2-essential", "vue2-strongly-recommended", "vue2-recommended"];
|
|
1569
1579
|
const vueRules = configKeys.reduce((preRules, key) => {
|
|
1570
1580
|
const config = pluginVue.configs[key];
|
|
1571
1581
|
return {
|
|
@@ -1700,6 +1710,75 @@ async function vue(options = {}) {
|
|
|
1700
1710
|
];
|
|
1701
1711
|
}
|
|
1702
1712
|
|
|
1713
|
+
// src/configs/yaml.ts
|
|
1714
|
+
async function yaml(options = {}) {
|
|
1715
|
+
const { files = [GLOB_YAML], overrides = {} } = options;
|
|
1716
|
+
const [pluginYaml, parserYaml] = await Promise.all([
|
|
1717
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1718
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1719
|
+
]);
|
|
1720
|
+
return [
|
|
1721
|
+
{
|
|
1722
|
+
name: "coderwyd/yaml/setup",
|
|
1723
|
+
plugins: {
|
|
1724
|
+
yaml: pluginYaml
|
|
1725
|
+
}
|
|
1726
|
+
},
|
|
1727
|
+
{
|
|
1728
|
+
files,
|
|
1729
|
+
languageOptions: {
|
|
1730
|
+
parser: parserYaml
|
|
1731
|
+
},
|
|
1732
|
+
name: "coderwyd/yaml/rules",
|
|
1733
|
+
rules: {
|
|
1734
|
+
"yaml/block-mapping": "error",
|
|
1735
|
+
"yaml/block-sequence": "error",
|
|
1736
|
+
"yaml/no-empty-key": "error",
|
|
1737
|
+
"yaml/no-empty-sequence-entry": "error",
|
|
1738
|
+
"yaml/no-irregular-whitespace": "error",
|
|
1739
|
+
"yaml/plain-scalar": "error",
|
|
1740
|
+
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
1741
|
+
...overrides
|
|
1742
|
+
}
|
|
1743
|
+
},
|
|
1744
|
+
{
|
|
1745
|
+
files: ["pnpm-workspace.yaml"],
|
|
1746
|
+
name: "coderwyd/yaml/pnpm-workspace",
|
|
1747
|
+
rules: {
|
|
1748
|
+
"yaml/sort-keys": [
|
|
1749
|
+
"error",
|
|
1750
|
+
{
|
|
1751
|
+
order: [
|
|
1752
|
+
"packages",
|
|
1753
|
+
"overrides",
|
|
1754
|
+
"patchedDependencies",
|
|
1755
|
+
"hoistPattern",
|
|
1756
|
+
"catalog",
|
|
1757
|
+
"catalogs",
|
|
1758
|
+
"allowedDeprecatedVersions",
|
|
1759
|
+
"allowNonAppliedPatches",
|
|
1760
|
+
"configDependencies",
|
|
1761
|
+
"ignoredBuiltDependencies",
|
|
1762
|
+
"ignoredOptionalDependencies",
|
|
1763
|
+
"neverBuiltDependencies",
|
|
1764
|
+
"onlyBuiltDependencies",
|
|
1765
|
+
"onlyBuiltDependenciesFile",
|
|
1766
|
+
"packageExtensions",
|
|
1767
|
+
"peerDependencyRules",
|
|
1768
|
+
"supportedArchitectures"
|
|
1769
|
+
],
|
|
1770
|
+
pathPattern: "^$"
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
order: { type: "asc" },
|
|
1774
|
+
pathPattern: ".*"
|
|
1775
|
+
}
|
|
1776
|
+
]
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
];
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1703
1782
|
// src/index.ts
|
|
1704
1783
|
var flatConfigProps = [
|
|
1705
1784
|
"name",
|
|
@@ -1849,6 +1928,13 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1849
1928
|
sortTsconfig()
|
|
1850
1929
|
);
|
|
1851
1930
|
}
|
|
1931
|
+
if (options.yaml ?? true) {
|
|
1932
|
+
configs2.push(
|
|
1933
|
+
yaml({
|
|
1934
|
+
overrides: getOverrides(options, "yaml")
|
|
1935
|
+
})
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1852
1938
|
configs2.push(specials(), prettier());
|
|
1853
1939
|
if ("files" in options) {
|
|
1854
1940
|
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.
|
|
4
|
+
"version": "4.2.1",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,57 +69,59 @@
|
|
|
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.28.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.28.0",
|
|
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.
|
|
78
|
-
"eslint-plugin-command": "^3.
|
|
79
|
-
"eslint-plugin-de-morgan": "^1.2.
|
|
76
|
+
"eslint-config-prettier": "^10.1.1",
|
|
77
|
+
"eslint-plugin-antfu": "^3.1.1",
|
|
78
|
+
"eslint-plugin-command": "^3.2.0",
|
|
79
|
+
"eslint-plugin-de-morgan": "^1.2.1",
|
|
80
80
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
81
|
-
"eslint-plugin-import-x": "^4.
|
|
82
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
81
|
+
"eslint-plugin-import-x": "^4.9.1",
|
|
82
|
+
"eslint-plugin-jsdoc": "^50.6.9",
|
|
83
83
|
"eslint-plugin-jsonc": "^2.19.1",
|
|
84
|
-
"eslint-plugin-n": "^17.16.
|
|
84
|
+
"eslint-plugin-n": "^17.16.2",
|
|
85
85
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
86
|
-
"eslint-plugin-perfectionist": "^4.
|
|
86
|
+
"eslint-plugin-perfectionist": "^4.10.1",
|
|
87
87
|
"eslint-plugin-regexp": "^2.7.0",
|
|
88
|
-
"eslint-plugin-unicorn": "^
|
|
88
|
+
"eslint-plugin-unicorn": "^58.0.0",
|
|
89
89
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
90
|
-
"eslint-plugin-vue": "^
|
|
91
|
-
"eslint-
|
|
90
|
+
"eslint-plugin-vue": "^10.0.0",
|
|
91
|
+
"eslint-plugin-yml": "^1.17.0",
|
|
92
|
+
"eslint-typegen": "^2.1.0",
|
|
92
93
|
"globals": "^16.0.0",
|
|
93
94
|
"jsonc-eslint-parser": "^2.4.0",
|
|
94
|
-
"local-pkg": "^1.1.
|
|
95
|
+
"local-pkg": "^1.1.1",
|
|
95
96
|
"parse-gitignore": "^2.0.0",
|
|
96
97
|
"picocolors": "^1.1.1",
|
|
97
98
|
"prettier": "^3.5.3",
|
|
98
99
|
"prompts": "^2.4.2",
|
|
99
|
-
"vue-eslint-parser": "^
|
|
100
|
+
"vue-eslint-parser": "^10.1.1",
|
|
101
|
+
"yaml-eslint-parser": "^1.3.0",
|
|
100
102
|
"yargs": "^17.7.2"
|
|
101
103
|
},
|
|
102
104
|
"devDependencies": {
|
|
103
|
-
"@antfu/ni": "^
|
|
104
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
105
|
-
"@eslint/config-inspector": "^1.0.
|
|
105
|
+
"@antfu/ni": "^24.3.0",
|
|
106
|
+
"@eslint-react/eslint-plugin": "^1.38.0",
|
|
107
|
+
"@eslint/config-inspector": "^1.0.2",
|
|
106
108
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
107
|
-
"@types/node": "^22.13.
|
|
109
|
+
"@types/node": "^22.13.13",
|
|
108
110
|
"@types/prompts": "^2.4.9",
|
|
109
111
|
"@types/yargs": "^17.0.33",
|
|
110
|
-
"@unocss/eslint-plugin": "^66.1.0-beta.
|
|
111
|
-
"bumpp": "^10.0
|
|
112
|
-
"eslint": "^9.
|
|
112
|
+
"@unocss/eslint-plugin": "^66.1.0-beta.6",
|
|
113
|
+
"bumpp": "^10.1.0",
|
|
114
|
+
"eslint": "^9.23.0",
|
|
113
115
|
"eslint-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
|
|
114
116
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
115
117
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
116
|
-
"eslint-plugin-svelte": "^3.
|
|
118
|
+
"eslint-plugin-svelte": "^3.3.3",
|
|
117
119
|
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
118
120
|
"jiti": "^2.4.2",
|
|
119
121
|
"nano-staged": "^0.8.0",
|
|
120
|
-
"simple-git-hooks": "^2.
|
|
121
|
-
"svelte": "^5.
|
|
122
|
-
"svelte-eslint-parser": "^1.
|
|
122
|
+
"simple-git-hooks": "^2.12.1",
|
|
123
|
+
"svelte": "^5.25.3",
|
|
124
|
+
"svelte-eslint-parser": "^1.1.0",
|
|
123
125
|
"tsup": "^8.4.0",
|
|
124
126
|
"typescript": "^5.8.2"
|
|
125
127
|
},
|