@coderwyd/eslint-config 2.4.0 → 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,7 +1082,7 @@ 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",
@@ -1136,7 +1136,7 @@ async function unicorn() {
1136
1136
  "unicorn/prefer-prototype-methods": "error",
1137
1137
  "unicorn/prefer-query-selector": "error",
1138
1138
  "unicorn/prefer-reflect-apply": "error",
1139
- "unicorn/prefer-regexp-test": "error",
1139
+ // 'unicorn/prefer-regexp-test': 'error',
1140
1140
  "unicorn/prefer-string-replace-all": "error",
1141
1141
  "unicorn/prefer-string-slice": "error",
1142
1142
  "unicorn/prefer-string-starts-ends-with": "error",
@@ -1548,7 +1548,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1548
1548
  };
1549
1549
  return config;
1550
1550
  }
1551
- const configs = [
1551
+ const configs2 = [
1552
1552
  {
1553
1553
  name: "coderwyd/formatter/setup",
1554
1554
  plugins: {
@@ -1558,34 +1558,34 @@ async function formatter(options = {}, prettierRules2 = {}) {
1558
1558
  ];
1559
1559
  if (html) {
1560
1560
  const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1561
- configs.push(htmlConfig);
1561
+ configs2.push(htmlConfig);
1562
1562
  }
1563
1563
  if (css) {
1564
1564
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1565
1565
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1566
1566
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1567
- configs.push(cssConfig, scssConfig, lessConfig);
1567
+ configs2.push(cssConfig, scssConfig, lessConfig);
1568
1568
  }
1569
1569
  if (markdown) {
1570
1570
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1571
- configs.push(markdownConfig);
1571
+ configs2.push(markdownConfig);
1572
1572
  }
1573
1573
  if (graphql) {
1574
1574
  const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1575
- configs.push(graphqlConfig);
1575
+ configs2.push(graphqlConfig);
1576
1576
  }
1577
1577
  if (yaml) {
1578
1578
  const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1579
- configs.push(yamlConfig);
1579
+ configs2.push(yamlConfig);
1580
1580
  }
1581
1581
  if (toml) {
1582
1582
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1583
1583
  const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1584
1584
  "prettier-plugin-toml"
1585
1585
  ]);
1586
- configs.push(tomlConfig);
1586
+ configs2.push(tomlConfig);
1587
1587
  }
1588
- return configs;
1588
+ return configs2;
1589
1589
  }
1590
1590
 
1591
1591
  // src/configs/svelte.ts
@@ -1720,6 +1720,31 @@ async function command() {
1720
1720
  ];
1721
1721
  }
1722
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
+
1723
1748
  // src/env.ts
1724
1749
  import process3 from "node:process";
1725
1750
  import { isPackageExists as isPackageExists3 } from "local-pkg";
@@ -1759,6 +1784,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1759
1784
  gitignore: enableGitignore = true,
1760
1785
  isInEditor: isInEditor2 = isInEditor,
1761
1786
  react: enableReact = false,
1787
+ regexp: enableRegexp = true,
1762
1788
  svelte: enableSvelte = false,
1763
1789
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1764
1790
  typescript: enableTypeScript = hasTypeScript,
@@ -1766,24 +1792,24 @@ async function defineConfig(options = {}, ...userConfigs) {
1766
1792
  usePrettierrc = true,
1767
1793
  vue: enableVue = hasVue
1768
1794
  } = options;
1769
- const configs = [];
1795
+ const configs2 = [];
1770
1796
  if (enableGitignore) {
1771
1797
  if (typeof enableGitignore !== "boolean") {
1772
- configs.push(
1798
+ configs2.push(
1773
1799
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1774
1800
  r(enableGitignore)
1775
1801
  ])
1776
1802
  );
1777
1803
  } else {
1778
1804
  if (fs.existsSync(".gitignore"))
1779
- configs.push(
1805
+ configs2.push(
1780
1806
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1781
1807
  r()
1782
1808
  ])
1783
1809
  );
1784
1810
  }
1785
1811
  }
1786
- configs.push(
1812
+ configs2.push(
1787
1813
  ignores(),
1788
1814
  javascript({
1789
1815
  isInEditor: isInEditor2,
@@ -1801,7 +1827,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1801
1827
  if (enableVue)
1802
1828
  componentExts.push("vue");
1803
1829
  if (enableTypeScript) {
1804
- configs.push(
1830
+ configs2.push(
1805
1831
  typescript({
1806
1832
  ...resolveSubOptions(options, "typescript"),
1807
1833
  componentExts,
@@ -1809,8 +1835,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1809
1835
  })
1810
1836
  );
1811
1837
  }
1838
+ if (enableRegexp)
1839
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1812
1840
  if (options.test ?? true) {
1813
- configs.push(
1841
+ configs2.push(
1814
1842
  test({
1815
1843
  isInEditor: isInEditor2,
1816
1844
  overrides: getOverrides(options, "test")
@@ -1818,7 +1846,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1818
1846
  );
1819
1847
  }
1820
1848
  if (enableVue) {
1821
- configs.push(
1849
+ configs2.push(
1822
1850
  vue({
1823
1851
  ...resolveSubOptions(options, "vue"),
1824
1852
  overrides: getOverrides(options, "typescript"),
@@ -1827,7 +1855,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1827
1855
  );
1828
1856
  }
1829
1857
  if (enableReact) {
1830
- configs.push(
1858
+ configs2.push(
1831
1859
  react({
1832
1860
  overrides: getOverrides(options, "react"),
1833
1861
  typescript: !!enableTypeScript
@@ -1835,7 +1863,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1835
1863
  );
1836
1864
  }
1837
1865
  if (enableSvelte) {
1838
- configs.push(
1866
+ configs2.push(
1839
1867
  svelte({
1840
1868
  overrides: getOverrides(options, "svelte"),
1841
1869
  typescript: !!enableTypeScript
@@ -1843,7 +1871,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1843
1871
  );
1844
1872
  }
1845
1873
  if (enableUnoCSS) {
1846
- configs.push(
1874
+ configs2.push(
1847
1875
  unocss({
1848
1876
  ...resolveSubOptions(options, "unocss"),
1849
1877
  overrides: getOverrides(options, "unocss")
@@ -1851,7 +1879,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1851
1879
  );
1852
1880
  }
1853
1881
  if (enableTailwindCSS) {
1854
- configs.push(
1882
+ configs2.push(
1855
1883
  tailwindcss({
1856
1884
  ...resolveSubOptions(options, "tailwindcss"),
1857
1885
  overrides: getOverrides(options, "tailwindcss")
@@ -1859,7 +1887,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1859
1887
  );
1860
1888
  }
1861
1889
  if (options.jsonc ?? true) {
1862
- configs.push(
1890
+ configs2.push(
1863
1891
  jsonc({
1864
1892
  overrides: getOverrides(options, "jsonc")
1865
1893
  }),
@@ -1880,12 +1908,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1880
1908
  );
1881
1909
  Object.assign(prettierRules2, prettierConfig);
1882
1910
  }
1883
- configs.push(
1911
+ configs2.push(
1884
1912
  prettier(prettierRules2),
1885
1913
  formatter(formatterOptions, prettierRules2)
1886
1914
  );
1887
1915
  } else {
1888
- configs.push(prettier());
1916
+ configs2.push(prettier());
1889
1917
  }
1890
1918
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1891
1919
  if (key in options)
@@ -1893,8 +1921,8 @@ async function defineConfig(options = {}, ...userConfigs) {
1893
1921
  return acc;
1894
1922
  }, {});
1895
1923
  if (Object.keys(fusedConfig).length > 0)
1896
- configs.push([fusedConfig]);
1897
- const merged = await combine(...configs, ...userConfigs);
1924
+ configs2.push([fusedConfig]);
1925
+ const merged = await combine(...configs2, ...userConfigs);
1898
1926
  if (autoRenamePlugins)
1899
1927
  return renamePluginInConfigs(merged, defaultPluginRenaming);
1900
1928
  return merged;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "description": "Donny's ESLint config",
6
6
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
7
7
  "license": "MIT",
@@ -33,11 +33,11 @@
33
33
  "dist"
34
34
  ],
35
35
  "engines": {
36
- "node": ">=16.14.0"
36
+ "node": ">=18.18.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@unocss/eslint-plugin": ">=0.50.0",
40
- "eslint": ">=8.40.0",
40
+ "eslint": "^8.56.0 || ^9.0.0",
41
41
  "eslint-plugin-react": "^7.33.2",
42
42
  "eslint-plugin-react-hooks": "^4.6.0",
43
43
  "eslint-plugin-react-refresh": "^0.4.4",
@@ -67,8 +67,8 @@
67
67
  "dependencies": {
68
68
  "@antfu/install-pkg": "^0.3.3",
69
69
  "@toml-tools/parser": "^1.0.0",
70
- "@typescript-eslint/eslint-plugin": "^7.8.0",
71
- "@typescript-eslint/parser": "^7.8.0",
70
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
71
+ "@typescript-eslint/parser": "^7.9.0",
72
72
  "eslint-config-flat-gitignore": "^0.1.5",
73
73
  "eslint-config-prettier": "^9.1.0",
74
74
  "eslint-plugin-antfu": "^2.2.0",
@@ -77,12 +77,13 @@
77
77
  "eslint-plugin-import-x": "^0.5.0",
78
78
  "eslint-plugin-jsdoc": "^48.2.4",
79
79
  "eslint-plugin-jsonc": "^2.15.1",
80
- "eslint-plugin-n": "^17.5.1",
80
+ "eslint-plugin-n": "^17.6.0",
81
81
  "eslint-plugin-no-only-tests": "^3.1.0",
82
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-unicorn": "^53.0.0",
86
87
  "eslint-plugin-unused-imports": "^3.2.0",
87
88
  "eslint-plugin-vitest": "^0.5.4",
88
89
  "eslint-plugin-vue": "^9.26.0",
@@ -106,23 +107,23 @@
106
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.60.0",
110
+ "@unocss/eslint-plugin": "^0.60.2",
110
111
  "bumpp": "^9.4.1",
111
112
  "eslint": "9.2.0",
112
113
  "eslint-plugin-react": "^7.34.1",
113
114
  "eslint-plugin-react-hooks": "^4.6.2",
114
115
  "eslint-plugin-react-refresh": "^0.4.7",
115
- "eslint-plugin-svelte": "2.38.0",
116
- "execa": "^9.0.1",
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.16",
123
+ "svelte": "^4.2.17",
123
124
  "svelte-eslint-parser": "^0.36.0",
124
125
  "tsup": "^8.0.2",
125
- "tsx": "^4.9.3",
126
+ "tsx": "^4.10.2",
126
127
  "typescript": "^5.4.5"
127
128
  },
128
129
  "simple-git-hooks": {