@coderwyd/eslint-config 2.3.4 → 2.4.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/index.js CHANGED
@@ -449,8 +449,8 @@ var parserPlain = {
449
449
  }
450
450
  })
451
451
  };
452
- async function combine(...configs) {
453
- const resolved = await Promise.all(configs);
452
+ async function combine(...configs2) {
453
+ const resolved = await Promise.all(configs2);
454
454
  return resolved.flat();
455
455
  }
456
456
  function renameRules(rules, map) {
@@ -464,8 +464,8 @@ function renameRules(rules, map) {
464
464
  })
465
465
  );
466
466
  }
467
- function renamePluginInConfigs(configs, map) {
468
- return configs.map((i) => {
467
+ function renamePluginInConfigs(configs2, map) {
468
+ return configs2.map((i) => {
469
469
  const clone = { ...i };
470
470
  if (clone.rules)
471
471
  clone.rules = renameRules(clone.rules, map);
@@ -894,7 +894,7 @@ async function prettier(rules = {}) {
894
894
  const pRules = {
895
895
  ...rules
896
896
  };
897
- const configs = [
897
+ const configs2 = [
898
898
  {
899
899
  name: "coderwyd/prettier/setup",
900
900
  plugins: {
@@ -913,7 +913,7 @@ async function prettier(rules = {}) {
913
913
  }
914
914
  }
915
915
  ];
916
- return configs;
916
+ return configs2;
917
917
  }
918
918
 
919
919
  // src/configs/typescript.ts
@@ -1082,12 +1082,12 @@ async function unicorn() {
1082
1082
  unicorn: default5
1083
1083
  },
1084
1084
  rules: {
1085
- "unicorn/better-regex": "error",
1085
+ // 'unicorn/better-regex': 'error',
1086
1086
  "unicorn/catch-error-name": "error",
1087
1087
  "unicorn/custom-error-definition": "error",
1088
1088
  "unicorn/error-message": "error",
1089
1089
  "unicorn/escape-case": "error",
1090
- "unicorn/explicit-length-check": "error",
1090
+ // 'unicorn/explicit-length-check': 'error',
1091
1091
  // 'unicorn/filename-case': [
1092
1092
  // 'error',
1093
1093
  // {
@@ -1096,9 +1096,10 @@ async function unicorn() {
1096
1096
  // },
1097
1097
  // ],
1098
1098
  "unicorn/new-for-builtins": "error",
1099
- "unicorn/no-array-callback-reference": "error",
1099
+ // 'unicorn/no-array-callback-reference': 'error',
1100
1100
  "unicorn/no-array-method-this-argument": "error",
1101
1101
  "unicorn/no-array-push-push": "error",
1102
+ "unicorn/no-await-in-promise-methods": "error",
1102
1103
  "unicorn/no-console-spaces": "error",
1103
1104
  "unicorn/no-for-loop": "error",
1104
1105
  "unicorn/no-hex-escape": "error",
@@ -1107,6 +1108,7 @@ async function unicorn() {
1107
1108
  "unicorn/no-lonely-if": "error",
1108
1109
  "unicorn/no-new-array": "error",
1109
1110
  "unicorn/no-new-buffer": "error",
1111
+ "unicorn/no-single-promise-in-promise-methods": "error",
1110
1112
  "unicorn/no-static-only-class": "error",
1111
1113
  "unicorn/no-unnecessary-await": "error",
1112
1114
  "unicorn/no-zero-fractions": `error`,
@@ -1134,12 +1136,13 @@ async function unicorn() {
1134
1136
  "unicorn/prefer-prototype-methods": "error",
1135
1137
  "unicorn/prefer-query-selector": "error",
1136
1138
  "unicorn/prefer-reflect-apply": "error",
1137
- "unicorn/prefer-regexp-test": "error",
1139
+ // 'unicorn/prefer-regexp-test': 'error',
1138
1140
  "unicorn/prefer-string-replace-all": "error",
1139
1141
  "unicorn/prefer-string-slice": "error",
1140
1142
  "unicorn/prefer-string-starts-ends-with": "error",
1141
1143
  "unicorn/prefer-string-trim-start-end": "error",
1142
- "unicorn/prefer-top-level-await": "error",
1144
+ // top level await is not supported in all environments
1145
+ // 'unicorn/prefer-top-level-await': 'error',
1143
1146
  "unicorn/prefer-type-error": "error",
1144
1147
  "unicorn/throw-new-error": "error"
1145
1148
  }
@@ -1545,7 +1548,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1545
1548
  };
1546
1549
  return config;
1547
1550
  }
1548
- const configs = [
1551
+ const configs2 = [
1549
1552
  {
1550
1553
  name: "coderwyd/formatter/setup",
1551
1554
  plugins: {
@@ -1555,34 +1558,34 @@ async function formatter(options = {}, prettierRules2 = {}) {
1555
1558
  ];
1556
1559
  if (html) {
1557
1560
  const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1558
- configs.push(htmlConfig);
1561
+ configs2.push(htmlConfig);
1559
1562
  }
1560
1563
  if (css) {
1561
1564
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1562
1565
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1563
1566
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1564
- configs.push(cssConfig, scssConfig, lessConfig);
1567
+ configs2.push(cssConfig, scssConfig, lessConfig);
1565
1568
  }
1566
1569
  if (markdown) {
1567
1570
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1568
- configs.push(markdownConfig);
1571
+ configs2.push(markdownConfig);
1569
1572
  }
1570
1573
  if (graphql) {
1571
1574
  const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1572
- configs.push(graphqlConfig);
1575
+ configs2.push(graphqlConfig);
1573
1576
  }
1574
1577
  if (yaml) {
1575
1578
  const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1576
- configs.push(yamlConfig);
1579
+ configs2.push(yamlConfig);
1577
1580
  }
1578
1581
  if (toml) {
1579
1582
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1580
1583
  const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1581
1584
  "prettier-plugin-toml"
1582
1585
  ]);
1583
- configs.push(tomlConfig);
1586
+ configs2.push(tomlConfig);
1584
1587
  }
1585
- return configs;
1588
+ return configs2;
1586
1589
  }
1587
1590
 
1588
1591
  // src/configs/svelte.ts
@@ -1706,6 +1709,42 @@ async function tailwindcss(options = {}) {
1706
1709
  ];
1707
1710
  }
1708
1711
 
1712
+ // src/configs/command.ts
1713
+ import createCommand from "eslint-plugin-command/config";
1714
+ async function command() {
1715
+ return [
1716
+ {
1717
+ ...createCommand(),
1718
+ name: "coderwyd/command/rules"
1719
+ }
1720
+ ];
1721
+ }
1722
+
1723
+ // src/configs/regexp.ts
1724
+ import { configs } from "eslint-plugin-regexp";
1725
+ async function regexp(options = {}) {
1726
+ const config = configs["flat/recommended"];
1727
+ const rules = {
1728
+ ...config.rules
1729
+ };
1730
+ if (options.level === "warn") {
1731
+ Object.keys(rules).forEach((key) => {
1732
+ if (rules[key] === "error")
1733
+ rules[key] = "warn";
1734
+ });
1735
+ }
1736
+ return [
1737
+ {
1738
+ ...config,
1739
+ name: "coderwyd/regexp/rules",
1740
+ rules: {
1741
+ ...rules,
1742
+ ...options.overrides
1743
+ }
1744
+ }
1745
+ ];
1746
+ }
1747
+
1709
1748
  // src/env.ts
1710
1749
  import process3 from "node:process";
1711
1750
  import { isPackageExists as isPackageExists3 } from "local-pkg";
@@ -1745,6 +1784,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1745
1784
  gitignore: enableGitignore = true,
1746
1785
  isInEditor: isInEditor2 = isInEditor,
1747
1786
  react: enableReact = false,
1787
+ regexp: enableRegexp = true,
1748
1788
  svelte: enableSvelte = false,
1749
1789
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1750
1790
  typescript: enableTypeScript = hasTypeScript,
@@ -1752,24 +1792,24 @@ async function defineConfig(options = {}, ...userConfigs) {
1752
1792
  usePrettierrc = true,
1753
1793
  vue: enableVue = hasVue
1754
1794
  } = options;
1755
- const configs = [];
1795
+ const configs2 = [];
1756
1796
  if (enableGitignore) {
1757
1797
  if (typeof enableGitignore !== "boolean") {
1758
- configs.push(
1798
+ configs2.push(
1759
1799
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1760
1800
  r(enableGitignore)
1761
1801
  ])
1762
1802
  );
1763
1803
  } else {
1764
1804
  if (fs.existsSync(".gitignore"))
1765
- configs.push(
1805
+ configs2.push(
1766
1806
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1767
1807
  r()
1768
1808
  ])
1769
1809
  );
1770
1810
  }
1771
1811
  }
1772
- configs.push(
1812
+ configs2.push(
1773
1813
  ignores(),
1774
1814
  javascript({
1775
1815
  isInEditor: isInEditor2,
@@ -1780,13 +1820,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1780
1820
  jsdoc(),
1781
1821
  imports(),
1782
1822
  unicorn(),
1823
+ command(),
1783
1824
  // Optional plugins (installed but not enabled by default)
1784
1825
  perfectionist()
1785
1826
  );
1786
1827
  if (enableVue)
1787
1828
  componentExts.push("vue");
1788
1829
  if (enableTypeScript) {
1789
- configs.push(
1830
+ configs2.push(
1790
1831
  typescript({
1791
1832
  ...resolveSubOptions(options, "typescript"),
1792
1833
  componentExts,
@@ -1794,8 +1835,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1794
1835
  })
1795
1836
  );
1796
1837
  }
1838
+ if (enableRegexp)
1839
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1797
1840
  if (options.test ?? true) {
1798
- configs.push(
1841
+ configs2.push(
1799
1842
  test({
1800
1843
  isInEditor: isInEditor2,
1801
1844
  overrides: getOverrides(options, "test")
@@ -1803,7 +1846,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1803
1846
  );
1804
1847
  }
1805
1848
  if (enableVue) {
1806
- configs.push(
1849
+ configs2.push(
1807
1850
  vue({
1808
1851
  ...resolveSubOptions(options, "vue"),
1809
1852
  overrides: getOverrides(options, "typescript"),
@@ -1812,7 +1855,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1812
1855
  );
1813
1856
  }
1814
1857
  if (enableReact) {
1815
- configs.push(
1858
+ configs2.push(
1816
1859
  react({
1817
1860
  overrides: getOverrides(options, "react"),
1818
1861
  typescript: !!enableTypeScript
@@ -1820,7 +1863,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1820
1863
  );
1821
1864
  }
1822
1865
  if (enableSvelte) {
1823
- configs.push(
1866
+ configs2.push(
1824
1867
  svelte({
1825
1868
  overrides: getOverrides(options, "svelte"),
1826
1869
  typescript: !!enableTypeScript
@@ -1828,7 +1871,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1828
1871
  );
1829
1872
  }
1830
1873
  if (enableUnoCSS) {
1831
- configs.push(
1874
+ configs2.push(
1832
1875
  unocss({
1833
1876
  ...resolveSubOptions(options, "unocss"),
1834
1877
  overrides: getOverrides(options, "unocss")
@@ -1836,7 +1879,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1836
1879
  );
1837
1880
  }
1838
1881
  if (enableTailwindCSS) {
1839
- configs.push(
1882
+ configs2.push(
1840
1883
  tailwindcss({
1841
1884
  ...resolveSubOptions(options, "tailwindcss"),
1842
1885
  overrides: getOverrides(options, "tailwindcss")
@@ -1844,7 +1887,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1844
1887
  );
1845
1888
  }
1846
1889
  if (options.jsonc ?? true) {
1847
- configs.push(
1890
+ configs2.push(
1848
1891
  jsonc({
1849
1892
  overrides: getOverrides(options, "jsonc")
1850
1893
  }),
@@ -1865,12 +1908,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1865
1908
  );
1866
1909
  Object.assign(prettierRules2, prettierConfig);
1867
1910
  }
1868
- configs.push(
1911
+ configs2.push(
1869
1912
  prettier(prettierRules2),
1870
1913
  formatter(formatterOptions, prettierRules2)
1871
1914
  );
1872
1915
  } else {
1873
- configs.push(prettier());
1916
+ configs2.push(prettier());
1874
1917
  }
1875
1918
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1876
1919
  if (key in options)
@@ -1878,8 +1921,8 @@ async function defineConfig(options = {}, ...userConfigs) {
1878
1921
  return acc;
1879
1922
  }, {});
1880
1923
  if (Object.keys(fusedConfig).length > 0)
1881
- configs.push([fusedConfig]);
1882
- const merged = await combine(...configs, ...userConfigs);
1924
+ configs2.push([fusedConfig]);
1925
+ const merged = await combine(...configs2, ...userConfigs);
1883
1926
  if (autoRenamePlugins)
1884
1927
  return renamePluginInConfigs(merged, defaultPluginRenaming);
1885
1928
  return merged;
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "2.3.4",
5
- "packageManager": "pnpm@8.15.6",
4
+ "version": "2.4.1",
6
5
  "description": "Donny's ESLint config",
7
6
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
8
7
  "license": "MIT",
@@ -34,11 +33,11 @@
34
33
  "dist"
35
34
  ],
36
35
  "engines": {
37
- "node": ">=16.14.0"
36
+ "node": ">=18.18.0"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "@unocss/eslint-plugin": ">=0.50.0",
41
- "eslint": ">=8.40.0",
40
+ "eslint": "^8.56.0 || ^9.0.0",
42
41
  "eslint-plugin-react": "^7.33.2",
43
42
  "eslint-plugin-react-hooks": "^4.6.0",
44
43
  "eslint-plugin-react-refresh": "^0.4.4",
@@ -66,28 +65,30 @@
66
65
  }
67
66
  },
68
67
  "dependencies": {
69
- "@antfu/install-pkg": "^0.3.2",
68
+ "@antfu/install-pkg": "^0.3.3",
70
69
  "@toml-tools/parser": "^1.0.0",
71
- "@typescript-eslint/eslint-plugin": "^7.6.0",
72
- "@typescript-eslint/parser": "^7.6.0",
70
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
71
+ "@typescript-eslint/parser": "^7.9.0",
73
72
  "eslint-config-flat-gitignore": "^0.1.5",
74
73
  "eslint-config-prettier": "^9.1.0",
75
- "eslint-plugin-antfu": "^2.1.2",
74
+ "eslint-plugin-antfu": "^2.2.0",
75
+ "eslint-plugin-command": "^0.2.0",
76
76
  "eslint-plugin-eslint-comments": "^3.2.0",
77
77
  "eslint-plugin-import-x": "^0.5.0",
78
- "eslint-plugin-jsdoc": "^48.2.3",
78
+ "eslint-plugin-jsdoc": "^48.2.4",
79
79
  "eslint-plugin-jsonc": "^2.15.1",
80
- "eslint-plugin-n": "^17.1.0",
80
+ "eslint-plugin-n": "^17.6.0",
81
81
  "eslint-plugin-no-only-tests": "^3.1.0",
82
- "eslint-plugin-perfectionist": "^2.8.0",
82
+ "eslint-plugin-perfectionist": "^2.10.0",
83
83
  "eslint-plugin-prettier": "^5.1.3",
84
+ "eslint-plugin-regexp": "^2.5.0",
84
85
  "eslint-plugin-tailwindcss": "^3.15.1",
85
- "eslint-plugin-unicorn": "^52.0.0",
86
- "eslint-plugin-unused-imports": "^3.1.0",
87
- "eslint-plugin-vitest": "^0.5.1",
88
- "eslint-plugin-vue": "^9.24.1",
89
- "eslint-typegen": "^0.2.2",
90
- "globals": "^15.0.0",
86
+ "eslint-plugin-unicorn": "^53.0.0",
87
+ "eslint-plugin-unused-imports": "^3.2.0",
88
+ "eslint-plugin-vitest": "^0.5.4",
89
+ "eslint-plugin-vue": "^9.26.0",
90
+ "eslint-typegen": "^0.2.4",
91
+ "globals": "^15.2.0",
91
92
  "jsonc-eslint-parser": "^2.4.0",
92
93
  "local-pkg": "^0.5.0",
93
94
  "parse-gitignore": "^2.0.0",
@@ -100,29 +101,29 @@
100
101
  },
101
102
  "devDependencies": {
102
103
  "@antfu/ni": "^0.21.12",
103
- "@eslint/config-inspector": "^0.4.6",
104
- "@types/eslint": "^8.56.9",
104
+ "@eslint/config-inspector": "^0.4.8",
105
+ "@types/eslint": "^8.56.10",
105
106
  "@types/fs-extra": "^11.0.4",
106
- "@types/node": "^20.12.7",
107
+ "@types/node": "^20.12.11",
107
108
  "@types/prompts": "^2.4.9",
108
109
  "@types/yargs": "^17.0.32",
109
- "@unocss/eslint-plugin": "^0.59.2",
110
- "bumpp": "^9.4.0",
111
- "eslint": "9.0.0",
110
+ "@unocss/eslint-plugin": "^0.60.2",
111
+ "bumpp": "^9.4.1",
112
+ "eslint": "9.2.0",
112
113
  "eslint-plugin-react": "^7.34.1",
113
- "eslint-plugin-react-hooks": "^4.6.0",
114
- "eslint-plugin-react-refresh": "^0.4.6",
115
- "eslint-plugin-svelte": "2.36.0",
116
- "execa": "^8.0.1",
114
+ "eslint-plugin-react-hooks": "^4.6.2",
115
+ "eslint-plugin-react-refresh": "^0.4.7",
116
+ "eslint-plugin-svelte": "2.39.0",
117
+ "execa": "^9.1.0",
117
118
  "fast-glob": "^3.3.2",
118
119
  "fs-extra": "^11.2.0",
119
120
  "lint-staged": "^15.2.2",
120
- "rimraf": "^5.0.5",
121
+ "rimraf": "^5.0.7",
121
122
  "simple-git-hooks": "^2.11.1",
122
- "svelte": "^4.2.13",
123
- "svelte-eslint-parser": "^0.34.1",
123
+ "svelte": "^4.2.17",
124
+ "svelte-eslint-parser": "^0.36.0",
124
125
  "tsup": "^8.0.2",
125
- "tsx": "^4.7.2",
126
+ "tsx": "^4.10.2",
126
127
  "typescript": "^5.4.5"
127
128
  },
128
129
  "simple-git-hooks": {