@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/cli.cjs CHANGED
@@ -46,32 +46,32 @@ 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.3.4";
49
+ var version = "2.4.1";
50
50
  var devDependencies = {
51
51
  "@antfu/ni": "^0.21.12",
52
- "@eslint/config-inspector": "^0.4.6",
53
- "@types/eslint": "^8.56.9",
52
+ "@eslint/config-inspector": "^0.4.8",
53
+ "@types/eslint": "^8.56.10",
54
54
  "@types/fs-extra": "^11.0.4",
55
- "@types/node": "^20.12.7",
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.59.2",
59
- bumpp: "^9.4.0",
60
- eslint: "9.0.0",
58
+ "@unocss/eslint-plugin": "^0.60.2",
59
+ bumpp: "^9.4.1",
60
+ eslint: "9.2.0",
61
61
  "eslint-plugin-react": "^7.34.1",
62
- "eslint-plugin-react-hooks": "^4.6.0",
63
- "eslint-plugin-react-refresh": "^0.4.6",
64
- "eslint-plugin-svelte": "2.36.0",
65
- execa: "^8.0.1",
62
+ "eslint-plugin-react-hooks": "^4.6.2",
63
+ "eslint-plugin-react-refresh": "^0.4.7",
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.13",
72
- "svelte-eslint-parser": "^0.34.1",
71
+ svelte: "^4.2.17",
72
+ "svelte-eslint-parser": "^0.36.0",
73
73
  tsup: "^8.0.2",
74
- tsx: "^4.7.2",
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,32 +17,32 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.3.4";
20
+ var version = "2.4.1";
21
21
  var devDependencies = {
22
22
  "@antfu/ni": "^0.21.12",
23
- "@eslint/config-inspector": "^0.4.6",
24
- "@types/eslint": "^8.56.9",
23
+ "@eslint/config-inspector": "^0.4.8",
24
+ "@types/eslint": "^8.56.10",
25
25
  "@types/fs-extra": "^11.0.4",
26
- "@types/node": "^20.12.7",
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.59.2",
30
- bumpp: "^9.4.0",
31
- eslint: "9.0.0",
29
+ "@unocss/eslint-plugin": "^0.60.2",
30
+ bumpp: "^9.4.1",
31
+ eslint: "9.2.0",
32
32
  "eslint-plugin-react": "^7.34.1",
33
- "eslint-plugin-react-hooks": "^4.6.0",
34
- "eslint-plugin-react-refresh": "^0.4.6",
35
- "eslint-plugin-svelte": "2.36.0",
36
- execa: "^8.0.1",
33
+ "eslint-plugin-react-hooks": "^4.6.2",
34
+ "eslint-plugin-react-refresh": "^0.4.7",
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.13",
43
- "svelte-eslint-parser": "^0.34.1",
42
+ svelte: "^4.2.17",
43
+ "svelte-eslint-parser": "^0.36.0",
44
44
  tsup: "^8.0.2",
45
- tsx: "^4.7.2",
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,12 +1128,12 @@ 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",
1135
1135
  "unicorn/escape-case": "error",
1136
- "unicorn/explicit-length-check": "error",
1136
+ // 'unicorn/explicit-length-check': 'error',
1137
1137
  // 'unicorn/filename-case': [
1138
1138
  // 'error',
1139
1139
  // {
@@ -1142,9 +1142,10 @@ async function unicorn() {
1142
1142
  // },
1143
1143
  // ],
1144
1144
  "unicorn/new-for-builtins": "error",
1145
- "unicorn/no-array-callback-reference": "error",
1145
+ // 'unicorn/no-array-callback-reference': 'error',
1146
1146
  "unicorn/no-array-method-this-argument": "error",
1147
1147
  "unicorn/no-array-push-push": "error",
1148
+ "unicorn/no-await-in-promise-methods": "error",
1148
1149
  "unicorn/no-console-spaces": "error",
1149
1150
  "unicorn/no-for-loop": "error",
1150
1151
  "unicorn/no-hex-escape": "error",
@@ -1153,6 +1154,7 @@ async function unicorn() {
1153
1154
  "unicorn/no-lonely-if": "error",
1154
1155
  "unicorn/no-new-array": "error",
1155
1156
  "unicorn/no-new-buffer": "error",
1157
+ "unicorn/no-single-promise-in-promise-methods": "error",
1156
1158
  "unicorn/no-static-only-class": "error",
1157
1159
  "unicorn/no-unnecessary-await": "error",
1158
1160
  "unicorn/no-zero-fractions": `error`,
@@ -1180,12 +1182,13 @@ async function unicorn() {
1180
1182
  "unicorn/prefer-prototype-methods": "error",
1181
1183
  "unicorn/prefer-query-selector": "error",
1182
1184
  "unicorn/prefer-reflect-apply": "error",
1183
- "unicorn/prefer-regexp-test": "error",
1185
+ // 'unicorn/prefer-regexp-test': 'error',
1184
1186
  "unicorn/prefer-string-replace-all": "error",
1185
1187
  "unicorn/prefer-string-slice": "error",
1186
1188
  "unicorn/prefer-string-starts-ends-with": "error",
1187
1189
  "unicorn/prefer-string-trim-start-end": "error",
1188
- "unicorn/prefer-top-level-await": "error",
1190
+ // top level await is not supported in all environments
1191
+ // 'unicorn/prefer-top-level-await': 'error',
1189
1192
  "unicorn/prefer-type-error": "error",
1190
1193
  "unicorn/throw-new-error": "error"
1191
1194
  }
@@ -1591,7 +1594,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1591
1594
  };
1592
1595
  return config;
1593
1596
  }
1594
- const configs = [
1597
+ const configs2 = [
1595
1598
  {
1596
1599
  name: "coderwyd/formatter/setup",
1597
1600
  plugins: {
@@ -1601,34 +1604,34 @@ async function formatter(options = {}, prettierRules2 = {}) {
1601
1604
  ];
1602
1605
  if (html) {
1603
1606
  const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
1604
- configs.push(htmlConfig);
1607
+ configs2.push(htmlConfig);
1605
1608
  }
1606
1609
  if (css) {
1607
1610
  const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
1608
1611
  const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
1609
1612
  const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
1610
- configs.push(cssConfig, scssConfig, lessConfig);
1613
+ configs2.push(cssConfig, scssConfig, lessConfig);
1611
1614
  }
1612
1615
  if (markdown) {
1613
1616
  const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
1614
- configs.push(markdownConfig);
1617
+ configs2.push(markdownConfig);
1615
1618
  }
1616
1619
  if (graphql) {
1617
1620
  const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
1618
- configs.push(graphqlConfig);
1621
+ configs2.push(graphqlConfig);
1619
1622
  }
1620
1623
  if (yaml) {
1621
1624
  const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
1622
- configs.push(yamlConfig);
1625
+ configs2.push(yamlConfig);
1623
1626
  }
1624
1627
  if (toml) {
1625
1628
  await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
1626
1629
  const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
1627
1630
  "prettier-plugin-toml"
1628
1631
  ]);
1629
- configs.push(tomlConfig);
1632
+ configs2.push(tomlConfig);
1630
1633
  }
1631
- return configs;
1634
+ return configs2;
1632
1635
  }
1633
1636
 
1634
1637
  // src/configs/svelte.ts
@@ -1752,6 +1755,42 @@ async function tailwindcss(options = {}) {
1752
1755
  ];
1753
1756
  }
1754
1757
 
1758
+ // src/configs/command.ts
1759
+ var import_config = __toESM(require("eslint-plugin-command/config"), 1);
1760
+ async function command() {
1761
+ return [
1762
+ {
1763
+ ...(0, import_config.default)(),
1764
+ name: "coderwyd/command/rules"
1765
+ }
1766
+ ];
1767
+ }
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
+
1755
1794
  // src/env.ts
1756
1795
  var import_node_process3 = __toESM(require("process"), 1);
1757
1796
  var import_local_pkg3 = require("local-pkg");
@@ -1791,6 +1830,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1791
1830
  gitignore: enableGitignore = true,
1792
1831
  isInEditor: isInEditor2 = isInEditor,
1793
1832
  react: enableReact = false,
1833
+ regexp: enableRegexp = true,
1794
1834
  svelte: enableSvelte = false,
1795
1835
  tailwindcss: enableTailwindCSS = hasTailwindCSS,
1796
1836
  typescript: enableTypeScript = hasTypeScript,
@@ -1798,24 +1838,24 @@ async function defineConfig(options = {}, ...userConfigs) {
1798
1838
  usePrettierrc = true,
1799
1839
  vue: enableVue = hasVue
1800
1840
  } = options;
1801
- const configs = [];
1841
+ const configs2 = [];
1802
1842
  if (enableGitignore) {
1803
1843
  if (typeof enableGitignore !== "boolean") {
1804
- configs.push(
1844
+ configs2.push(
1805
1845
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1806
1846
  r(enableGitignore)
1807
1847
  ])
1808
1848
  );
1809
1849
  } else {
1810
1850
  if (import_node_fs.default.existsSync(".gitignore"))
1811
- configs.push(
1851
+ configs2.push(
1812
1852
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1813
1853
  r()
1814
1854
  ])
1815
1855
  );
1816
1856
  }
1817
1857
  }
1818
- configs.push(
1858
+ configs2.push(
1819
1859
  ignores(),
1820
1860
  javascript({
1821
1861
  isInEditor: isInEditor2,
@@ -1826,13 +1866,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1826
1866
  jsdoc(),
1827
1867
  imports(),
1828
1868
  unicorn(),
1869
+ command(),
1829
1870
  // Optional plugins (installed but not enabled by default)
1830
1871
  perfectionist()
1831
1872
  );
1832
1873
  if (enableVue)
1833
1874
  componentExts.push("vue");
1834
1875
  if (enableTypeScript) {
1835
- configs.push(
1876
+ configs2.push(
1836
1877
  typescript({
1837
1878
  ...resolveSubOptions(options, "typescript"),
1838
1879
  componentExts,
@@ -1840,8 +1881,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1840
1881
  })
1841
1882
  );
1842
1883
  }
1884
+ if (enableRegexp)
1885
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1843
1886
  if (options.test ?? true) {
1844
- configs.push(
1887
+ configs2.push(
1845
1888
  test({
1846
1889
  isInEditor: isInEditor2,
1847
1890
  overrides: getOverrides(options, "test")
@@ -1849,7 +1892,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1849
1892
  );
1850
1893
  }
1851
1894
  if (enableVue) {
1852
- configs.push(
1895
+ configs2.push(
1853
1896
  vue({
1854
1897
  ...resolveSubOptions(options, "vue"),
1855
1898
  overrides: getOverrides(options, "typescript"),
@@ -1858,7 +1901,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1858
1901
  );
1859
1902
  }
1860
1903
  if (enableReact) {
1861
- configs.push(
1904
+ configs2.push(
1862
1905
  react({
1863
1906
  overrides: getOverrides(options, "react"),
1864
1907
  typescript: !!enableTypeScript
@@ -1866,7 +1909,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1866
1909
  );
1867
1910
  }
1868
1911
  if (enableSvelte) {
1869
- configs.push(
1912
+ configs2.push(
1870
1913
  svelte({
1871
1914
  overrides: getOverrides(options, "svelte"),
1872
1915
  typescript: !!enableTypeScript
@@ -1874,7 +1917,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1874
1917
  );
1875
1918
  }
1876
1919
  if (enableUnoCSS) {
1877
- configs.push(
1920
+ configs2.push(
1878
1921
  unocss({
1879
1922
  ...resolveSubOptions(options, "unocss"),
1880
1923
  overrides: getOverrides(options, "unocss")
@@ -1882,7 +1925,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1882
1925
  );
1883
1926
  }
1884
1927
  if (enableTailwindCSS) {
1885
- configs.push(
1928
+ configs2.push(
1886
1929
  tailwindcss({
1887
1930
  ...resolveSubOptions(options, "tailwindcss"),
1888
1931
  overrides: getOverrides(options, "tailwindcss")
@@ -1890,7 +1933,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1890
1933
  );
1891
1934
  }
1892
1935
  if (options.jsonc ?? true) {
1893
- configs.push(
1936
+ configs2.push(
1894
1937
  jsonc({
1895
1938
  overrides: getOverrides(options, "jsonc")
1896
1939
  }),
@@ -1911,12 +1954,12 @@ async function defineConfig(options = {}, ...userConfigs) {
1911
1954
  );
1912
1955
  Object.assign(prettierRules2, prettierConfig);
1913
1956
  }
1914
- configs.push(
1957
+ configs2.push(
1915
1958
  prettier(prettierRules2),
1916
1959
  formatter(formatterOptions, prettierRules2)
1917
1960
  );
1918
1961
  } else {
1919
- configs.push(prettier());
1962
+ configs2.push(prettier());
1920
1963
  }
1921
1964
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1922
1965
  if (key in options)
@@ -1924,8 +1967,8 @@ async function defineConfig(options = {}, ...userConfigs) {
1924
1967
  return acc;
1925
1968
  }, {});
1926
1969
  if (Object.keys(fusedConfig).length > 0)
1927
- configs.push([fusedConfig]);
1928
- const merged = await combine(...configs, ...userConfigs);
1970
+ configs2.push([fusedConfig]);
1971
+ const merged = await combine(...configs2, ...userConfigs);
1929
1972
  if (autoRenamePlugins)
1930
1973
  return renamePluginInConfigs(merged, defaultPluginRenaming);
1931
1974
  return merged;