@coderwyd/eslint-config 2.3.1 → 2.3.3

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
@@ -24,7 +24,7 @@ import { default as default7 } from "eslint-plugin-perfectionist";
24
24
  async function comments() {
25
25
  return [
26
26
  {
27
- name: "coderwyd:eslint-comments",
27
+ name: "coderwyd/eslint-comments/rules",
28
28
  plugins: {
29
29
  "eslint-comments": default3
30
30
  },
@@ -112,7 +112,7 @@ async function ignores() {
112
112
  async function imports() {
113
113
  return [
114
114
  {
115
- name: "coderwyd:imports",
115
+ name: "coderwyd/imports/rules",
116
116
  plugins: {
117
117
  antfu: default2,
118
118
  import: pluginImport
@@ -152,7 +152,7 @@ async function imports() {
152
152
  },
153
153
  {
154
154
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
155
- name: "coderwyd:imports:bin",
155
+ name: "coderwyd/imports/disables/bin",
156
156
  rules: {
157
157
  "antfu/no-import-dist": "off",
158
158
  "antfu/no-import-node-modules-by-path": "off"
@@ -189,7 +189,7 @@ async function javascript(options = {}) {
189
189
  linterOptions: {
190
190
  reportUnusedDisableDirectives: true
191
191
  },
192
- name: "coderwyd:javascript",
192
+ name: "coderwyd/javascript/rules",
193
193
  plugins: {
194
194
  "unused-imports": default6
195
195
  },
@@ -252,8 +252,8 @@ async function javascript(options = {}) {
252
252
  "no-multi-str": "error",
253
253
  "no-new": "error",
254
254
  "no-new-func": "error",
255
+ "no-new-native-nonconstructor": "error",
255
256
  "no-new-object": "error",
256
- "no-new-symbol": "error",
257
257
  "no-new-wrappers": "error",
258
258
  "no-obj-calls": "error",
259
259
  "no-octal": "error",
@@ -408,13 +408,14 @@ async function javascript(options = {}) {
408
408
  },
409
409
  {
410
410
  files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
411
- name: "coderwyd:scripts-overrides",
411
+ name: "coderwyd/javascript/disables/cli",
412
412
  rules: {
413
413
  "no-console": "off"
414
414
  }
415
415
  },
416
416
  {
417
417
  files: ["**/*.{test,spec}.js?(x)"],
418
+ name: "coderwyd/javascript/disables/test",
418
419
  rules: {
419
420
  "no-unused-expressions": "off"
420
421
  }
@@ -534,7 +535,7 @@ function getOverrides(options, key) {
534
535
  async function jsdoc() {
535
536
  return [
536
537
  {
537
- name: "coderwyd:jsdoc",
538
+ name: "coderwyd/jsdoc/rules",
538
539
  plugins: {
539
540
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
540
541
  },
@@ -573,7 +574,7 @@ async function jsonc(options = {}) {
573
574
  ]);
574
575
  return [
575
576
  {
576
- name: "coderwyd:jsonc:setup",
577
+ name: "coderwyd/jsonc/setup",
577
578
  plugins: {
578
579
  jsonc: pluginJsonc
579
580
  }
@@ -583,7 +584,7 @@ async function jsonc(options = {}) {
583
584
  languageOptions: {
584
585
  parser: parserJsonc
585
586
  },
586
- name: "coderwyd:jsonc:rules",
587
+ name: "coderwyd/jsonc/rules",
587
588
  rules: {
588
589
  "jsonc/no-bigint-literals": "error",
589
590
  "jsonc/no-binary-expression": "error",
@@ -643,7 +644,7 @@ async function jsonc(options = {}) {
643
644
  async function node() {
644
645
  return [
645
646
  {
646
- name: "coderwyd:node",
647
+ name: "coderwyd/node/rules",
647
648
  plugins: {
648
649
  node: default4
649
650
  },
@@ -666,7 +667,7 @@ async function sortPackageJson() {
666
667
  return [
667
668
  {
668
669
  files: ["**/package.json"],
669
- name: "coderwyd:sort-package-json",
670
+ name: "coderwyd/sort/package-json",
670
671
  rules: {
671
672
  "jsonc/sort-array-values": [
672
673
  "error",
@@ -762,7 +763,7 @@ function sortTsconfig() {
762
763
  return [
763
764
  {
764
765
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
765
- name: "coderwyd:sort-tsconfig",
766
+ name: "coderwyd/sort/tsconfig-json",
766
767
  rules: {
767
768
  "jsonc/sort-keys": [
768
769
  "error",
@@ -887,21 +888,21 @@ function sortTsconfig() {
887
888
  // src/configs/prettier.ts
888
889
  import prettierRules from "eslint-config-prettier";
889
890
  var { rules: eslintRules } = prettierRules;
890
- async function prettier(rules) {
891
+ async function prettier(rules = {}) {
891
892
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
892
893
  const pRules = {
893
894
  ...rules
894
895
  };
895
896
  const configs = [
896
897
  {
897
- name: "coderwyd:prettier:setup",
898
+ name: "coderwyd/prettier/setup",
898
899
  plugins: {
899
900
  prettier: pluginPrettier
900
901
  }
901
902
  },
902
903
  {
903
904
  files: GLOB_PRETTIER_LINT,
904
- name: "coderwyd:prettier:rules",
905
+ name: "coderwyd/prettier/rules",
905
906
  rules: {
906
907
  ...eslintRules,
907
908
  "prettier/prettier": ["warn", pRules],
@@ -966,13 +967,13 @@ async function typescript(options = {}) {
966
967
  ...parserOptions
967
968
  }
968
969
  },
969
- name: `coderwyd:typescript:${typeAware ? "type-aware-parser" : "parser"}`
970
+ name: `coderwyd/typescript/${typeAware ? "type-aware-parser" : "parser"}`
970
971
  };
971
972
  }
972
973
  return [
973
974
  {
974
975
  // Install the plugins without globs, so they can be configured separately.
975
- name: "coderwyd:typescript:setup",
976
+ name: "coderwyd/typescript/setup",
976
977
  plugins: {
977
978
  antfu: default2,
978
979
  ts: pluginTs
@@ -985,7 +986,7 @@ async function typescript(options = {}) {
985
986
  ] : [makeParser(false, files)],
986
987
  {
987
988
  files,
988
- name: "coderwyd:typescript:rules",
989
+ name: "coderwyd/typescript/rules",
989
990
  rules: {
990
991
  ...renameRules(
991
992
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
@@ -1033,17 +1034,19 @@ async function typescript(options = {}) {
1033
1034
  ...overrides
1034
1035
  }
1035
1036
  },
1036
- {
1037
- files: filesTypeAware,
1038
- name: "coderwyd:typescript:rules-type-aware",
1039
- rules: {
1040
- ...tsconfigPath ? typeAwareRules : {},
1041
- ...overrides
1037
+ ...isTypeAware ? [
1038
+ {
1039
+ files: filesTypeAware,
1040
+ name: "coderwyd/typescript/rules-type-aware",
1041
+ rules: {
1042
+ ...tsconfigPath ? typeAwareRules : {},
1043
+ ...overrides
1044
+ }
1042
1045
  }
1043
- },
1046
+ ] : [],
1044
1047
  {
1045
1048
  files: ["**/*.d.ts"],
1046
- name: "coderwyd:typescript:dts-overrides",
1049
+ name: "coderwyd/typescript/disables/dts",
1047
1050
  rules: {
1048
1051
  "eslint-comments/no-unlimited-disable": "off",
1049
1052
  "import/no-duplicates": "off",
@@ -1053,14 +1056,14 @@ async function typescript(options = {}) {
1053
1056
  },
1054
1057
  {
1055
1058
  files: ["**/*.{test,spec}.ts?(x)"],
1056
- name: "coderwyd:typescript:tests-overrides",
1059
+ name: "coderwyd/typescript/disables/test",
1057
1060
  rules: {
1058
1061
  "no-unused-expressions": "off"
1059
1062
  }
1060
1063
  },
1061
1064
  {
1062
1065
  files: ["**/*.js", "**/*.cjs"],
1063
- name: "coderwyd:typescript:javascript-overrides",
1066
+ name: "coderwyd/typescript/disables/cjs",
1064
1067
  rules: {
1065
1068
  "ts/no-require-imports": "off",
1066
1069
  "ts/no-var-requires": "off"
@@ -1073,7 +1076,7 @@ async function typescript(options = {}) {
1073
1076
  async function unicorn() {
1074
1077
  return [
1075
1078
  {
1076
- name: "coderwyd:unicorn",
1079
+ name: "coderwyd/unicorn/rules",
1077
1080
  plugins: {
1078
1081
  unicorn: default5
1079
1082
  },
@@ -1181,7 +1184,7 @@ async function vue(options = {}) {
1181
1184
  watchEffect: "readonly"
1182
1185
  }
1183
1186
  },
1184
- name: "coderwyd:vue:setup",
1187
+ name: "coderwyd/vue/setup",
1185
1188
  plugins: {
1186
1189
  vue: pluginVue
1187
1190
  }
@@ -1201,7 +1204,7 @@ async function vue(options = {}) {
1201
1204
  sourceType: "module"
1202
1205
  }
1203
1206
  },
1204
- name: "coderwyd:vue:rules",
1207
+ name: "coderwyd/vue/rules",
1205
1208
  processor: pluginVue.processors[".vue"],
1206
1209
  rules: {
1207
1210
  ...pluginVue.configs.base.rules,
@@ -1336,7 +1339,7 @@ async function test(options = {}) {
1336
1339
  ]);
1337
1340
  return [
1338
1341
  {
1339
- name: "coderwyd:test:setup",
1342
+ name: "coderwyd/test/setup",
1340
1343
  plugins: {
1341
1344
  test: {
1342
1345
  ...pluginVitest,
@@ -1350,7 +1353,7 @@ async function test(options = {}) {
1350
1353
  },
1351
1354
  {
1352
1355
  files,
1353
- name: "coderwyd:test:rules",
1356
+ name: "coderwyd/test/rules",
1354
1357
  rules: {
1355
1358
  "node/prefer-global/process": "off",
1356
1359
  "test/consistent-test-it": [
@@ -1372,7 +1375,7 @@ async function test(options = {}) {
1372
1375
  async function perfectionist() {
1373
1376
  return [
1374
1377
  {
1375
- name: "coderwyd:perfectionist",
1378
+ name: "coderwyd/perfectionist/setup",
1376
1379
  plugins: {
1377
1380
  perfectionist: default7
1378
1381
  }
@@ -1406,7 +1409,7 @@ async function react(options = {}) {
1406
1409
  );
1407
1410
  return [
1408
1411
  {
1409
- name: "coderwyd:react:setup",
1412
+ name: "coderwyd/react/setup",
1410
1413
  plugins: {
1411
1414
  react: pluginReact,
1412
1415
  "react-hooks": pluginReactHooks,
@@ -1427,7 +1430,7 @@ async function react(options = {}) {
1427
1430
  }
1428
1431
  }
1429
1432
  },
1430
- name: "coderwyd:react:rules",
1433
+ name: "coderwyd/react/rules",
1431
1434
  rules: {
1432
1435
  // recommended rules react-hooks
1433
1436
  "react-hooks/exhaustive-deps": "warn",
@@ -1480,7 +1483,7 @@ async function unocss(options = {}) {
1480
1483
  ]);
1481
1484
  return [
1482
1485
  {
1483
- name: "coderwyd:unocss",
1486
+ name: "coderwyd/unocss/rules",
1484
1487
  plugins: {
1485
1488
  unocss: pluginUnoCSS
1486
1489
  },
@@ -1499,21 +1502,14 @@ async function unocss(options = {}) {
1499
1502
 
1500
1503
  // src/configs/formatter.ts
1501
1504
  async function formatter(options = {}, prettierRules2 = {}) {
1502
- const {
1503
- css = true,
1504
- graphql = false,
1505
- html = true,
1506
- markdown = false,
1507
- toml = false,
1508
- yaml = false
1509
- } = typeof options === "object" ? options : {
1505
+ const { css, graphql, html, markdown, toml, yaml } = options === true ? {
1510
1506
  css: true,
1511
1507
  graphql: true,
1512
1508
  html: true,
1513
1509
  markdown: true,
1514
1510
  toml: true,
1515
1511
  yaml: true
1516
- };
1512
+ } : options;
1517
1513
  const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
1518
1514
  function createPrettierFormatter(files, parser, plugins) {
1519
1515
  const rules = {
@@ -1533,7 +1529,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1533
1529
  languageOptions: {
1534
1530
  parser: parserPlain
1535
1531
  },
1536
- name: `coderwyd:formatter:${parser}`,
1532
+ name: `coderwyd/formatter/${parser}`,
1537
1533
  plugins: {
1538
1534
  prettier: pluginPrettier
1539
1535
  },
@@ -1548,7 +1544,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
1548
1544
  }
1549
1545
  const configs = [
1550
1546
  {
1551
- name: "coderwyd:formatter:setup",
1547
+ name: "coderwyd/formatter/setup",
1552
1548
  plugins: {
1553
1549
  prettier: pluginPrettier
1554
1550
  }
@@ -1596,7 +1592,7 @@ async function svelte(options = {}) {
1596
1592
  ]);
1597
1593
  return [
1598
1594
  {
1599
- name: "coderwyd:svelte:setup",
1595
+ name: "coderwyd/svelte/setup",
1600
1596
  plugins: {
1601
1597
  svelte: pluginSvelte
1602
1598
  }
@@ -1612,7 +1608,7 @@ async function svelte(options = {}) {
1612
1608
  ) : null
1613
1609
  }
1614
1610
  },
1615
- name: "coderwyd:svelte:rules",
1611
+ name: "coderwyd/svelte/rules",
1616
1612
  processor: pluginSvelte.processors[".svelte"],
1617
1613
  rules: {
1618
1614
  "import/no-mutable-exports": "off",
@@ -1688,7 +1684,7 @@ async function tailwindcss(options = {}) {
1688
1684
  );
1689
1685
  return [
1690
1686
  {
1691
- name: "coderwyd:tailwindcss",
1687
+ name: "coderwyd/tailwindcss/rules",
1692
1688
  plugins: {
1693
1689
  tailwindcss: pluginTailwindcss
1694
1690
  },
@@ -1739,6 +1735,10 @@ async function defineConfig(options = {}, ...userConfigs) {
1739
1735
  const {
1740
1736
  autoRenamePlugins = true,
1741
1737
  componentExts = [],
1738
+ formatter: formatterOptions = {
1739
+ css: true,
1740
+ html: true
1741
+ },
1742
1742
  gitignore: enableGitignore = true,
1743
1743
  isInEditor: isInEditor2 = isInEditor,
1744
1744
  react: enableReact = false,
@@ -1849,21 +1849,25 @@ async function defineConfig(options = {}, ...userConfigs) {
1849
1849
  sortTsconfig()
1850
1850
  );
1851
1851
  }
1852
- let prettierRules2 = {
1853
- ...DEFAULT_PRETTIER_RULES
1854
- };
1855
- if (options.prettierRules) {
1856
- prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1857
- }
1858
- if (usePrettierrc) {
1859
- const prettierConfig = await loadPrettierConfig(
1860
- options.cwd ?? process4.cwd()
1852
+ if (formatterOptions) {
1853
+ let prettierRules2 = {
1854
+ ...DEFAULT_PRETTIER_RULES
1855
+ };
1856
+ if (options.prettierRules) {
1857
+ prettierRules2 = { ...prettierRules2, ...options.prettierRules };
1858
+ }
1859
+ if (usePrettierrc) {
1860
+ const prettierConfig = await loadPrettierConfig(
1861
+ options.cwd ?? process4.cwd()
1862
+ );
1863
+ Object.assign(prettierRules2, prettierConfig);
1864
+ }
1865
+ configs.push(
1866
+ prettier(prettierRules2),
1867
+ formatter(formatterOptions, prettierRules2)
1861
1868
  );
1862
- Object.assign(prettierRules2, prettierConfig);
1863
- }
1864
- configs.push(prettier(options.formatter ? prettierRules2 : {}));
1865
- if (options.formatter) {
1866
- configs.push(formatter(options.formatter, prettierRules2));
1869
+ } else {
1870
+ configs.push(prettier());
1867
1871
  }
1868
1872
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1869
1873
  if (key in options)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "2.3.1",
5
- "packageManager": "pnpm@8.15.5",
4
+ "version": "2.3.3",
5
+ "packageManager": "pnpm@8.15.6",
6
6
  "description": "Donny's ESLint config",
7
7
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
8
8
  "license": "MIT",
@@ -66,30 +66,27 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "@antfu/eslint-define-config": "1.23.0-2",
70
- "@antfu/install-pkg": "^0.3.1",
71
- "@eslint-types/jsdoc": "48.2.1",
72
- "@eslint-types/typescript-eslint": "^7.2.0",
73
- "@eslint-types/unicorn": "^51.0.1",
69
+ "@antfu/install-pkg": "^0.3.2",
74
70
  "@toml-tools/parser": "^1.0.0",
75
- "@typescript-eslint/eslint-plugin": "^7.4.0",
76
- "@typescript-eslint/parser": "^7.4.0",
77
- "eslint-config-flat-gitignore": "^0.1.3",
71
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
72
+ "@typescript-eslint/parser": "^7.5.0",
73
+ "eslint-config-flat-gitignore": "^0.1.5",
78
74
  "eslint-config-prettier": "^9.1.0",
79
75
  "eslint-plugin-antfu": "^2.1.2",
80
76
  "eslint-plugin-eslint-comments": "^3.2.0",
81
- "eslint-plugin-import-x": "^0.4.4",
82
- "eslint-plugin-jsdoc": "^48.2.1",
83
- "eslint-plugin-jsonc": "^2.14.1",
77
+ "eslint-plugin-import-x": "^0.5.0",
78
+ "eslint-plugin-jsdoc": "^48.2.3",
79
+ "eslint-plugin-jsonc": "^2.15.0",
84
80
  "eslint-plugin-n": "^16.6.2",
85
81
  "eslint-plugin-no-only-tests": "^3.1.0",
86
- "eslint-plugin-perfectionist": "^2.7.0",
82
+ "eslint-plugin-perfectionist": "^2.8.0",
87
83
  "eslint-plugin-prettier": "^5.1.3",
88
84
  "eslint-plugin-tailwindcss": "^3.15.1",
89
- "eslint-plugin-unicorn": "^51.0.1",
85
+ "eslint-plugin-unicorn": "^52.0.0",
90
86
  "eslint-plugin-unused-imports": "^3.1.0",
91
- "eslint-plugin-vitest": "^0.4.0",
87
+ "eslint-plugin-vitest": "^0.4.1",
92
88
  "eslint-plugin-vue": "^9.24.0",
89
+ "eslint-typegen": "^0.2.0",
93
90
  "globals": "^15.0.0",
94
91
  "jsonc-eslint-parser": "^2.4.0",
95
92
  "local-pkg": "^0.5.0",
@@ -103,29 +100,30 @@
103
100
  },
104
101
  "devDependencies": {
105
102
  "@antfu/ni": "^0.21.12",
106
- "@types/eslint": "^8.56.6",
103
+ "@eslint/config-inspector": "^0.4.1",
104
+ "@types/eslint": "^8.56.7",
107
105
  "@types/fs-extra": "^11.0.4",
108
- "@types/node": "^20.11.30",
106
+ "@types/node": "^20.12.5",
109
107
  "@types/prompts": "^2.4.9",
110
108
  "@types/yargs": "^17.0.32",
111
- "@unocss/eslint-plugin": "^0.58.7",
109
+ "@unocss/eslint-plugin": "^0.59.0",
112
110
  "bumpp": "^9.4.0",
113
- "eslint": "9.0.0-rc.0",
114
- "eslint-flat-config-viewer": "^0.1.14",
111
+ "eslint": "9.0.0",
115
112
  "eslint-plugin-react": "^7.34.1",
116
113
  "eslint-plugin-react-hooks": "^4.6.0",
117
114
  "eslint-plugin-react-refresh": "^0.4.6",
118
- "eslint-plugin-svelte": "^2.35.1",
115
+ "eslint-plugin-svelte": "2.36.0-next.13",
119
116
  "execa": "^8.0.1",
120
117
  "fast-glob": "^3.3.2",
121
118
  "fs-extra": "^11.2.0",
122
119
  "lint-staged": "^15.2.2",
123
120
  "rimraf": "^5.0.5",
124
121
  "simple-git-hooks": "^2.11.1",
122
+ "svelte": "^4.2.12",
125
123
  "svelte-eslint-parser": "^0.33.1",
126
124
  "tsup": "^8.0.2",
127
- "tsx": "^4.7.1",
128
- "typescript": "^5.4.3"
125
+ "tsx": "^4.7.2",
126
+ "typescript": "^5.4.4"
129
127
  },
130
128
  "simple-git-hooks": {
131
129
  "pre-commit": "pnpx nano-staged"
@@ -134,10 +132,12 @@
134
132
  "*": "eslint --fix"
135
133
  },
136
134
  "scripts": {
137
- "build": "tsup",
138
- "dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
135
+ "build": "nr typegen && tsup",
136
+ "dev": "tsup --format esm,cjs --watch & npx @eslint/config-inspector",
139
137
  "lint": "eslint .",
140
138
  "lint:fix": "eslint . --fix",
139
+ "build:inspector": "pnpm build && npx @eslint/config-inspector build",
140
+ "typegen": "tsx scripts/typegen.ts",
141
141
  "release": "bumpp && pnpm publish",
142
142
  "typecheck": "tsc --noEmit"
143
143
  }