@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/cli.cjs CHANGED
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
46
46
  var import_picocolors = __toESM(require("picocolors"), 1);
47
47
 
48
48
  // package.json
49
- var version = "2.4.0";
49
+ var version = "2.4.1";
50
50
  var devDependencies = {
51
51
  "@antfu/ni": "^0.21.12",
52
52
  "@eslint/config-inspector": "^0.4.8",
@@ -55,23 +55,23 @@ var devDependencies = {
55
55
  "@types/node": "^20.12.11",
56
56
  "@types/prompts": "^2.4.9",
57
57
  "@types/yargs": "^17.0.32",
58
- "@unocss/eslint-plugin": "^0.60.0",
58
+ "@unocss/eslint-plugin": "^0.60.2",
59
59
  bumpp: "^9.4.1",
60
60
  eslint: "9.2.0",
61
61
  "eslint-plugin-react": "^7.34.1",
62
62
  "eslint-plugin-react-hooks": "^4.6.2",
63
63
  "eslint-plugin-react-refresh": "^0.4.7",
64
- "eslint-plugin-svelte": "2.38.0",
65
- execa: "^9.0.1",
64
+ "eslint-plugin-svelte": "2.39.0",
65
+ execa: "^9.1.0",
66
66
  "fast-glob": "^3.3.2",
67
67
  "fs-extra": "^11.2.0",
68
68
  "lint-staged": "^15.2.2",
69
- rimraf: "^5.0.5",
69
+ rimraf: "^5.0.7",
70
70
  "simple-git-hooks": "^2.11.1",
71
- svelte: "^4.2.16",
71
+ svelte: "^4.2.17",
72
72
  "svelte-eslint-parser": "^0.36.0",
73
73
  tsup: "^8.0.2",
74
- tsx: "^4.9.3",
74
+ tsx: "^4.10.2",
75
75
  typescript: "^5.4.5"
76
76
  };
77
77
 
@@ -239,7 +239,7 @@ ${coderwydConfig}
239
239
  console.log(import_picocolors2.default.green(`${CHECK} created .vscode/settings.json`));
240
240
  } else {
241
241
  let settingsContent = await import_promises.default.readFile(settingsPath, "utf8");
242
- settingsContent = settingsContent.trim().replace(/\s*}$/, "");
242
+ settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
243
243
  settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
244
244
  settingsContent += `${vscodeSettingsString}}
245
245
  `;
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.4.0";
20
+ var version = "2.4.1";
21
21
  var devDependencies = {
22
22
  "@antfu/ni": "^0.21.12",
23
23
  "@eslint/config-inspector": "^0.4.8",
@@ -26,23 +26,23 @@ var devDependencies = {
26
26
  "@types/node": "^20.12.11",
27
27
  "@types/prompts": "^2.4.9",
28
28
  "@types/yargs": "^17.0.32",
29
- "@unocss/eslint-plugin": "^0.60.0",
29
+ "@unocss/eslint-plugin": "^0.60.2",
30
30
  bumpp: "^9.4.1",
31
31
  eslint: "9.2.0",
32
32
  "eslint-plugin-react": "^7.34.1",
33
33
  "eslint-plugin-react-hooks": "^4.6.2",
34
34
  "eslint-plugin-react-refresh": "^0.4.7",
35
- "eslint-plugin-svelte": "2.38.0",
36
- execa: "^9.0.1",
35
+ "eslint-plugin-svelte": "2.39.0",
36
+ execa: "^9.1.0",
37
37
  "fast-glob": "^3.3.2",
38
38
  "fs-extra": "^11.2.0",
39
39
  "lint-staged": "^15.2.2",
40
- rimraf: "^5.0.5",
40
+ rimraf: "^5.0.7",
41
41
  "simple-git-hooks": "^2.11.1",
42
- svelte: "^4.2.16",
42
+ svelte: "^4.2.17",
43
43
  "svelte-eslint-parser": "^0.36.0",
44
44
  tsup: "^8.0.2",
45
- tsx: "^4.9.3",
45
+ tsx: "^4.10.2",
46
46
  typescript: "^5.4.5"
47
47
  };
48
48
 
@@ -210,7 +210,7 @@ ${coderwydConfig}
210
210
  console.log(c2.green(`${CHECK} created .vscode/settings.json`));
211
211
  } else {
212
212
  let settingsContent = await fsp.readFile(settingsPath, "utf8");
213
- settingsContent = settingsContent.trim().replace(/\s*}$/, "");
213
+ settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
214
214
  settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
215
215
  settingsContent += `${vscodeSettingsString}}
216
216
  `;
package/dist/index.cjs CHANGED
@@ -495,8 +495,8 @@ var parserPlain = {
495
495
  }
496
496
  })
497
497
  };
498
- async function combine(...configs) {
499
- const resolved = await Promise.all(configs);
498
+ async function combine(...configs2) {
499
+ const resolved = await Promise.all(configs2);
500
500
  return resolved.flat();
501
501
  }
502
502
  function renameRules(rules, map) {
@@ -510,8 +510,8 @@ function renameRules(rules, map) {
510
510
  })
511
511
  );
512
512
  }
513
- function renamePluginInConfigs(configs, map) {
514
- return configs.map((i) => {
513
+ function renamePluginInConfigs(configs2, map) {
514
+ return configs2.map((i) => {
515
515
  const clone = { ...i };
516
516
  if (clone.rules)
517
517
  clone.rules = renameRules(clone.rules, map);
@@ -940,7 +940,7 @@ async function prettier(rules = {}) {
940
940
  const pRules = {
941
941
  ...rules
942
942
  };
943
- const configs = [
943
+ const configs2 = [
944
944
  {
945
945
  name: "coderwyd/prettier/setup",
946
946
  plugins: {
@@ -959,7 +959,7 @@ async function prettier(rules = {}) {
959
959
  }
960
960
  }
961
961
  ];
962
- return configs;
962
+ return configs2;
963
963
  }
964
964
 
965
965
  // src/configs/typescript.ts
@@ -1128,7 +1128,7 @@ async function unicorn() {
1128
1128
  unicorn: import_eslint_plugin_unicorn.default
1129
1129
  },
1130
1130
  rules: {
1131
- "unicorn/better-regex": "error",
1131
+ // 'unicorn/better-regex': 'error',
1132
1132
  "unicorn/catch-error-name": "error",
1133
1133
  "unicorn/custom-error-definition": "error",
1134
1134
  "unicorn/error-message": "error",
@@ -1182,7 +1182,7 @@ async function unicorn() {
1182
1182
  "unicorn/prefer-prototype-methods": "error",
1183
1183
  "unicorn/prefer-query-selector": "error",
1184
1184
  "unicorn/prefer-reflect-apply": "error",
1185
- "unicorn/prefer-regexp-test": "error",
1185
+ // 'unicorn/prefer-regexp-test': 'error',
1186
1186
  "unicorn/prefer-string-replace-all": "error",
1187
1187
  "unicorn/prefer-string-slice": "error",
1188
1188
  "unicorn/prefer-string-starts-ends-with": "error",
@@ -1594,7 +1594,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1594
1594
  };
1595
1595
  return config;
1596
1596
  }
1597
- const configs = [
1597
+ const configs2 = [
1598
1598
  {
1599
1599
  name: "coderwyd/formatter/setup",
1600
1600
  plugins: {
@@ -1604,34 +1604,34 @@ async function formatter(options = {}, prettierRules2 = {}) {
1604
1604
  ];
1605
1605
  if (html) {
1606
1606
  const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1607
- configs.push(htmlConfig);
1607
+ configs2.push(htmlConfig);
1608
1608
  }
1609
1609
  if (css) {
1610
1610
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1611
1611
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1612
1612
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1613
- configs.push(cssConfig, scssConfig, lessConfig);
1613
+ configs2.push(cssConfig, scssConfig, lessConfig);
1614
1614
  }
1615
1615
  if (markdown) {
1616
1616
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1617
- configs.push(markdownConfig);
1617
+ configs2.push(markdownConfig);
1618
1618
  }
1619
1619
  if (graphql) {
1620
1620
  const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1621
- configs.push(graphqlConfig);
1621
+ configs2.push(graphqlConfig);
1622
1622
  }
1623
1623
  if (yaml) {
1624
1624
  const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1625
- configs.push(yamlConfig);
1625
+ configs2.push(yamlConfig);
1626
1626
  }
1627
1627
  if (toml) {
1628
1628
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1629
1629
  const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1630
1630
  "prettier-plugin-toml"
1631
1631
  ]);
1632
- configs.push(tomlConfig);
1632
+ configs2.push(tomlConfig);
1633
1633
  }
1634
- return configs;
1634
+ return configs2;
1635
1635
  }
1636
1636
 
1637
1637
  // src/configs/svelte.ts
@@ -1766,6 +1766,31 @@ async function command() {
1766
1766
  ];
1767
1767
  }
1768
1768
 
1769
+ // src/configs/regexp.ts
1770
+ var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1771
+ async function regexp(options = {}) {
1772
+ const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1773
+ const rules = {
1774
+ ...config.rules
1775
+ };
1776
+ if (options.level === "warn") {
1777
+ Object.keys(rules).forEach((key) => {
1778
+ if (rules[key] === "error")
1779
+ rules[key] = "warn";
1780
+ });
1781
+ }
1782
+ return [
1783
+ {
1784
+ ...config,
1785
+ name: "coderwyd/regexp/rules",
1786
+ rules: {
1787
+ ...rules,
1788
+ ...options.overrides
1789
+ }
1790
+ }
1791
+ ];
1792
+ }
1793
+
1769
1794
  // src/env.ts
1770
1795
  var import_node_process3 = __toESM(require("process"), 1);
1771
1796
  var import_local_pkg3 = require("local-pkg");
@@ -1805,6 +1830,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1805
1830
  gitignore: enableGitignore = true,
1806
1831
  isInEditor: isInEditor2 = isInEditor,
1807
1832
  react: enableReact = false,
1833
+ regexp: enableRegexp = true,
1808
1834
  svelte: enableSvelte = false,
1809
1835
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1810
1836
  typescript: enableTypeScript = hasTypeScript,
@@ -1812,24 +1838,24 @@ async function defineConfig(options = {}, ...userConfigs) {
1812
1838
  usePrettierrc = true,
1813
1839
  vue: enableVue = hasVue
1814
1840
  } = options;
1815
- const configs = [];
1841
+ const configs2 = [];
1816
1842
  if (enableGitignore) {
1817
1843
  if (typeof enableGitignore !== "boolean") {
1818
- configs.push(
1844
+ configs2.push(
1819
1845
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1820
1846
  r(enableGitignore)
1821
1847
  ])
1822
1848
  );
1823
1849
  } else {
1824
1850
  if (import_node_fs.default.existsSync(".gitignore"))
1825
- configs.push(
1851
+ configs2.push(
1826
1852
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1827
1853
  r()
1828
1854
  ])
1829
1855
  );
1830
1856
  }
1831
1857
  }
1832
- configs.push(
1858
+ configs2.push(
1833
1859
  ignores(),
1834
1860
  javascript({
1835
1861
  isInEditor: isInEditor2,
@@ -1847,7 +1873,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1847
1873
  if (enableVue)
1848
1874
  componentExts.push("vue");
1849
1875
  if (enableTypeScript) {
1850
- configs.push(
1876
+ configs2.push(
1851
1877
  typescript({
1852
1878
  ...resolveSubOptions(options, "typescript"),
1853
1879
  componentExts,
@@ -1855,8 +1881,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1855
1881
  })
1856
1882
  );
1857
1883
  }
1884
+ if (enableRegexp)
1885
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1858
1886
  if (options.test ?? true) {
1859
- configs.push(
1887
+ configs2.push(
1860
1888
  test({
1861
1889
  isInEditor: isInEditor2,
1862
1890
  overrides: getOverrides(options, "test")
@@ -1864,7 +1892,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1864
1892
  );
1865
1893
  }
1866
1894
  if (enableVue) {
1867
- configs.push(
1895
+ configs2.push(
1868
1896
  vue({
1869
1897
  ...resolveSubOptions(options, "vue"),
1870
1898
  overrides: getOverrides(options, "typescript"),
@@ -1873,7 +1901,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1873
1901
  );
1874
1902
  }
1875
1903
  if (enableReact) {
1876
- configs.push(
1904
+ configs2.push(
1877
1905
  react({
1878
1906
  overrides: getOverrides(options, "react"),
1879
1907
  typescript: !!enableTypeScript
@@ -1881,7 +1909,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1881
1909
  );
1882
1910
  }
1883
1911
  if (enableSvelte) {
1884
- configs.push(
1912
+ configs2.push(
1885
1913
  svelte({
1886
1914
  overrides: getOverrides(options, "svelte"),
1887
1915
  typescript: !!enableTypeScript
@@ -1889,7 +1917,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1889
1917
  );
1890
1918
  }
1891
1919
  if (enableUnoCSS) {
1892
- configs.push(
1920
+ configs2.push(
1893
1921
  unocss({
1894
1922
  ...resolveSubOptions(options, "unocss"),
1895
1923
  overrides: getOverrides(options, "unocss")
@@ -1897,7 +1925,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1897
1925
  );
1898
1926
  }
1899
1927
  if (enableTailwindCSS) {
1900
- configs.push(
1928
+ configs2.push(
1901
1929
  tailwindcss({
1902
1930
  ...resolveSubOptions(options, "tailwindcss"),
1903
1931
  overrides: getOverrides(options, "tailwindcss")
@@ -1905,7 +1933,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1905
1933
  );
1906
1934
  }
1907
1935
  if (options.jsonc ?? true) {
1908
- configs.push(
1936
+ configs2.push(
1909
1937
  jsonc({
1910
1938
  overrides: getOverrides(options, "jsonc")
1911
1939
  }),
@@ -1926,12 +1954,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1926
1954
  );
1927
1955
  Object.assign(prettierRules2, prettierConfig);
1928
1956
  }
1929
- configs.push(
1957
+ configs2.push(
1930
1958
  prettier(prettierRules2),
1931
1959
  formatter(formatterOptions, prettierRules2)
1932
1960
  );
1933
1961
  } else {
1934
- configs.push(prettier());
1962
+ configs2.push(prettier());
1935
1963
  }
1936
1964
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1937
1965
  if (key in options)
@@ -1939,8 +1967,8 @@ async function defineConfig(options = {}, ...userConfigs) {
1939
1967
  return acc;
1940
1968
  }, {});
1941
1969
  if (Object.keys(fusedConfig).length > 0)
1942
- configs.push([fusedConfig]);
1943
- const merged = await combine(...configs, ...userConfigs);
1970
+ configs2.push([fusedConfig]);
1971
+ const merged = await combine(...configs2, ...userConfigs);
1944
1972
  if (autoRenamePlugins)
1945
1973
  return renamePluginInConfigs(merged, defaultPluginRenaming);
1946
1974
  return merged;