@tofrankie/eslint 0.0.8 → 0.0.10
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/CHANGELOG.md +12 -0
- package/README.md +31 -1
- package/dist/index.cjs +42 -8
- package/dist/index.d.cts +0 -7
- package/dist/index.d.mts +0 -7
- package/dist/index.mjs +42 -8
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## eslint@0.0.10 (2026-02-26)
|
|
4
|
+
|
|
5
|
+
- Update `@antfu/eslint-config` to v7.6.1 and its related dependencies
|
|
6
|
+
- Disable `react-hooks-extra/no-direct-set-state-in-use-effect` rule
|
|
7
|
+
- Disable `jsdoc/reject-any-type` rule
|
|
8
|
+
|
|
9
|
+
## eslint@0.0.9 (2026-02-22)
|
|
10
|
+
|
|
11
|
+
- Disable `vue/singleline-html-element-content-newline`, `vue/html-closing-bracket-newline`, `vue/html-indent` to avoid conflicts with Prettier
|
|
12
|
+
- Add `vue/html-self-closing` for consistency with Prettier
|
|
13
|
+
- Add `style/quote-props` for consistency with Prettier
|
|
14
|
+
|
|
3
15
|
## eslint@0.0.8 (2026-02-21)
|
|
4
16
|
|
|
5
17
|
- Update `style/quotes` rule
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tofrankie/eslint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A shared ESLint configuration based on [@antfu/eslint-config](https://github.com/antfu/eslint-config), with preset rules tailored to personal preferences.
|
|
4
4
|
|
|
5
5
|
> [!IMPORTANT]
|
|
6
6
|
> Rule presets are not yet stable and may change.
|
|
@@ -18,3 +18,33 @@ import { defineConfig } from '@tofrankie/eslint'
|
|
|
18
18
|
|
|
19
19
|
export default defineConfig()
|
|
20
20
|
```
|
|
21
|
+
|
|
22
|
+
## Configuration Examples
|
|
23
|
+
|
|
24
|
+
### Miniapp
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { defineConfig } from '@tofrankie/eslint'
|
|
28
|
+
|
|
29
|
+
export default defineConfig(
|
|
30
|
+
{
|
|
31
|
+
ignores: ['project.config.json', 'project.private.config.json'],
|
|
32
|
+
// other antfu options...
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
languageOptions: {
|
|
36
|
+
globals: {
|
|
37
|
+
wx: true,
|
|
38
|
+
App: true,
|
|
39
|
+
getApp: true,
|
|
40
|
+
getCurrentPages: true,
|
|
41
|
+
Page: true,
|
|
42
|
+
Component: true,
|
|
43
|
+
Behavior: true,
|
|
44
|
+
requireMiniProgram: true,
|
|
45
|
+
requirePlugin: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,8 @@ const SHARED_RULES = {
|
|
|
41
41
|
"jsdoc/require-returns": "off",
|
|
42
42
|
"jsdoc/require-returns-type": "off",
|
|
43
43
|
"jsdoc/require-returns-description": "off",
|
|
44
|
-
"jsdoc/newline-after-description": "off"
|
|
44
|
+
"jsdoc/newline-after-description": "off",
|
|
45
|
+
"jsdoc/reject-any-type": "off"
|
|
45
46
|
};
|
|
46
47
|
const SHARED_SETTINGS = { tagNamePreference: {
|
|
47
48
|
description: "desc",
|
|
@@ -160,6 +161,15 @@ const NODE_PRESET_RULES = { "node/prefer-global/process": "off" };
|
|
|
160
161
|
*/
|
|
161
162
|
const PNPM_PRESET_RULES = { "pnpm/yaml-enforce-settings": "off" };
|
|
162
163
|
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/preset-rules/react.ts
|
|
166
|
+
/**
|
|
167
|
+
* - rule: `react/*`、`react-hooks-extra/*`
|
|
168
|
+
* - plugin: `eslint-plugin-react-hooks-extra`
|
|
169
|
+
* @see https://www.npmjs.com/package/eslint-plugin-react-hooks-extra
|
|
170
|
+
*/
|
|
171
|
+
const REACT_PRESET_RULES = { "react-hooks-extra/no-direct-set-state-in-use-effect": "off" };
|
|
172
|
+
|
|
163
173
|
//#endregion
|
|
164
174
|
//#region src/preset-rules/style.ts
|
|
165
175
|
/**
|
|
@@ -178,6 +188,7 @@ const STYLE_PRESET_RULES = {
|
|
|
178
188
|
allowTemplateLiterals: "avoidEscape"
|
|
179
189
|
}
|
|
180
190
|
],
|
|
191
|
+
"style/quote-props": ["error", "as-needed"],
|
|
181
192
|
"style/arrow-parens": ["error", "as-needed"],
|
|
182
193
|
"style/brace-style": [
|
|
183
194
|
"error",
|
|
@@ -208,6 +219,28 @@ const STYLE_PRESET_RULES = {
|
|
|
208
219
|
*/
|
|
209
220
|
const TEST_PRESET_RULES = { "test/prefer-lowercase-title": "off" };
|
|
210
221
|
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/preset-rules/vue.ts
|
|
224
|
+
/**
|
|
225
|
+
* - rule: `vue/*`
|
|
226
|
+
* - plugin: `eslint-plugin-vue`
|
|
227
|
+
* @see https://eslint.vuejs.org/rules/
|
|
228
|
+
*/
|
|
229
|
+
const VUE_PRESET_RULES = {
|
|
230
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
231
|
+
"vue/html-closing-bracket-newline": "off",
|
|
232
|
+
"vue/html-indent": "off",
|
|
233
|
+
"vue/html-self-closing": ["warn", {
|
|
234
|
+
html: {
|
|
235
|
+
void: "always",
|
|
236
|
+
normal: "always",
|
|
237
|
+
component: "always"
|
|
238
|
+
},
|
|
239
|
+
svg: "always",
|
|
240
|
+
math: "always"
|
|
241
|
+
}]
|
|
242
|
+
};
|
|
243
|
+
|
|
211
244
|
//#endregion
|
|
212
245
|
//#region src/preset-rules/index.ts
|
|
213
246
|
const ALL_PRESET_RULES = {
|
|
@@ -241,6 +274,14 @@ const PRESET_PREDICATES = [
|
|
|
241
274
|
{
|
|
242
275
|
rules: PNPM_PRESET_RULES,
|
|
243
276
|
predicate: notFalse("pnpm")
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
rules: VUE_PRESET_RULES,
|
|
280
|
+
predicate: (options) => options.vue === true
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
rules: REACT_PRESET_RULES,
|
|
284
|
+
predicate: (options) => options.react === true
|
|
244
285
|
}
|
|
245
286
|
];
|
|
246
287
|
function buildPresetRules(resolvedOptions) {
|
|
@@ -264,13 +305,6 @@ function notFalse(key) {
|
|
|
264
305
|
/**
|
|
265
306
|
* @param antfuOptions Configures for antfu's config.
|
|
266
307
|
* @param userFlatConfigs From the second arguments they are ESLint Flat Configs, you can have multiple configs.
|
|
267
|
-
*
|
|
268
|
-
* 前提:用户预设优于内置预设,若有相同的 key,则进行覆盖。
|
|
269
|
-
* 1. 排除 rules 的前提下,合并 baseOptions 与 userOptions,得到 mergedOptions
|
|
270
|
-
* 2. 根据 mergedOptions 取预设规则 presetRules,不对用户 rules 作错误兼容
|
|
271
|
-
* 3. 将 presetRules 与 userRules 合并,得到 mergedRules
|
|
272
|
-
* 4. 将 mergedOptions 与 { rules: mergedRules } 合并,得到 resolvedOptions
|
|
273
|
-
* 5. 将 resolvedOptions 作为 antfu 第一个参数
|
|
274
308
|
*/
|
|
275
309
|
function defineConfig(antfuOptions, ...userFlatConfigs) {
|
|
276
310
|
const { rules: userRules, ...userOptionsWithoutRules } = antfuOptions ?? {};
|
package/dist/index.d.cts
CHANGED
|
@@ -10,13 +10,6 @@ type Config = ReturnType<typeof antfu>;
|
|
|
10
10
|
/**
|
|
11
11
|
* @param antfuOptions Configures for antfu's config.
|
|
12
12
|
* @param userFlatConfigs From the second arguments they are ESLint Flat Configs, you can have multiple configs.
|
|
13
|
-
*
|
|
14
|
-
* 前提:用户预设优于内置预设,若有相同的 key,则进行覆盖。
|
|
15
|
-
* 1. 排除 rules 的前提下,合并 baseOptions 与 userOptions,得到 mergedOptions
|
|
16
|
-
* 2. 根据 mergedOptions 取预设规则 presetRules,不对用户 rules 作错误兼容
|
|
17
|
-
* 3. 将 presetRules 与 userRules 合并,得到 mergedRules
|
|
18
|
-
* 4. 将 mergedOptions 与 { rules: mergedRules } 合并,得到 resolvedOptions
|
|
19
|
-
* 5. 将 resolvedOptions 作为 antfu 第一个参数
|
|
20
13
|
*/
|
|
21
14
|
declare function defineConfig(antfuOptions?: AntfuOptions, ...userFlatConfigs: UserFlatConfig[]): Config;
|
|
22
15
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -10,13 +10,6 @@ type Config = ReturnType<typeof antfu>;
|
|
|
10
10
|
/**
|
|
11
11
|
* @param antfuOptions Configures for antfu's config.
|
|
12
12
|
* @param userFlatConfigs From the second arguments they are ESLint Flat Configs, you can have multiple configs.
|
|
13
|
-
*
|
|
14
|
-
* 前提:用户预设优于内置预设,若有相同的 key,则进行覆盖。
|
|
15
|
-
* 1. 排除 rules 的前提下,合并 baseOptions 与 userOptions,得到 mergedOptions
|
|
16
|
-
* 2. 根据 mergedOptions 取预设规则 presetRules,不对用户 rules 作错误兼容
|
|
17
|
-
* 3. 将 presetRules 与 userRules 合并,得到 mergedRules
|
|
18
|
-
* 4. 将 mergedOptions 与 { rules: mergedRules } 合并,得到 resolvedOptions
|
|
19
|
-
* 5. 将 resolvedOptions 作为 antfu 第一个参数
|
|
20
13
|
*/
|
|
21
14
|
declare function defineConfig(antfuOptions?: AntfuOptions, ...userFlatConfigs: UserFlatConfig[]): Config;
|
|
22
15
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,8 @@ const SHARED_RULES = {
|
|
|
12
12
|
"jsdoc/require-returns": "off",
|
|
13
13
|
"jsdoc/require-returns-type": "off",
|
|
14
14
|
"jsdoc/require-returns-description": "off",
|
|
15
|
-
"jsdoc/newline-after-description": "off"
|
|
15
|
+
"jsdoc/newline-after-description": "off",
|
|
16
|
+
"jsdoc/reject-any-type": "off"
|
|
16
17
|
};
|
|
17
18
|
const SHARED_SETTINGS = { tagNamePreference: {
|
|
18
19
|
description: "desc",
|
|
@@ -131,6 +132,15 @@ const NODE_PRESET_RULES = { "node/prefer-global/process": "off" };
|
|
|
131
132
|
*/
|
|
132
133
|
const PNPM_PRESET_RULES = { "pnpm/yaml-enforce-settings": "off" };
|
|
133
134
|
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/preset-rules/react.ts
|
|
137
|
+
/**
|
|
138
|
+
* - rule: `react/*`、`react-hooks-extra/*`
|
|
139
|
+
* - plugin: `eslint-plugin-react-hooks-extra`
|
|
140
|
+
* @see https://www.npmjs.com/package/eslint-plugin-react-hooks-extra
|
|
141
|
+
*/
|
|
142
|
+
const REACT_PRESET_RULES = { "react-hooks-extra/no-direct-set-state-in-use-effect": "off" };
|
|
143
|
+
|
|
134
144
|
//#endregion
|
|
135
145
|
//#region src/preset-rules/style.ts
|
|
136
146
|
/**
|
|
@@ -149,6 +159,7 @@ const STYLE_PRESET_RULES = {
|
|
|
149
159
|
allowTemplateLiterals: "avoidEscape"
|
|
150
160
|
}
|
|
151
161
|
],
|
|
162
|
+
"style/quote-props": ["error", "as-needed"],
|
|
152
163
|
"style/arrow-parens": ["error", "as-needed"],
|
|
153
164
|
"style/brace-style": [
|
|
154
165
|
"error",
|
|
@@ -179,6 +190,28 @@ const STYLE_PRESET_RULES = {
|
|
|
179
190
|
*/
|
|
180
191
|
const TEST_PRESET_RULES = { "test/prefer-lowercase-title": "off" };
|
|
181
192
|
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/preset-rules/vue.ts
|
|
195
|
+
/**
|
|
196
|
+
* - rule: `vue/*`
|
|
197
|
+
* - plugin: `eslint-plugin-vue`
|
|
198
|
+
* @see https://eslint.vuejs.org/rules/
|
|
199
|
+
*/
|
|
200
|
+
const VUE_PRESET_RULES = {
|
|
201
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
202
|
+
"vue/html-closing-bracket-newline": "off",
|
|
203
|
+
"vue/html-indent": "off",
|
|
204
|
+
"vue/html-self-closing": ["warn", {
|
|
205
|
+
html: {
|
|
206
|
+
void: "always",
|
|
207
|
+
normal: "always",
|
|
208
|
+
component: "always"
|
|
209
|
+
},
|
|
210
|
+
svg: "always",
|
|
211
|
+
math: "always"
|
|
212
|
+
}]
|
|
213
|
+
};
|
|
214
|
+
|
|
182
215
|
//#endregion
|
|
183
216
|
//#region src/preset-rules/index.ts
|
|
184
217
|
const ALL_PRESET_RULES = {
|
|
@@ -212,6 +245,14 @@ const PRESET_PREDICATES = [
|
|
|
212
245
|
{
|
|
213
246
|
rules: PNPM_PRESET_RULES,
|
|
214
247
|
predicate: notFalse("pnpm")
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
rules: VUE_PRESET_RULES,
|
|
251
|
+
predicate: (options) => options.vue === true
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
rules: REACT_PRESET_RULES,
|
|
255
|
+
predicate: (options) => options.react === true
|
|
215
256
|
}
|
|
216
257
|
];
|
|
217
258
|
function buildPresetRules(resolvedOptions) {
|
|
@@ -235,13 +276,6 @@ function notFalse(key) {
|
|
|
235
276
|
/**
|
|
236
277
|
* @param antfuOptions Configures for antfu's config.
|
|
237
278
|
* @param userFlatConfigs From the second arguments they are ESLint Flat Configs, you can have multiple configs.
|
|
238
|
-
*
|
|
239
|
-
* 前提:用户预设优于内置预设,若有相同的 key,则进行覆盖。
|
|
240
|
-
* 1. 排除 rules 的前提下,合并 baseOptions 与 userOptions,得到 mergedOptions
|
|
241
|
-
* 2. 根据 mergedOptions 取预设规则 presetRules,不对用户 rules 作错误兼容
|
|
242
|
-
* 3. 将 presetRules 与 userRules 合并,得到 mergedRules
|
|
243
|
-
* 4. 将 mergedOptions 与 { rules: mergedRules } 合并,得到 resolvedOptions
|
|
244
|
-
* 5. 将 resolvedOptions 作为 antfu 第一个参数
|
|
245
279
|
*/
|
|
246
280
|
function defineConfig(antfuOptions, ...userFlatConfigs) {
|
|
247
281
|
const { rules: userRules, ...userOptionsWithoutRules } = antfuOptions ?? {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tofrankie/eslint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "Shared ESLint configuration
|
|
4
|
+
"version": "0.0.10",
|
|
5
|
+
"description": "Shared ESLint configuration",
|
|
6
6
|
"author": "Frankie <1426203851@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/tofrankie/config/tree/main/packages/eslint",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"node": ">=18"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@antfu/eslint-config": ">=7.
|
|
45
|
-
"eslint": ">=9.
|
|
44
|
+
"@antfu/eslint-config": ">=7.6.1",
|
|
45
|
+
"eslint": ">=9.10.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
49
|
-
"eslint-plugin-format": "^
|
|
50
|
-
"eslint-plugin-jsdoc": "^62.
|
|
48
|
+
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
49
|
+
"eslint-plugin-format": "^2.0.1",
|
|
50
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
51
51
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
52
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
52
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
53
53
|
"lodash.merge": "^4.6.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@antfu/eslint-config": "^7.
|
|
56
|
+
"@antfu/eslint-config": "^7.6.1",
|
|
57
57
|
"@types/lodash.merge": "^4.6.9",
|
|
58
58
|
"eslint": "^9.39.2"
|
|
59
59
|
},
|