@kirklin/eslint-config 2.3.0 → 2.3.2

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/README.md CHANGED
@@ -495,7 +495,7 @@ export default kirklin({
495
495
  Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
496
496
 
497
497
  ```bash
498
- npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
498
+ npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
499
499
  ```
500
500
 
501
501
  #### Svelte
@@ -578,23 +578,40 @@ npm i -D @unocss/eslint-plugin
578
578
 
579
579
  This config also provides some optional plugins/rules for extended usage.
580
580
 
581
- #### `perfectionist` (sorting)
581
+ #### `command`
582
582
 
583
- This plugin [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) allows you to sort object keys, imports, etc, with auto-fix.
583
+ Powered by [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command). It is not a typical rule for linting, but an on-demand micro-codemod tool that triggers by specific comments.
584
584
 
585
- The plugin is installed, but no rules are enabled by default.
585
+ For a few triggers, for example:
586
586
 
587
- It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
587
+ - `/// to-function` - converts an arrow function to a normal function
588
+ - `/// to-arrow` - converts a normal function to an arrow function
589
+ - `/// to-for-each` - converts a for-in/for-of loop to `.forEach()`
590
+ - `/// to-for-of` - converts a `.forEach()` to a for-of loop
591
+ - `/// keep-sorted` - sorts an object/array/interface
592
+ - ... etc. - refer to the [documentation](https://github.com/antfu/eslint-plugin-command#built-in-commands)
588
593
 
589
- ```js
590
- /* eslint perfectionist/sort-objects: "error" */
591
- const objectWantedToSort = {
592
- a: 2,
593
- b: 1,
594
- c: 3,
594
+ You can add the trigger comment one line above the code you want to transform, for example (note the triple slash):
595
+
596
+ <!-- eslint-skip -->
597
+
598
+ ```ts
599
+ /// to-function
600
+ const foo = async (msg: string): void => {
601
+ console.log(msg)
595
602
  };
596
603
  ```
597
604
 
605
+ Will be transformed to this when you hit save with your editor or run `eslint . --fix`:
606
+
607
+ ```ts
608
+ async function foo(msg: string): void {
609
+ console.log(msg);
610
+ }
611
+ ```
612
+
613
+ The command comments are usually one-off and will be removed along with the transformation.
614
+
598
615
  ### Type Aware Rules
599
616
 
600
617
  You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
package/README.zh-cn.md CHANGED
@@ -499,7 +499,7 @@ export default kirklin({
499
499
  运行`npx eslint`时,它应该会提示您安装所需的依赖项,如果没有,您可以手动安装它们:
500
500
 
501
501
  ```bash
502
- npm i -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
502
+ npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
503
503
  ```
504
504
 
505
505
  #### Svelte
@@ -582,23 +582,40 @@ npm i -D @unocss/eslint-plugin
582
582
 
583
583
  此配置还提供了一些用于扩展用途的可选插件/规则。
584
584
 
585
- #### `perfectionist`(排序)
585
+ #### `command`
586
586
 
587
- 此插件 [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) 允许您对对象键、导入等进行自动修复的排序。
587
+ [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command) 提供支持。这不是一个典型的代码检查规则,而是一个按需的微型代码修改工具,通过特定的注释触发。
588
588
 
589
- 插件已安装,但默认情况下不启用任何规则。
589
+ 例如,几个触发器包括:
590
590
 
591
- 建议通过使用[配置注释](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1)来为每个文件单独选择启用。
591
+ - `/// to-function` - 将箭头函数转换为普通函数
592
+ - `/// to-arrow` - 将普通函数转换为箭头函数
593
+ - `/// to-for-each` - 将 for-in/for-of 循环转换为 `.forEach()`
594
+ - `/// to-for-of` - 将 `.forEach()` 转换为 for-of 循环
595
+ - `/// keep-sorted` - 对对象/数组/接口进行排序
596
+ - ... 等 - 参考 [文档](https://github.com/antfu/eslint-plugin-command#built-in-commands)
592
597
 
593
- ```js
594
- /* eslint perfectionist/sort-objects: "error" */
595
- const objectWantedToSort = {
596
- a: 2,
597
- b: 1,
598
- c: 3,
598
+ 你可以在想要转换的代码上方添加触发注释,例如(注意三个斜杠):
599
+
600
+ <!-- eslint-skip -->
601
+
602
+ ```typescript
603
+ /// to-function
604
+ const foo = async (msg: string): void => {
605
+ console.log(msg);
599
606
  };
600
607
  ```
601
608
 
609
+ 当你在编辑器中保存或运行 `eslint . --fix` 时,将转换为:
610
+
611
+ ```typescript
612
+ async function foo(msg: string): void {
613
+ console.log(msg);
614
+ }
615
+ ```
616
+
617
+ 命令注释通常是一次性的,一旦转换完成,它们将被一并移除。
618
+
602
619
  ### 类型感知规则
603
620
 
604
621
  您可以通过将选项对象传递给`typescript`配置来选择启用[类型感知规则](https://typescript-eslint.io/linting/typed-linting/):
package/dist/cli.cjs CHANGED
@@ -48,8 +48,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
48
48
  var package_default = {
49
49
  name: "@kirklin/eslint-config",
50
50
  type: "module",
51
- version: "2.3.0",
52
- packageManager: "pnpm@8.15.5",
51
+ version: "2.3.2",
52
+ packageManager: "pnpm@9.0.6",
53
53
  description: "Kirk Lin's ESLint config",
54
54
  author: "Kirk Lin (https://github.com/kirklin/)",
55
55
  license: "MIT",
@@ -87,12 +87,12 @@ var package_default = {
87
87
  prepare: "simple-git-hooks"
88
88
  },
89
89
  peerDependencies: {
90
+ "@eslint-react/eslint-plugin": "^1.5.8",
90
91
  "@unocss/eslint-plugin": ">=0.50.0",
91
92
  "astro-eslint-parser": "^0.16.3",
92
93
  eslint: ">=8.40.0",
93
94
  "eslint-plugin-astro": "^0.31.4",
94
95
  "eslint-plugin-format": ">=0.1.0",
95
- "eslint-plugin-react": "^7.33.2",
96
96
  "eslint-plugin-react-hooks": "^4.6.0",
97
97
  "eslint-plugin-react-refresh": "^0.4.4",
98
98
  "eslint-plugin-solid": "^0.13.2",
@@ -102,6 +102,9 @@ var package_default = {
102
102
  "svelte-eslint-parser": "^0.33.1"
103
103
  },
104
104
  peerDependenciesMeta: {
105
+ "@eslint-react/eslint-plugin": {
106
+ optional: true
107
+ },
105
108
  "@unocss/eslint-plugin": {
106
109
  optional: true
107
110
  },
@@ -114,9 +117,6 @@ var package_default = {
114
117
  "eslint-plugin-format": {
115
118
  optional: true
116
119
  },
117
- "eslint-plugin-react": {
118
- optional: true
119
- },
120
120
  "eslint-plugin-react-hooks": {
121
121
  optional: true
122
122
  },
@@ -140,31 +140,32 @@ var package_default = {
140
140
  }
141
141
  },
142
142
  dependencies: {
143
- "@antfu/install-pkg": "^0.3.2",
143
+ "@antfu/install-pkg": "^0.3.3",
144
144
  "@clack/prompts": "^0.7.0",
145
- "@stylistic/eslint-plugin": "^1.7.0",
146
- "@typescript-eslint/eslint-plugin": "^7.6.0",
147
- "@typescript-eslint/parser": "^7.6.0",
145
+ "@stylistic/eslint-plugin": "^1.7.2",
146
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
147
+ "@typescript-eslint/parser": "^7.7.1",
148
148
  "eslint-config-flat-gitignore": "^0.1.5",
149
- "eslint-flat-config-utils": "^0.2.3",
149
+ "eslint-flat-config-utils": "^0.2.4",
150
150
  "eslint-merge-processors": "^0.1.0",
151
+ "eslint-plugin-command": "^0.1.2",
151
152
  "eslint-plugin-eslint-comments": "^3.2.0",
152
153
  "eslint-plugin-import-x": "^0.5.0",
153
154
  "eslint-plugin-jsdoc": "^48.2.3",
154
155
  "eslint-plugin-jsonc": "^2.15.1",
155
- "eslint-plugin-kirklin": "^1.1.0",
156
+ "eslint-plugin-kirklin": "^1.2.0",
156
157
  "eslint-plugin-markdown": "^4.0.1",
157
- "eslint-plugin-n": "^17.2.1",
158
+ "eslint-plugin-n": "^17.3.1",
158
159
  "eslint-plugin-no-only-tests": "^3.1.0",
159
- "eslint-plugin-perfectionist": "^2.9.0",
160
+ "eslint-plugin-perfectionist": "^2.10.0",
160
161
  "eslint-plugin-toml": "^0.11.0",
161
162
  "eslint-plugin-unicorn": "^52.0.0",
162
163
  "eslint-plugin-unused-imports": "^3.1.0",
163
- "eslint-plugin-vitest": "^0.5.3",
164
+ "eslint-plugin-vitest": "^0.5.4",
164
165
  "eslint-plugin-vue": "^9.25.0",
165
166
  "eslint-plugin-yml": "^1.14.0",
166
- "eslint-processor-vue-blocks": "^0.1.1",
167
- globals: "^15.0.0",
167
+ "eslint-processor-vue-blocks": "^0.1.2",
168
+ globals: "^15.1.0",
168
169
  "jsonc-eslint-parser": "^2.4.0",
169
170
  "local-pkg": "^0.5.0",
170
171
  "parse-gitignore": "^2.0.0",
@@ -177,27 +178,27 @@ var package_default = {
177
178
  devDependencies: {
178
179
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
179
180
  "@antfu/ni": "^0.21.12",
180
- "@eslint/config-inspector": "^0.4.6",
181
+ "@eslint-react/eslint-plugin": "^1.5.10",
182
+ "@eslint/config-inspector": "^0.4.7",
181
183
  "@kirklin/eslint-config": "workspace:*",
182
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
183
- "@types/eslint": "^8.56.9",
184
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
185
+ "@types/eslint": "^8.56.10",
184
186
  "@types/fs-extra": "^11.0.4",
185
187
  "@types/node": "^20.12.7",
186
188
  "@types/prompts": "^2.4.9",
187
189
  "@types/yargs": "^17.0.32",
188
- "@unocss/eslint-plugin": "^0.59.2",
189
- "astro-eslint-parser": "^0.17.0",
190
- bumpp: "^9.4.0",
191
- "bundle-require": "^4.0.2",
192
- eslint: "^9.0.0",
193
- "eslint-plugin-astro": "^0.34.0",
194
- "eslint-plugin-format": "^0.1.0",
195
- "eslint-plugin-react": "^7.34.1",
196
- "eslint-plugin-react-hooks": "^4.6.0",
190
+ "@unocss/eslint-plugin": "^0.59.4",
191
+ "astro-eslint-parser": "^1.0.1",
192
+ bumpp: "^9.4.1",
193
+ "bundle-require": "^4.0.3",
194
+ eslint: "^9.1.1",
195
+ "eslint-plugin-astro": "^1.1.0",
196
+ "eslint-plugin-format": "^0.1.1",
197
+ "eslint-plugin-react-hooks": "^4.6.2",
197
198
  "eslint-plugin-react-refresh": "^0.4.6",
198
- "eslint-plugin-solid": "^0.13.2",
199
- "eslint-plugin-svelte": "2.36.0-next.13",
200
- "eslint-typegen": "^0.2.3",
199
+ "eslint-plugin-solid": "^0.14.0",
200
+ "eslint-plugin-svelte": "2.38.0",
201
+ "eslint-typegen": "^0.2.4",
201
202
  esno: "^4.7.0",
202
203
  execa: "^8.0.1",
203
204
  "fast-glob": "^3.3.2",
@@ -207,12 +208,12 @@ var package_default = {
207
208
  "prettier-plugin-slidev": "^1.0.5",
208
209
  rimraf: "^5.0.5",
209
210
  "simple-git-hooks": "^2.11.1",
210
- svelte: "^4.2.14",
211
- "svelte-eslint-parser": "^0.34.1",
211
+ svelte: "^4.2.15",
212
+ "svelte-eslint-parser": "^0.35.0",
212
213
  tsup: "^8.0.2",
213
214
  typescript: "^5.4.5",
214
- vitest: "^1.5.0",
215
- vue: "^3.4.21"
215
+ vitest: "^1.5.2",
216
+ vue: "^3.4.26"
216
217
  },
217
218
  "simple-git-hooks": {
218
219
  "pre-commit": "pnpm lint-staged"
@@ -312,7 +313,7 @@ var dependenciesMap = {
312
313
  "astro-eslint-parser"
313
314
  ],
314
315
  react: [
315
- "eslint-plugin-react",
316
+ "@eslint-react/eslint-plugin",
316
317
  "eslint-plugin-react-hooks",
317
318
  "eslint-plugin-react-refresh"
318
319
  ],
package/dist/cli.js CHANGED
@@ -19,8 +19,8 @@ import c from "picocolors";
19
19
  var package_default = {
20
20
  name: "@kirklin/eslint-config",
21
21
  type: "module",
22
- version: "2.3.0",
23
- packageManager: "pnpm@8.15.5",
22
+ version: "2.3.2",
23
+ packageManager: "pnpm@9.0.6",
24
24
  description: "Kirk Lin's ESLint config",
25
25
  author: "Kirk Lin (https://github.com/kirklin/)",
26
26
  license: "MIT",
@@ -58,12 +58,12 @@ var package_default = {
58
58
  prepare: "simple-git-hooks"
59
59
  },
60
60
  peerDependencies: {
61
+ "@eslint-react/eslint-plugin": "^1.5.8",
61
62
  "@unocss/eslint-plugin": ">=0.50.0",
62
63
  "astro-eslint-parser": "^0.16.3",
63
64
  eslint: ">=8.40.0",
64
65
  "eslint-plugin-astro": "^0.31.4",
65
66
  "eslint-plugin-format": ">=0.1.0",
66
- "eslint-plugin-react": "^7.33.2",
67
67
  "eslint-plugin-react-hooks": "^4.6.0",
68
68
  "eslint-plugin-react-refresh": "^0.4.4",
69
69
  "eslint-plugin-solid": "^0.13.2",
@@ -73,6 +73,9 @@ var package_default = {
73
73
  "svelte-eslint-parser": "^0.33.1"
74
74
  },
75
75
  peerDependenciesMeta: {
76
+ "@eslint-react/eslint-plugin": {
77
+ optional: true
78
+ },
76
79
  "@unocss/eslint-plugin": {
77
80
  optional: true
78
81
  },
@@ -85,9 +88,6 @@ var package_default = {
85
88
  "eslint-plugin-format": {
86
89
  optional: true
87
90
  },
88
- "eslint-plugin-react": {
89
- optional: true
90
- },
91
91
  "eslint-plugin-react-hooks": {
92
92
  optional: true
93
93
  },
@@ -111,31 +111,32 @@ var package_default = {
111
111
  }
112
112
  },
113
113
  dependencies: {
114
- "@antfu/install-pkg": "^0.3.2",
114
+ "@antfu/install-pkg": "^0.3.3",
115
115
  "@clack/prompts": "^0.7.0",
116
- "@stylistic/eslint-plugin": "^1.7.0",
117
- "@typescript-eslint/eslint-plugin": "^7.6.0",
118
- "@typescript-eslint/parser": "^7.6.0",
116
+ "@stylistic/eslint-plugin": "^1.7.2",
117
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
118
+ "@typescript-eslint/parser": "^7.7.1",
119
119
  "eslint-config-flat-gitignore": "^0.1.5",
120
- "eslint-flat-config-utils": "^0.2.3",
120
+ "eslint-flat-config-utils": "^0.2.4",
121
121
  "eslint-merge-processors": "^0.1.0",
122
+ "eslint-plugin-command": "^0.1.2",
122
123
  "eslint-plugin-eslint-comments": "^3.2.0",
123
124
  "eslint-plugin-import-x": "^0.5.0",
124
125
  "eslint-plugin-jsdoc": "^48.2.3",
125
126
  "eslint-plugin-jsonc": "^2.15.1",
126
- "eslint-plugin-kirklin": "^1.1.0",
127
+ "eslint-plugin-kirklin": "^1.2.0",
127
128
  "eslint-plugin-markdown": "^4.0.1",
128
- "eslint-plugin-n": "^17.2.1",
129
+ "eslint-plugin-n": "^17.3.1",
129
130
  "eslint-plugin-no-only-tests": "^3.1.0",
130
- "eslint-plugin-perfectionist": "^2.9.0",
131
+ "eslint-plugin-perfectionist": "^2.10.0",
131
132
  "eslint-plugin-toml": "^0.11.0",
132
133
  "eslint-plugin-unicorn": "^52.0.0",
133
134
  "eslint-plugin-unused-imports": "^3.1.0",
134
- "eslint-plugin-vitest": "^0.5.3",
135
+ "eslint-plugin-vitest": "^0.5.4",
135
136
  "eslint-plugin-vue": "^9.25.0",
136
137
  "eslint-plugin-yml": "^1.14.0",
137
- "eslint-processor-vue-blocks": "^0.1.1",
138
- globals: "^15.0.0",
138
+ "eslint-processor-vue-blocks": "^0.1.2",
139
+ globals: "^15.1.0",
139
140
  "jsonc-eslint-parser": "^2.4.0",
140
141
  "local-pkg": "^0.5.0",
141
142
  "parse-gitignore": "^2.0.0",
@@ -148,27 +149,27 @@ var package_default = {
148
149
  devDependencies: {
149
150
  "@antfu/eslint-plugin-prettier": "^5.0.1-1",
150
151
  "@antfu/ni": "^0.21.12",
151
- "@eslint/config-inspector": "^0.4.6",
152
+ "@eslint-react/eslint-plugin": "^1.5.10",
153
+ "@eslint/config-inspector": "^0.4.7",
152
154
  "@kirklin/eslint-config": "workspace:*",
153
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
154
- "@types/eslint": "^8.56.9",
155
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
156
+ "@types/eslint": "^8.56.10",
155
157
  "@types/fs-extra": "^11.0.4",
156
158
  "@types/node": "^20.12.7",
157
159
  "@types/prompts": "^2.4.9",
158
160
  "@types/yargs": "^17.0.32",
159
- "@unocss/eslint-plugin": "^0.59.2",
160
- "astro-eslint-parser": "^0.17.0",
161
- bumpp: "^9.4.0",
162
- "bundle-require": "^4.0.2",
163
- eslint: "^9.0.0",
164
- "eslint-plugin-astro": "^0.34.0",
165
- "eslint-plugin-format": "^0.1.0",
166
- "eslint-plugin-react": "^7.34.1",
167
- "eslint-plugin-react-hooks": "^4.6.0",
161
+ "@unocss/eslint-plugin": "^0.59.4",
162
+ "astro-eslint-parser": "^1.0.1",
163
+ bumpp: "^9.4.1",
164
+ "bundle-require": "^4.0.3",
165
+ eslint: "^9.1.1",
166
+ "eslint-plugin-astro": "^1.1.0",
167
+ "eslint-plugin-format": "^0.1.1",
168
+ "eslint-plugin-react-hooks": "^4.6.2",
168
169
  "eslint-plugin-react-refresh": "^0.4.6",
169
- "eslint-plugin-solid": "^0.13.2",
170
- "eslint-plugin-svelte": "2.36.0-next.13",
171
- "eslint-typegen": "^0.2.3",
170
+ "eslint-plugin-solid": "^0.14.0",
171
+ "eslint-plugin-svelte": "2.38.0",
172
+ "eslint-typegen": "^0.2.4",
172
173
  esno: "^4.7.0",
173
174
  execa: "^8.0.1",
174
175
  "fast-glob": "^3.3.2",
@@ -178,12 +179,12 @@ var package_default = {
178
179
  "prettier-plugin-slidev": "^1.0.5",
179
180
  rimraf: "^5.0.5",
180
181
  "simple-git-hooks": "^2.11.1",
181
- svelte: "^4.2.14",
182
- "svelte-eslint-parser": "^0.34.1",
182
+ svelte: "^4.2.15",
183
+ "svelte-eslint-parser": "^0.35.0",
183
184
  tsup: "^8.0.2",
184
185
  typescript: "^5.4.5",
185
- vitest: "^1.5.0",
186
- vue: "^3.4.21"
186
+ vitest: "^1.5.2",
187
+ vue: "^3.4.26"
187
188
  },
188
189
  "simple-git-hooks": {
189
190
  "pre-commit": "pnpm lint-staged"
@@ -283,7 +284,7 @@ var dependenciesMap = {
283
284
  "astro-eslint-parser"
284
285
  ],
285
286
  react: [
286
- "eslint-plugin-react",
287
+ "@eslint-react/eslint-plugin",
287
288
  "eslint-plugin-react-hooks",
288
289
  "eslint-plugin-react-refresh"
289
290
  ],