@coderwyd/eslint-config 4.9.1 → 4.10.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.mjs CHANGED
@@ -11,7 +11,7 @@ import { fileURLToPath } from "node:url";
11
11
  import { getPackageInfoSync, isPackageExists } from "local-pkg";
12
12
  import globals from "globals";
13
13
  import prettierRules from "eslint-config-prettier";
14
- import { configs } from "eslint-plugin-regexp";
14
+ import { configs as configs$1 } from "eslint-plugin-regexp";
15
15
 
16
16
  //#region src/configs/command.ts
17
17
  function command() {
@@ -122,8 +122,8 @@ const isCwdInScope = isPackageExists("@coderwyd/eslint-config");
122
122
  /**
123
123
  * Combine array and non-array configs into a single array.
124
124
  */
125
- async function combine(...configs$1) {
126
- return (await Promise.all(configs$1)).flat();
125
+ async function combine(...configs) {
126
+ return (await Promise.all(configs)).flat();
127
127
  }
128
128
  /**
129
129
  * Rename plugin prefixes in a rule object.
@@ -163,8 +163,8 @@ function renameRules(rules, map) {
163
163
  * })
164
164
  * ```
165
165
  */
166
- function renamePluginInConfigs(configs$1, map) {
167
- return configs$1.map((i) => {
166
+ function renamePluginInConfigs(configs, map) {
167
+ return configs.map((i) => {
168
168
  const clone = { ...i };
169
169
  if (clone.rules) clone.rules = renameRules(clone.rules, map);
170
170
  if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
@@ -243,7 +243,7 @@ async function imports() {
243
243
  //#endregion
244
244
  //#region src/configs/javascript.ts
245
245
  function javascript(options = {}) {
246
- const { isInEditor: isInEditor$1 = false, overrides = {} } = options;
246
+ const { isInEditor = false, overrides = {} } = options;
247
247
  return [{
248
248
  languageOptions: {
249
249
  ecmaVersion: "latest",
@@ -444,7 +444,7 @@ function javascript(options = {}) {
444
444
  "require-yield": "error",
445
445
  "symbol-description": "error",
446
446
  "unicode-bom": ["error", "never"],
447
- "unused-imports/no-unused-imports": isInEditor$1 ? "off" : "error",
447
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
448
448
  "unused-imports/no-unused-vars": ["error", {
449
449
  args: "after-used",
450
450
  argsIgnorePattern: "^_",
@@ -637,10 +637,7 @@ async function pnpm() {
637
637
  name: "coderwyd/pnpm/pnpm-workspace-yaml",
638
638
  plugins: { pnpm: pluginPnpm },
639
639
  rules: {
640
- "pnpm/yaml-enforce-settings": ["error", { settings: {
641
- shellEmulator: true,
642
- trustPolicy: "no-downgrade"
643
- } }],
640
+ "pnpm/yaml-enforce-settings": ["error", { settings: { shellEmulator: true } }],
644
641
  "pnpm/yaml-no-duplicate-catalog-item": "error",
645
642
  "pnpm/yaml-no-unused-catalog-item": "error"
646
643
  }
@@ -836,7 +833,7 @@ async function react(options = {}) {
836
833
  //#endregion
837
834
  //#region src/configs/regexp.ts
838
835
  function regexp(options = {}) {
839
- const config = configs["flat/recommended"];
836
+ const config = configs$1["flat/recommended"];
840
837
  const rules = { ...config.rules };
841
838
  if (options.level === "warn") Object.keys(rules).forEach((key) => {
842
839
  if (rules[key] === "error") rules[key] = "warn";
@@ -1299,7 +1296,7 @@ async function tailwindcss(options = {}) {
1299
1296
  //#region src/configs/test.ts
1300
1297
  let _pluginTest;
1301
1298
  async function test(options = {}) {
1302
- const { files = GLOB_TESTS, isInEditor: isInEditor$1 = false, overrides = {} } = options;
1299
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1303
1300
  const [pluginVitest, pluginNoOnlyTests] = await Promise.all([interopDefault(import("@vitest/eslint-plugin")), interopDefault(import("eslint-plugin-no-only-tests"))]);
1304
1301
  _pluginTest = _pluginTest || {
1305
1302
  ...pluginVitest,
@@ -1322,7 +1319,7 @@ async function test(options = {}) {
1322
1319
  }],
1323
1320
  "test/no-identical-title": "error",
1324
1321
  "test/no-import-node-test": "error",
1325
- "test/no-only-tests": isInEditor$1 ? "off" : "error",
1322
+ "test/no-only-tests": isInEditor ? "off" : "error",
1326
1323
  "test/prefer-hooks-in-order": "error",
1327
1324
  "test/prefer-lowercase-title": "error",
1328
1325
  "ts/explicit-function-return-type": "off",
@@ -1397,10 +1394,10 @@ async function typescript(options = {}) {
1397
1394
  "ts/unbound-method": "error"
1398
1395
  };
1399
1396
  const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
1400
- function makeParser(typeAware, files$1, ignores$1) {
1397
+ function makeParser(typeAware, files, ignores) {
1401
1398
  return {
1402
- files: files$1,
1403
- ...ignores$1 ? { ignores: ignores$1 } : {},
1399
+ files,
1400
+ ...ignores ? { ignores } : {},
1404
1401
  languageOptions: {
1405
1402
  parser: parserTs,
1406
1403
  parserOptions: {
@@ -1591,19 +1588,27 @@ async function vue(options = {}) {
1591
1588
  const { files = [GLOB_VUE], overrides = {} } = options;
1592
1589
  const [pluginVue, parserVue] = await Promise.all([interopDefault(import("eslint-plugin-vue")), interopDefault(import("vue-eslint-parser"))]);
1593
1590
  const isVue3 = getVueVersion() === 3;
1594
- const vueRules = (isVue3 ? [
1595
- "essential",
1596
- "strongly-recommended",
1597
- "recommended"
1591
+ const configKeys = isVue3 ? [
1592
+ "flat/essential",
1593
+ "flat/strongly-recommended",
1594
+ "flat/recommended"
1598
1595
  ] : [
1599
- "vue2-essential",
1600
- "vue2-strongly-recommended",
1601
- "vue2-recommended"
1602
- ]).reduce((preRules, key) => {
1596
+ "flat/vue2-essential",
1597
+ "flat/vue2-strongly-recommended",
1598
+ "flat/vue2-recommended"
1599
+ ];
1600
+ function extractRules(config) {
1601
+ if (Array.isArray(config)) return config.reduce((acc, c) => {
1602
+ if (c && c.rules) Object.assign(acc, c.rules);
1603
+ return acc;
1604
+ }, {});
1605
+ return config?.rules ?? {};
1606
+ }
1607
+ const vueRules = configKeys.reduce((preRules, key) => {
1603
1608
  const config = pluginVue.configs[key];
1604
1609
  return {
1605
1610
  ...preRules,
1606
- ...config.rules
1611
+ ...extractRules(config)
1607
1612
  };
1608
1613
  }, {});
1609
1614
  return [{
@@ -1621,7 +1626,7 @@ async function vue(options = {}) {
1621
1626
  plugins: { vue: pluginVue },
1622
1627
  processor: pluginVue.processors[".vue"],
1623
1628
  rules: {
1624
- ...pluginVue.configs.base.rules,
1629
+ ...pluginVue.configs["flat/base"].rules,
1625
1630
  ...vueRules,
1626
1631
  "antfu/no-top-level-await": "off",
1627
1632
  "node/prefer-global/process": "off",
@@ -1646,15 +1651,6 @@ async function vue(options = {}) {
1646
1651
  "defineSlots"
1647
1652
  ] }],
1648
1653
  "vue/eqeqeq": ["error", "smart"],
1649
- "vue/html-self-closing": ["error", {
1650
- html: {
1651
- component: "always",
1652
- normal: "always",
1653
- void: "any"
1654
- },
1655
- math: "always",
1656
- svg: "always"
1657
- }],
1658
1654
  "vue/max-attributes-per-line": "off",
1659
1655
  "vue/multi-word-component-names": "off",
1660
1656
  "vue/no-constant-condition": "warn",
@@ -1809,69 +1805,69 @@ const defaultPluginRenaming = {
1809
1805
  */
1810
1806
  async function defineConfig(options = {}, ...userConfigs) {
1811
1807
  const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, pnpm: enableCatalogs = false, react: enableReact = false, regexp: enableRegexp = true, svelte: enableSvelte = false, tailwindcss: enableTailwindCSS = false, typescript: enableTypeScript = isUsingTypeScript, unocss: enableUnoCSS = false, vue: enableVue = isUsingVue } = options;
1812
- let isInEditor$1 = options.isInEditor;
1813
- if (isInEditor$1 == null) {
1814
- isInEditor$1 = isInEditorEnv();
1815
- if (isInEditor$1) console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
1808
+ let isInEditor = options.isInEditor;
1809
+ if (isInEditor == null) {
1810
+ isInEditor = isInEditorEnv();
1811
+ if (isInEditor) console.log("[@coderwyd/eslint-config] Detected running in editor, some rules are disabled.");
1816
1812
  }
1817
- const configs$1 = [];
1818
- if (enableGitignore) if (typeof enableGitignore !== "boolean") configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1813
+ const configs = [];
1814
+ if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1819
1815
  ...enableGitignore,
1820
1816
  name: "coderwyd/gitignore"
1821
1817
  })]));
1822
- else configs$1.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1818
+ else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
1823
1819
  name: "coderwyd/gitignore",
1824
1820
  strict: false
1825
1821
  })]));
1826
1822
  const typescriptOptions = resolveSubOptions(options, "typescript");
1827
1823
  const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1828
- configs$1.push(ignores(options.ignores), javascript({
1829
- isInEditor: isInEditor$1,
1824
+ configs.push(ignores(options.ignores), javascript({
1825
+ isInEditor,
1830
1826
  overrides: getOverrides(options, "javascript")
1831
1827
  }), comments(), node(), jsdoc(), imports(), unicorn(), command(), deMorgan(), perfectionist(), sortPnpmWorkspace());
1832
1828
  if (enableVue) componentExts.push("vue");
1833
- if (enableTypeScript) configs$1.push(typescript({
1829
+ if (enableTypeScript) configs.push(typescript({
1834
1830
  ...typescriptOptions,
1835
1831
  componentExts,
1836
1832
  overrides: getOverrides(options, "typescript")
1837
1833
  }));
1838
- if (enableRegexp) configs$1.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1839
- if (options.test ?? true) configs$1.push(test({
1840
- isInEditor: isInEditor$1,
1834
+ if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1835
+ if (options.test ?? true) configs.push(test({
1836
+ isInEditor,
1841
1837
  overrides: getOverrides(options, "test")
1842
1838
  }));
1843
- if (enableVue) configs$1.push(vue({
1839
+ if (enableVue) configs.push(vue({
1844
1840
  ...resolveSubOptions(options, "vue"),
1845
1841
  overrides: getOverrides(options, "typescript"),
1846
1842
  typescript: !!enableTypeScript
1847
1843
  }));
1848
- if (enableReact) configs$1.push(react({
1844
+ if (enableReact) configs.push(react({
1849
1845
  overrides: getOverrides(options, "react"),
1850
1846
  tsconfigPath
1851
1847
  }));
1852
- if (enableSvelte) configs$1.push(svelte({
1848
+ if (enableSvelte) configs.push(svelte({
1853
1849
  overrides: getOverrides(options, "svelte"),
1854
1850
  typescript: !!enableTypeScript
1855
1851
  }));
1856
- if (enableUnoCSS) configs$1.push(unocss({
1852
+ if (enableUnoCSS) configs.push(unocss({
1857
1853
  ...resolveSubOptions(options, "unocss"),
1858
1854
  overrides: getOverrides(options, "unocss")
1859
1855
  }));
1860
- if (enableTailwindCSS) configs$1.push(tailwindcss({
1856
+ if (enableTailwindCSS) configs.push(tailwindcss({
1861
1857
  ...resolveSubOptions(options, "tailwindcss"),
1862
1858
  overrides: getOverrides(options, "tailwindcss")
1863
1859
  }));
1864
- if (options.jsonc ?? true) configs$1.push(jsonc({ overrides: getOverrides(options, "jsonc") }), sortPackageJson(), sortTsconfig());
1865
- if (enableCatalogs) configs$1.push(pnpm());
1866
- if (options.yaml ?? true) configs$1.push(yaml({ overrides: getOverrides(options, "yaml") }));
1867
- configs$1.push(specials(), prettier());
1860
+ if (options.jsonc ?? true) configs.push(jsonc({ overrides: getOverrides(options, "jsonc") }), sortPackageJson(), sortTsconfig());
1861
+ if (enableCatalogs) configs.push(pnpm());
1862
+ if (options.yaml ?? true) configs.push(yaml({ overrides: getOverrides(options, "yaml") }));
1863
+ configs.push(specials(), prettier());
1868
1864
  if ("files" in options) throw new Error("[@coderwyd/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
1869
1865
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1870
1866
  if (key in options) acc[key] = options[key];
1871
1867
  return acc;
1872
1868
  }, {});
1873
- if (Object.keys(fusedConfig).length > 0) configs$1.push([fusedConfig]);
1874
- const merged = await combine(...configs$1, ...userConfigs);
1869
+ if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
1870
+ const merged = await combine(...configs, ...userConfigs);
1875
1871
  if (autoRenamePlugins) return renamePluginInConfigs(merged, defaultPluginRenaming);
1876
1872
  return merged;
1877
1873
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "4.9.1",
4
+ "version": "4.10.1",
5
5
  "description": "Donny's ESLint config",
6
6
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
7
7
  "license": "MIT",
@@ -25,10 +25,8 @@
25
25
  "./cli": "./dist/cli.mjs",
26
26
  "./package.json": "./package.json"
27
27
  },
28
- "main": "./dist/index.mjs",
29
- "module": "./dist/index.mjs",
30
28
  "types": "./dist/index.d.mts",
31
- "bin": "./bin/index.js",
29
+ "bin": "./bin/index.mjs",
32
30
  "files": [
33
31
  "bin",
34
32
  "dist"
@@ -74,10 +72,10 @@
74
72
  },
75
73
  "dependencies": {
76
74
  "@antfu/install-pkg": "^1.1.0",
77
- "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
78
- "@typescript-eslint/eslint-plugin": "^8.52.0",
79
- "@typescript-eslint/parser": "^8.52.0",
80
- "@vitest/eslint-plugin": "^1.6.5",
75
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.6.0",
76
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
77
+ "@typescript-eslint/parser": "^8.53.1",
78
+ "@vitest/eslint-plugin": "^1.6.6",
81
79
  "cac": "^6.7.14",
82
80
  "eslint-config-flat-gitignore": "^2.1.0",
83
81
  "eslint-config-prettier": "^10.1.8",
@@ -87,47 +85,47 @@
87
85
  "eslint-plugin-import-lite": "^0.5.0",
88
86
  "eslint-plugin-jsdoc": "61.4.1",
89
87
  "eslint-plugin-jsonc": "^2.21.0",
90
- "eslint-plugin-n": "^17.23.1",
88
+ "eslint-plugin-n": "^17.23.2",
91
89
  "eslint-plugin-no-only-tests": "^3.3.0",
92
- "eslint-plugin-perfectionist": "^5.3.0",
93
- "eslint-plugin-pnpm": "^1.4.3",
94
- "eslint-plugin-regexp": "^2.10.0",
90
+ "eslint-plugin-perfectionist": "^5.4.0",
91
+ "eslint-plugin-pnpm": "^1.5.0",
92
+ "eslint-plugin-regexp": "^3.0.0",
95
93
  "eslint-plugin-unicorn": "^62.0.0",
96
94
  "eslint-plugin-unused-imports": "^4.3.0",
97
- "eslint-plugin-vue": "^10.6.2",
98
- "eslint-plugin-yml": "^1.19.1",
99
- "globals": "^17.0.0",
95
+ "eslint-plugin-vue": "^10.7.0",
96
+ "eslint-plugin-yml": "^3.0.0",
97
+ "globals": "^17.1.0",
100
98
  "jsonc-eslint-parser": "^2.4.2",
101
99
  "local-pkg": "^1.1.2",
102
100
  "parse-gitignore": "^2.0.0",
103
101
  "prompts": "^2.4.2",
104
102
  "vue-eslint-parser": "^10.2.0",
105
- "yaml-eslint-parser": "^1.3.2"
103
+ "yaml-eslint-parser": "^2.0.0"
106
104
  },
107
105
  "devDependencies": {
108
- "@eslint-react/eslint-plugin": "^2.5.1",
106
+ "@eslint-react/eslint-plugin": "^2.7.2",
109
107
  "@eslint/config-inspector": "^1.4.2",
110
108
  "@types/eslint-config-prettier": "^6.11.3",
111
- "@types/node": "^25.0.3",
109
+ "@types/node": "^25.0.10",
112
110
  "@types/prompts": "^2.4.9",
113
111
  "@typescript/native-preview": "7.0.0-dev.20260107.1",
114
- "@unocss/eslint-plugin": "^66.5.12",
115
- "bumpp": "^10.3.2",
112
+ "@unocss/eslint-plugin": "^66.6.0",
113
+ "bumpp": "^10.4.0",
116
114
  "eslint": "^9.39.2",
117
115
  "eslint-plugin-react-hooks": "7.0.1",
118
116
  "eslint-plugin-react-refresh": "^0.4.26",
119
- "eslint-plugin-svelte": "^3.13.1",
117
+ "eslint-plugin-svelte": "^3.14.0",
120
118
  "eslint-plugin-tailwindcss": "^3.18.2",
121
119
  "eslint-typegen": "^2.3.0",
122
120
  "jiti": "^2.6.1",
123
121
  "nano-staged": "^0.9.0",
124
- "prettier": "^3.7.4",
125
- "publint": "^0.3.16",
122
+ "prettier": "^3.8.1",
123
+ "publint": "^0.3.17",
126
124
  "simple-git-hooks": "^2.13.1",
127
125
  "svelte-eslint-parser": "^1.4.1",
128
- "tsdown": "^0.18.4",
126
+ "tsdown": "^0.20.1",
129
127
  "typescript": "^5.9.3",
130
- "unplugin-unused": "^0.5.6"
128
+ "unplugin-unused": "^0.5.7"
131
129
  },
132
130
  "simple-git-hooks": {
133
131
  "pre-commit": "pnpm exec nano-staged"
File without changes