@pawover/kit-eslint-rules 0.2.0-alpha.2 → 0.2.0-alpha.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.d.ts +94 -6
- package/dist/index.js +1393 -10
- package/package.json +7 -6
- package/skills/eslint-preset/SKILL.md +65 -27
- package/skills/eslint-preset/references/options.md +69 -29
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,41 @@ interface RulesOverrideOptions {
|
|
|
123
123
|
/** 覆盖该规则组的规则(与预设规则表浅合并,同名规则以本参数为准) */
|
|
124
124
|
overrides?: RuleMap;
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* 引号风格快捷值
|
|
128
|
+
*
|
|
129
|
+
* 用于 `stylistic.quotes` 快捷项;仅支持单引号与双引号,不包含模板字符串(backtick)。
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const quotes: StylisticQuotes = "single";
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
type StylisticQuotes = "single" | "double";
|
|
137
|
+
/**
|
|
138
|
+
* stylistic 规则组选项
|
|
139
|
+
*
|
|
140
|
+
* 除通用 `overrides` 外提供常用风格快捷项;快捷项在装配阶段编译为规则配置,
|
|
141
|
+
* 优先级低于 `overrides`、高于规则映射默认值。
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* // 单引号 + 不写分号(自动联动 JSX 引号与 TypeScript 成员分隔符)
|
|
146
|
+
* const options: StylisticOptions = { quotes: "single", semi: false };
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* // 保留原有 `{ overrides }` 用法
|
|
152
|
+
* const legacy: StylisticOptions = { overrides: { "stylistic/quotes": 0 } };
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
interface StylisticOptions extends RulesOverrideOptions {
|
|
156
|
+
/** 引号风格:同时切换 `stylistic/quotes` 与 `stylistic/jsx-quotes`(不传则不产生覆写) */
|
|
157
|
+
quotes?: StylisticQuotes;
|
|
158
|
+
/** 是否保留语句分号;传 `false` 时自动联动 `stylistic/member-delimiter-style`(不传则不产生覆写) */
|
|
159
|
+
semi?: boolean;
|
|
160
|
+
}
|
|
126
161
|
/**
|
|
127
162
|
* TypeScript 规则组选项
|
|
128
163
|
*
|
|
@@ -140,7 +175,12 @@ interface TypeScriptOptions extends RulesOverrideOptions {
|
|
|
140
175
|
overridesTypeAware?: RuleMap;
|
|
141
176
|
/** 类型感知规则的文件范围;默认 {@link GLOB_TYPESCRIPT} */
|
|
142
177
|
filesTypeAware?: string[];
|
|
143
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* 透传给 TypeScript parser 的解析选项;与默认值浅合并,同名键以本参数为准
|
|
180
|
+
*
|
|
181
|
+
* `extraFileExtensions` 例外:启用 `vue` 时会自动并入 `.vue`,本参数中的同名数组与之去重合并;
|
|
182
|
+
* 未启用 `vue` 时按原值透传(不裁剪、不改写)。
|
|
183
|
+
*/
|
|
144
184
|
parserOptions?: Record<string, unknown>;
|
|
145
185
|
}
|
|
146
186
|
/**
|
|
@@ -179,6 +219,45 @@ interface ReactOptions extends RulesOverrideOptions {
|
|
|
179
219
|
/** 仅覆盖依赖类型信息的 react 规则(仅在开启 `typescript` 时生效) */
|
|
180
220
|
overridesTypeAware?: RuleMap;
|
|
181
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Vue 组件命名风格
|
|
224
|
+
*
|
|
225
|
+
* 同时适用于模板标签、组件属性与自定义事件三处命名快捷项。
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const casing: VueNamingCasing = "kebab-case";
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
type VueNamingCasing = "PascalCase" | "camelCase" | "kebab-case";
|
|
233
|
+
/**
|
|
234
|
+
* vue 规则组选项
|
|
235
|
+
*
|
|
236
|
+
* 命名快捷项分别映射到模板标签、组件属性与自定义事件三条规则:单项优先于总开关 `naming`,
|
|
237
|
+
* `overrides` 优先于全部快捷项。
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* // 属性与事件使用 kebab-case,仅模板标签保留 PascalCase
|
|
242
|
+
* const options: VueOptions = { naming: "kebab-case", templateNaming: "PascalCase" };
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* // 保留原有 `{ overrides }` 用法
|
|
248
|
+
* const legacy: VueOptions = { overrides: { "vue/attribute-hyphenation": "off" } };
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
interface VueOptions extends RulesOverrideOptions {
|
|
252
|
+
/** 命名总开关:一次设定模板标签 / 组件属性 / 自定义事件三条规则 */
|
|
253
|
+
naming?: VueNamingCasing;
|
|
254
|
+
/** 模板标签命名(`vue/component-name-in-template-casing`),优先于 `naming` */
|
|
255
|
+
templateNaming?: VueNamingCasing;
|
|
256
|
+
/** 组件属性命名(`vue/attribute-hyphenation`),优先于 `naming` */
|
|
257
|
+
attributeNaming?: VueNamingCasing;
|
|
258
|
+
/** 自定义事件命名(`vue/v-on-event-hyphenation`),优先于 `naming` */
|
|
259
|
+
eventNaming?: VueNamingCasing;
|
|
260
|
+
}
|
|
182
261
|
/**
|
|
183
262
|
* 预设工厂选项
|
|
184
263
|
*
|
|
@@ -194,14 +273,23 @@ interface ReactOptions extends RulesOverrideOptions {
|
|
|
194
273
|
* react: true,
|
|
195
274
|
* };
|
|
196
275
|
* ```
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* // 风格快捷开关
|
|
280
|
+
* const options: PawoverOptions = {
|
|
281
|
+
* stylistic: { quotes: "single", semi: false },
|
|
282
|
+
* vue: { naming: "kebab-case" },
|
|
283
|
+
* };
|
|
284
|
+
* ```
|
|
197
285
|
*/
|
|
198
286
|
interface PawoverOptions {
|
|
199
287
|
/** javascript 规则组覆盖选项(该组常开) */
|
|
200
288
|
javascript?: RulesOverrideOptions;
|
|
201
289
|
/** 启用 `typescript` 规则组(ts / tsx 文件;同时注册 TypeScript parser,默认启用 type-aware 解析) */
|
|
202
290
|
typescript?: boolean | TypeScriptOptions;
|
|
203
|
-
/** 启用 `stylistic`
|
|
204
|
-
stylistic?: boolean |
|
|
291
|
+
/** 启用 `stylistic` 规则组(支持 `quotes` / `semi` 风格快捷项) */
|
|
292
|
+
stylistic?: boolean | StylisticOptions;
|
|
205
293
|
/** 启用 `antfu` 规则组 */
|
|
206
294
|
antfu?: boolean | RulesOverrideOptions;
|
|
207
295
|
/** 启用 `imports` 规则组(eslint-plugin-import-lite) */
|
|
@@ -210,8 +298,8 @@ interface PawoverOptions {
|
|
|
210
298
|
importsSort?: boolean | RulesOverrideOptions;
|
|
211
299
|
/** 启用 `react` 规则组(注册 `@eslint-react` 与 `eslint-plugin-react-hooks` 两个插件,默认开启 React Compiler 规则切换);与 `typescript` 同开时,依赖类型信息的规则作用于 ts/tsx/jsx */
|
|
212
300
|
react?: boolean | ReactOptions;
|
|
213
|
-
/** 启用 `vue` 规则组(vue / vue+ts 单文件组件;同时接入 vue-eslint-parser
|
|
214
|
-
vue?: boolean |
|
|
301
|
+
/** 启用 `vue` 规则组(vue / vue+ts 单文件组件;同时接入 vue-eslint-parser,与 `typescript` 同开时自动为 TypeScript parser 放行 `.vue` 扩展名;支持 `naming` 命名快捷项) */
|
|
302
|
+
vue?: boolean | VueOptions;
|
|
215
303
|
}
|
|
216
304
|
/**
|
|
217
305
|
* 创建 ESLint flat config 预设
|
|
@@ -378,4 +466,4 @@ export type Severity = SeverityName | SeverityLevel;
|
|
|
378
466
|
* ```
|
|
379
467
|
*/
|
|
380
468
|
export type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
|
381
|
-
export { type ConfigLayer, type ConfigNames, GLOB_EXCLUDE, GLOB_JSX, GLOB_SOURCE, GLOB_TYPESCRIPT, GLOB_VUE, type PawoverOptions, type PawoverUserConfig, type ReactCompilerPreset, type ReactOptions, type RuleMap, type RulesOverrideOptions, type TypeScriptOptions, pawover as default };
|
|
469
|
+
export { type ConfigLayer, type ConfigNames, GLOB_EXCLUDE, GLOB_JSX, GLOB_SOURCE, GLOB_TYPESCRIPT, GLOB_VUE, type PawoverOptions, type PawoverUserConfig, type ReactCompilerPreset, type ReactOptions, type RuleMap, type RulesOverrideOptions, type StylisticOptions, type StylisticQuotes, type TypeScriptOptions, type VueNamingCasing, type VueOptions, pawover as default };
|