@zedtech/zedkit-quality 0.2.0 → 0.3.0
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 +5 -2
- package/package.json +1 -1
- package/src/eslint.d.mts +18 -0
- package/src/eslint.mjs +19 -2
package/README.md
CHANGED
|
@@ -55,10 +55,13 @@ subagents, commands) see `@zedtech/zedkit-ai` instead.
|
|
|
55
55
|
jsx-a11y recommended, Tailwind hygiene, tokens-only classes, no `style`
|
|
56
56
|
attributes, no raw `try`/`catch`. `entryPoint` (your Tailwind CSS
|
|
57
57
|
entry) is required: it is the one thing that varies per repo.
|
|
58
|
-
- `defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns })` —
|
|
58
|
+
- `defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns, extraPatterns })` —
|
|
59
59
|
`no-restricted-imports` blocks for routes -> views -> data: the UI kit
|
|
60
60
|
is only imported from views, views never import data clients or
|
|
61
|
-
actions, data files import no UI.
|
|
61
|
+
actions, data files import no UI. `extraPatterns` (optional,
|
|
62
|
+
`{ kitScope?, viewData?, dataUi? }`) merges your own bans into each
|
|
63
|
+
block — use it instead of a second `no-restricted-imports` block,
|
|
64
|
+
which would replace these per flat-config key semantics.
|
|
62
65
|
- `@zedtech/zedkit-quality/tsconfig` — the strict base (`strict`,
|
|
63
66
|
`exactOptionalPropertyTypes`, `noUncheckedIndexedAccess`,
|
|
64
67
|
`noUnusedLocals`, and more). Extend it, do not copy it.
|
package/package.json
CHANGED
package/src/eslint.d.mts
CHANGED
|
@@ -7,6 +7,14 @@ export interface UiPresetOptions {
|
|
|
7
7
|
|
|
8
8
|
export function uiPreset(options: UiPresetOptions): Linter.Config[];
|
|
9
9
|
|
|
10
|
+
/** A `no-restricted-imports` pattern object, passed through untouched. */
|
|
11
|
+
export interface RestrictedImportPattern {
|
|
12
|
+
readonly group: readonly string[];
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly importNames?: readonly string[];
|
|
15
|
+
readonly allowTypeImports?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
export interface DefineLayersOptions {
|
|
11
19
|
/** UI kit specifier (e.g. `@acme/ui`). */
|
|
12
20
|
readonly kitPackage: string;
|
|
@@ -16,6 +24,16 @@ export interface DefineLayersOptions {
|
|
|
16
24
|
readonly dataDirs: readonly string[];
|
|
17
25
|
/** Import specifiers for data clients and server actions. */
|
|
18
26
|
readonly actionPatterns: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Consumer bans merged into each block's own patterns (flat-config
|
|
29
|
+
* rules replace per key, so a consumer block setting
|
|
30
|
+
* `no-restricted-imports` would otherwise drop these).
|
|
31
|
+
*/
|
|
32
|
+
readonly extraPatterns?: {
|
|
33
|
+
readonly kitScope?: readonly RestrictedImportPattern[];
|
|
34
|
+
readonly viewData?: readonly RestrictedImportPattern[];
|
|
35
|
+
readonly dataUi?: readonly RestrictedImportPattern[];
|
|
36
|
+
};
|
|
19
37
|
}
|
|
20
38
|
|
|
21
39
|
export function defineLayers(options: DefineLayersOptions): Linter.Config[];
|
package/src/eslint.mjs
CHANGED
|
@@ -116,17 +116,31 @@ function asFiles(patterns) {
|
|
|
116
116
|
* - views receive data as props and never import data clients or actions;
|
|
117
117
|
* - data files import no UI (no React runtime, no UI kit).
|
|
118
118
|
*
|
|
119
|
-
* @param {{ kitPackage: string, viewDirs: string[], dataDirs: string[], actionPatterns: string[] }} options
|
|
119
|
+
* @param {{ kitPackage: string, viewDirs: string[], dataDirs: string[], actionPatterns: string[], extraPatterns?: { kitScope?: object[], viewData?: object[], dataUi?: object[] } }} options
|
|
120
120
|
* - `kitPackage`: UI kit specifier (e.g. `@acme/ui`).
|
|
121
121
|
* - `viewDirs`: view folders (e.g. `app/ui/**`) or file globs.
|
|
122
122
|
* - `dataDirs`: data-access folders or file globs, same shapes.
|
|
123
123
|
* - `actionPatterns`: import specifiers for data clients and server actions.
|
|
124
|
+
* - `extraPatterns`: consumer bans merged into each block's own
|
|
125
|
+
* patterns (flat-config rules replace per key, so a consumer block
|
|
126
|
+
* setting `no-restricted-imports` would otherwise drop these).
|
|
127
|
+
* Keys: `kitScope`, `viewData`, `dataUi`; each a list of standard
|
|
128
|
+
* `no-restricted-imports` pattern objects, passed through untouched.
|
|
124
129
|
* @returns {import("eslint").Linter.Config[]} Flat config blocks.
|
|
125
130
|
*/
|
|
126
|
-
export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns }) {
|
|
131
|
+
export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns, extraPatterns = {} }) {
|
|
132
|
+
for (const [key, value] of Object.entries(extraPatterns)) {
|
|
133
|
+
if (key !== "kitScope" && key !== "viewData" && key !== "dataUi") {
|
|
134
|
+
throw new Error(`defineLayers: unknown extraPatterns key "${key}" (want kitScope, viewData or dataUi)`);
|
|
135
|
+
}
|
|
136
|
+
if (!Array.isArray(value)) {
|
|
137
|
+
throw new Error(`defineLayers: extraPatterns.${key} must be a list of no-restricted-imports pattern objects`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
127
140
|
const kitPatterns = [kitPackage, `${kitPackage}/*`];
|
|
128
141
|
const views = asFiles(viewDirs);
|
|
129
142
|
const data = asFiles(dataDirs);
|
|
143
|
+
const extras = { kitScope: [], viewData: [], dataUi: [], ...extraPatterns };
|
|
130
144
|
return [
|
|
131
145
|
{
|
|
132
146
|
name: "zedkit/layers-kit-scope",
|
|
@@ -141,6 +155,7 @@ export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns })
|
|
|
141
155
|
group: kitPatterns,
|
|
142
156
|
message: "UI kit imports are only allowed from view files. Move this import into a view.",
|
|
143
157
|
},
|
|
158
|
+
...extras.kitScope,
|
|
144
159
|
],
|
|
145
160
|
},
|
|
146
161
|
],
|
|
@@ -158,6 +173,7 @@ export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns })
|
|
|
158
173
|
group: [...actionPatterns],
|
|
159
174
|
message: "Views receive data as props and never import data clients or server actions.",
|
|
160
175
|
},
|
|
176
|
+
...extras.viewData,
|
|
161
177
|
],
|
|
162
178
|
},
|
|
163
179
|
],
|
|
@@ -179,6 +195,7 @@ export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns })
|
|
|
179
195
|
group: kitPatterns,
|
|
180
196
|
message: "Data code is UI-free: no UI kit imports.",
|
|
181
197
|
},
|
|
198
|
+
...extras.dataUi,
|
|
182
199
|
],
|
|
183
200
|
},
|
|
184
201
|
],
|