@pawover/kit-eslint-rules 0.2.0-alpha.2 → 0.2.0-alpha.4
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 +1410 -22
- package/package.json +7 -6
- package/skills/eslint-preset/SKILL.md +65 -27
- package/skills/eslint-preset/references/options.md +69 -29
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/pawover"
|
|
7
7
|
},
|
|
8
8
|
"description": "Self-contained ESLint flat config preset: javascript, typescript, react, vue, stylistic, antfu and import rules, with pinned bundled plugins",
|
|
9
|
-
"version": "0.2.0-alpha.
|
|
9
|
+
"version": "0.2.0-alpha.4",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"pawover",
|
|
@@ -46,16 +46,17 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@eslint-react/eslint-plugin": "5.
|
|
50
|
-
"@
|
|
49
|
+
"@eslint-react/eslint-plugin": "5.30.3",
|
|
50
|
+
"@pawover/kit-utils": "1.1.0-alpha.0",
|
|
51
|
+
"@stylistic/eslint-plugin": "6.0.1",
|
|
51
52
|
"eslint-flat-config-utils": "3.2.0",
|
|
52
53
|
"eslint-plugin-antfu": "3.3.1",
|
|
53
54
|
"eslint-plugin-import-lite": "0.6.0",
|
|
54
55
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
55
56
|
"eslint-plugin-simple-import-sort": "14.0.0",
|
|
56
|
-
"eslint-plugin-vue": "10.12.
|
|
57
|
-
"typescript-eslint": "8.
|
|
58
|
-
"vue-eslint-parser": "10.4.
|
|
57
|
+
"eslint-plugin-vue": "10.12.1",
|
|
58
|
+
"typescript-eslint": "8.73.0",
|
|
59
|
+
"vue-eslint-parser": "10.4.2"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@pawover/kit-internal": "0.0.0"
|
|
@@ -3,11 +3,14 @@ name: eslint-preset
|
|
|
3
3
|
description: >-
|
|
4
4
|
Use when configuring ESLint flat config with @pawover/kit-eslint-rules,
|
|
5
5
|
including enabling TypeScript, React, Vue, stylistic, antfu, imports, or
|
|
6
|
-
importsSort groups; overriding rules per group or per layer;
|
|
7
|
-
Compiler rules
|
|
6
|
+
importsSort groups; overriding rules per group or per layer; handling React
|
|
7
|
+
Compiler rules; and applying stylistic (quotes / semi) or vue (naming /
|
|
8
|
+
templateNaming / attributeNaming / eventNaming) quick switches.
|
|
8
9
|
metadata:
|
|
9
|
-
purpose:
|
|
10
|
-
|
|
10
|
+
purpose: >-
|
|
11
|
+
Configure ESLint flat config with the self-contained
|
|
12
|
+
@pawover/kit-eslint-rules preset, including style quick switches and
|
|
13
|
+
the documented precedence over explicit overrides.
|
|
11
14
|
type: core
|
|
12
15
|
library: "@pawover/kit-eslint-rules"
|
|
13
16
|
library_version: "0.2.0-alpha.1"
|
|
@@ -19,6 +22,7 @@ sources:
|
|
|
19
22
|
- src/reactCompiler.ts
|
|
20
23
|
- src/core.javascript.ts
|
|
21
24
|
- src/core.typescript.ts
|
|
25
|
+
- src/core.stylistic.ts
|
|
22
26
|
- src/core.react.ts
|
|
23
27
|
- src/core.vue.ts
|
|
24
28
|
---
|
|
@@ -27,7 +31,9 @@ sources:
|
|
|
27
31
|
|
|
28
32
|
The package is a self-contained ESLint flat config preset. Every upstream plugin
|
|
29
33
|
it uses is a dependency and is registered by the factory; do not install or
|
|
30
|
-
register the preset's plugins manually.
|
|
34
|
+
register the preset's plugins manually. It also depends on
|
|
35
|
+
`@pawover/kit-utils` (shared internal utilities, used at assembly time for
|
|
36
|
+
array de-duplication when merging parser options).
|
|
31
37
|
|
|
32
38
|
The default export is `pawover(options?, ...userConfigs)`. It returns an
|
|
33
39
|
`eslint-flat-config-utils` `FlatConfigComposer`, which extends `Promise` and can
|
|
@@ -64,15 +70,15 @@ const fullConfig = pawover({
|
|
|
64
70
|
|
|
65
71
|
### Enable the groups the project needs
|
|
66
72
|
|
|
67
|
-
| Option
|
|
68
|
-
|
|
|
69
|
-
| `typescript`
|
|
70
|
-
| `stylistic`
|
|
71
|
-
| `antfu`
|
|
72
|
-
| `imports`
|
|
73
|
-
| `importsSort` | `eslint-plugin-simple-import-sort` rules
|
|
74
|
-
| `react`
|
|
75
|
-
| `vue`
|
|
73
|
+
| Option | Enables | Files |
|
|
74
|
+
| ------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
75
|
+
| `typescript` | TypeScript plugin, parser, and rules | `**/*.{ts,tsx}`; adds `*.vue` when `vue` is enabled |
|
|
76
|
+
| `stylistic` | Stylistic rules | source files |
|
|
77
|
+
| `antfu` | `eslint-plugin-antfu` rules | source files |
|
|
78
|
+
| `imports` | `eslint-plugin-import-lite` rules | source files |
|
|
79
|
+
| `importsSort` | `eslint-plugin-simple-import-sort` rules | source files |
|
|
80
|
+
| `react` | `@eslint-react` + `eslint-plugin-react-hooks` | source files; type-aware rules also cover `*.jsx` |
|
|
81
|
+
| `vue` | Vue parser, `vue/vue` processor, and rules | `**/*.vue`; when `typescript` is also enabled, the TypeScript parser's `extraFileExtensions` additionally admits `.vue` |
|
|
76
82
|
|
|
77
83
|
`typescript` defaults the parser to `projectService: true`. Pass parser options
|
|
78
84
|
to match the project:
|
|
@@ -89,7 +95,11 @@ const parserConfig = pawover({
|
|
|
89
95
|
```
|
|
90
96
|
|
|
91
97
|
The passed `parserOptions` are shallow-merged over the defaults; a same-named key
|
|
92
|
-
wins
|
|
98
|
+
wins, with one exception: `extraFileExtensions` is de-duplicated and merged with
|
|
99
|
+
the preset's required entries (`.vue` when `vue` is enabled) instead of being
|
|
100
|
+
overwritten. When `vue` is not enabled, the user's `extraFileExtensions` is
|
|
101
|
+
passed through unchanged — the preset neither trims nor rewrites it.
|
|
102
|
+
Use `filesTypeAware` to narrow the type-aware file range; the default is
|
|
93
103
|
`GLOB_TYPESCRIPT` (`**/*.{ts,tsx}`).
|
|
94
104
|
|
|
95
105
|
### Override rules at the group level
|
|
@@ -106,7 +116,7 @@ import pawover from "@pawover/kit-eslint-rules";
|
|
|
106
116
|
const overrideConfig = pawover({
|
|
107
117
|
typescript: {
|
|
108
118
|
overrides: {
|
|
109
|
-
"ts/
|
|
119
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
110
120
|
},
|
|
111
121
|
},
|
|
112
122
|
react: {
|
|
@@ -133,6 +143,40 @@ const typeAwareConfig = pawover({
|
|
|
133
143
|
});
|
|
134
144
|
```
|
|
135
145
|
|
|
146
|
+
### Use style quick switches
|
|
147
|
+
|
|
148
|
+
`stylistic` and `vue` accept ergonomic shortcut options that compile into rule
|
|
149
|
+
overrides at assembly time. They sit between the rule map defaults and
|
|
150
|
+
`overrides`:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import pawover from "@pawover/kit-eslint-rules";
|
|
154
|
+
|
|
155
|
+
const config = pawover({
|
|
156
|
+
stylistic: { quotes: "single", semi: false },
|
|
157
|
+
vue: { naming: "kebab-case" },
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`stylistic.quotes` switches `stylistic/quotes` and `stylistic/jsx-quotes` in
|
|
162
|
+
tandem (`"single"` → `"prefer-single"`, `"double"` → `"prefer-double"`).
|
|
163
|
+
`stylistic.semi: false` additionally rewrites
|
|
164
|
+
`stylistic/member-delimiter-style` (multiline: `delimiter: "none"`,
|
|
165
|
+
`requireLast: false`; singleline: `delimiter: "comma"`). The two options are
|
|
166
|
+
independent and only affect rules they explicitly own — `semi-spacing`,
|
|
167
|
+
`semi-style`, `no-extra-semi`, `quote-props`, and `vue/html-quotes` are
|
|
168
|
+
left untouched, and `quotes` does not inject `allowTemplateLiterals`. HTML
|
|
169
|
+
attribute quotes stay at `double` regardless of the switch.
|
|
170
|
+
|
|
171
|
+
`vue.naming` sets `vue/component-name-in-template-casing`,
|
|
172
|
+
`vue/attribute-hyphenation`, and `vue/v-on-event-hyphenation` in one go.
|
|
173
|
+
Override any of them individually with `templateNaming`, `attributeNaming`, or
|
|
174
|
+
`eventNaming` — the per-item option wins over the group-wide `naming`.
|
|
175
|
+
|
|
176
|
+
Precedence (highest first): `overrides` > per-item shortcut > group shortcut >
|
|
177
|
+
rule map default. Both shortcut sets remain fully compatible with the existing
|
|
178
|
+
`{ overrides }` shape.
|
|
179
|
+
|
|
136
180
|
### Control React Compiler rules
|
|
137
181
|
|
|
138
182
|
When `react` is enabled, the preset switches ten overlapping rules from
|
|
@@ -170,14 +214,11 @@ target it precisely:
|
|
|
170
214
|
```ts
|
|
171
215
|
import pawover from "@pawover/kit-eslint-rules";
|
|
172
216
|
|
|
173
|
-
const layerConfig = pawover({ typescript: true }).override(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
rules: {
|
|
177
|
-
"ts/consistent-type-definitions": ["error", "interface"],
|
|
178
|
-
},
|
|
217
|
+
const layerConfig = pawover({ typescript: true }).override("pawover/typescript/rules", {
|
|
218
|
+
rules: {
|
|
219
|
+
"ts/consistent-type-definitions": ["error", "interface"],
|
|
179
220
|
},
|
|
180
|
-
);
|
|
221
|
+
});
|
|
181
222
|
```
|
|
182
223
|
|
|
183
224
|
Layer names are `pawover/<group>/<setup|parser|rules|type-aware>`; group names use
|
|
@@ -194,10 +235,7 @@ the composer methods directly.
|
|
|
194
235
|
```ts
|
|
195
236
|
import pawover from "@pawover/kit-eslint-rules";
|
|
196
237
|
|
|
197
|
-
const appendedConfig = pawover(
|
|
198
|
-
{ typescript: true },
|
|
199
|
-
{ rules: { "no-console": "error" } },
|
|
200
|
-
);
|
|
238
|
+
const appendedConfig = pawover({ typescript: true }, { rules: { "no-console": "error" } });
|
|
201
239
|
|
|
202
240
|
// Equivalent composition style
|
|
203
241
|
const composerConfig = pawover({ typescript: true }).append({
|
|
@@ -8,25 +8,25 @@ main skill.
|
|
|
8
8
|
|
|
9
9
|
The factory emits layers in this order when the corresponding group is enabled:
|
|
10
10
|
|
|
11
|
-
| Layer name
|
|
12
|
-
|
|
|
13
|
-
| `pawover/ignores`
|
|
14
|
-
| `pawover/javascript/parser`
|
|
15
|
-
| `pawover/javascript/rules`
|
|
16
|
-
| `pawover/typescript/setup`
|
|
17
|
-
| `pawover/typescript/parser`
|
|
18
|
-
| `pawover/typescript/rules`
|
|
19
|
-
| `pawover/typescript/type-aware`
|
|
20
|
-
| `pawover/stylistic/setup` / `rules`
|
|
21
|
-
| `pawover/antfu/setup` / `rules`
|
|
22
|
-
| `pawover/imports/setup` / `rules`
|
|
23
|
-
| `pawover/imports-sort/setup` / `rules` | Registers the `importsSort` plugin and applies its rules.
|
|
24
|
-
| `pawover/react/setup`
|
|
25
|
-
| `pawover/react/rules`
|
|
26
|
-
| `pawover/react/type-aware`
|
|
27
|
-
| `pawover/vue/setup`
|
|
28
|
-
| `pawover/vue/parser`
|
|
29
|
-
| `pawover/vue/rules`
|
|
11
|
+
| Layer name | Contents |
|
|
12
|
+
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `pawover/ignores` | The `GLOB_EXCLUDE` ignore list. |
|
|
14
|
+
| `pawover/javascript/parser` | JavaScript parser settings (`ecmaVersion: "latest"`, `sourceType: "module"`, JSX enabled). |
|
|
15
|
+
| `pawover/javascript/rules` | JavaScript rule map and `javascript.overrides`. |
|
|
16
|
+
| `pawover/typescript/setup` | Registers the `ts` plugin. |
|
|
17
|
+
| `pawover/typescript/parser` | TypeScript parser with `projectService: true`, `typescript.parserOptions`, and the preset-merged `extraFileExtensions` (`.vue` appended and de-duplicated only when `vue` is enabled; user value passed through unchanged otherwise). |
|
|
18
|
+
| `pawover/typescript/rules` | TypeScript rule map and `typescript.overrides`. |
|
|
19
|
+
| `pawover/typescript/type-aware` | `typescript.overridesTypeAware` on `filesTypeAware`. |
|
|
20
|
+
| `pawover/stylistic/setup` / `rules` | Registers the `stylistic` plugin and applies its rules. `stylistic.overrides` is merged last; style shortcut keys (`quotes` / `semi`) compile into rule overrides between the rule map default and `overrides`. |
|
|
21
|
+
| `pawover/antfu/setup` / `rules` | Registers the `antfu` plugin and applies its rules. |
|
|
22
|
+
| `pawover/imports/setup` / `rules` | Registers the `imports` plugin and applies its rules. |
|
|
23
|
+
| `pawover/imports-sort/setup` / `rules` | Registers the `importsSort` plugin and applies its rules. |
|
|
24
|
+
| `pawover/react/setup` | Registers `react` and `react-hooks` (or the no-op `react` implementation without TypeScript). |
|
|
25
|
+
| `pawover/react/rules` | React base rules, hooks rules, compiler switch, and `react.overrides`. |
|
|
26
|
+
| `pawover/react/type-aware` | React type-aware rules and `react.overridesTypeAware`. |
|
|
27
|
+
| `pawover/vue/setup` | Registers the `vue` plugin. |
|
|
28
|
+
| `pawover/vue/parser` | `vue-eslint-parser` with the `vue/vue` processor (consumes `vue/comment-directive` `clear` messages; without it each `clear` surfaces as an error), optionally delegating `<script>` to the TypeScript parser. |
|
|
29
|
+
| `pawover/vue/rules` | Vue rule map and `vue.overrides`. Style shortcut keys (`naming` / `templateNaming` / `attributeNaming` / `eventNaming`) compile into rule overrides between the rule map default and `overrides`. |
|
|
30
30
|
|
|
31
31
|
Group names in layer names use kebab-case: `importsSort` becomes
|
|
32
32
|
`imports-sort`.
|
|
@@ -44,7 +44,7 @@ const options: PawoverOptions = {
|
|
|
44
44
|
filesTypeAware: ["**/*.{ts,tsx}"],
|
|
45
45
|
parserOptions: { tsconfigRootDir: "/repo" },
|
|
46
46
|
},
|
|
47
|
-
stylistic:
|
|
47
|
+
stylistic: { quotes: "single", semi: false },
|
|
48
48
|
antfu: true,
|
|
49
49
|
imports: true,
|
|
50
50
|
importsSort: true,
|
|
@@ -53,7 +53,11 @@ const options: PawoverOptions = {
|
|
|
53
53
|
overrides: { "react/no-implicit-key": "warn" },
|
|
54
54
|
overridesTypeAware: { "react/no-unused-props": "off" },
|
|
55
55
|
},
|
|
56
|
-
vue: {
|
|
56
|
+
vue: {
|
|
57
|
+
naming: "kebab-case",
|
|
58
|
+
templateNaming: "PascalCase",
|
|
59
|
+
overrides: { "vue/multi-word-component-names": "off" },
|
|
60
|
+
},
|
|
57
61
|
};
|
|
58
62
|
```
|
|
59
63
|
|
|
@@ -61,15 +65,47 @@ const options: PawoverOptions = {
|
|
|
61
65
|
groups accept `true` or an options object. Each group's `overrides` is merged
|
|
62
66
|
into that group's rule map at generation time.
|
|
63
67
|
|
|
68
|
+
## Style quick switches
|
|
69
|
+
|
|
70
|
+
`stylistic` and `vue` options accept shortcut keys that compile into rule
|
|
71
|
+
overrides at assembly time. The precedence is
|
|
72
|
+
`overrides` > per-item shortcut > group shortcut > rule map default.
|
|
73
|
+
|
|
74
|
+
**`StylisticOptions`**:
|
|
75
|
+
|
|
76
|
+
- `quotes?: "single" | "double"` — toggles `stylistic/quotes` and
|
|
77
|
+
`stylistic/jsx-quotes` in tandem (`single` → `prefer-single`,
|
|
78
|
+
`double` → `prefer-double`). Does not inject `allowTemplateLiterals`.
|
|
79
|
+
- `semi?: boolean` — toggles `stylistic/semi`; when `false`, additionally
|
|
80
|
+
rewrites `stylistic/member-delimiter-style` (multiline:
|
|
81
|
+
`delimiter: "none"`, `requireLast: false`; singleline:
|
|
82
|
+
`delimiter: "comma"`).
|
|
83
|
+
|
|
84
|
+
The two keys only affect the rules they explicitly own. Rules that are **not**
|
|
85
|
+
touched: `semi-spacing`, `semi-style`, `no-extra-semi`, `quote-props`, and
|
|
86
|
+
`vue/html-quotes` (HTML attribute quotes stay at `double` regardless of the
|
|
87
|
+
switch).
|
|
88
|
+
|
|
89
|
+
**`VueOptions`**:
|
|
90
|
+
|
|
91
|
+
- `naming?: "PascalCase" | "camelCase" | "kebab-case"` — one-shot setter for
|
|
92
|
+
`vue/component-name-in-template-casing`, `vue/attribute-hyphenation`, and
|
|
93
|
+
`vue/v-on-event-hyphenation`.
|
|
94
|
+
- `templateNaming?` / `attributeNaming?` / `eventNaming?` — per-item
|
|
95
|
+
overrides; each takes precedence over `naming` for its own rule.
|
|
96
|
+
|
|
97
|
+
Both shortcut sets remain fully compatible with the existing `{ overrides }`
|
|
98
|
+
shape.
|
|
99
|
+
|
|
64
100
|
## Glob constants
|
|
65
101
|
|
|
66
|
-
| Constant
|
|
67
|
-
|
|
|
68
|
-
| `GLOB_SOURCE`
|
|
69
|
-
| `GLOB_TYPESCRIPT` | `["**/*.{ts,tsx}"]`
|
|
70
|
-
| `GLOB_JSX`
|
|
71
|
-
| `GLOB_VUE`
|
|
72
|
-
| `GLOB_EXCLUDE`
|
|
102
|
+
| Constant | Value | Meaning |
|
|
103
|
+
| ----------------- | ---------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
104
|
+
| `GLOB_SOURCE` | `["**/*.{js,cjs,mjs,jsx,ts,tsx}"]` | All source files. Append `GLOB_VUE` when customizing Vue sources. |
|
|
105
|
+
| `GLOB_TYPESCRIPT` | `["**/*.{ts,tsx}"]` | TypeScript files; default for type-aware layers. |
|
|
106
|
+
| `GLOB_JSX` | `"**/*.jsx"` | JSX files; added to React's type-aware range. |
|
|
107
|
+
| `GLOB_VUE` | `"**/*.vue"` | Vue single-file components. |
|
|
108
|
+
| `GLOB_EXCLUDE` | Array of ignore globs | Dependencies, build outputs, lockfiles, caches, editor directories, generated declarations. |
|
|
73
109
|
|
|
74
110
|
## React Compiler switch
|
|
75
111
|
|
|
@@ -117,7 +153,11 @@ composer.
|
|
|
117
153
|
- `javascript` is not a boolean switch; passing `true` is not meaningful.
|
|
118
154
|
- `filesTypeAware` only accepts `string[]`; a single glob string is invalid.
|
|
119
155
|
- `parserOptions` is shallow-merged, so nested objects are replaced rather than
|
|
120
|
-
deep-merged
|
|
156
|
+
deep-merged — except `extraFileExtensions`, which is de-duplicated and merged
|
|
157
|
+
with the preset's required entries (`.vue` when `vue` is enabled) instead of
|
|
158
|
+
being overwritten. Without `vue`, the user value is passed through unchanged.
|
|
159
|
+
De-duplication uses strict string equality: `.Vue` and `.vue` are treated as
|
|
160
|
+
distinct entries — normalize casing yourself before passing the array.
|
|
121
161
|
- `ignores` and `renamePlugins` are composer concerns, not factory options.
|
|
122
162
|
- `react.compiler` accepts `true`, `false`, `"recommended"`, or `"latest"`.
|
|
123
163
|
- A custom plugin layer must register the plugin before using its rules; the
|