@zedtech/zedkit-quality 0.3.0 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zedtech/zedkit-quality",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
package/src/eslint.d.mts CHANGED
@@ -22,7 +22,7 @@ export interface DefineLayersOptions {
22
22
  readonly viewDirs: readonly string[];
23
23
  /** Minimatch globs for data-access folders. */
24
24
  readonly dataDirs: readonly string[];
25
- /** Import specifiers for data clients and server actions. */
25
+ /** Import specifiers for data clients and server actions. May be empty. */
26
26
  readonly actionPatterns: readonly string[];
27
27
  /**
28
28
  * Consumer bans merged into each block's own patterns (flat-config
package/src/eslint.mjs CHANGED
@@ -121,6 +121,9 @@ function asFiles(patterns) {
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
+ * May be empty (views legitimately import data): the view ban is
125
+ * then omitted, and the view block is dropped when it would carry
126
+ * no bans at all.
124
127
  * - `extraPatterns`: consumer bans merged into each block's own
125
128
  * patterns (flat-config rules replace per key, so a consumer block
126
129
  * setting `no-restricted-imports` would otherwise drop these).
@@ -137,10 +140,27 @@ export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns, e
137
140
  throw new Error(`defineLayers: extraPatterns.${key} must be a list of no-restricted-imports pattern objects`);
138
141
  }
139
142
  }
143
+ if (!Array.isArray(actionPatterns)) {
144
+ throw new Error("defineLayers: actionPatterns must be a list of import specifiers (may be empty)");
145
+ }
140
146
  const kitPatterns = [kitPackage, `${kitPackage}/*`];
141
147
  const views = asFiles(viewDirs);
142
148
  const data = asFiles(dataDirs);
143
149
  const extras = { kitScope: [], viewData: [], dataUi: [], ...extraPatterns };
150
+ // An empty group fails ESLint schema validation, so an empty
151
+ // actionPatterns omits the ban; with no viewData extras either,
152
+ // the whole block is dropped (a ban-less block is noise).
153
+ const viewDataPatterns = [
154
+ ...(actionPatterns.length > 0
155
+ ? [
156
+ {
157
+ group: [...actionPatterns],
158
+ message: "Views receive data as props and never import data clients or server actions.",
159
+ },
160
+ ]
161
+ : []),
162
+ ...extras.viewData,
163
+ ];
144
164
  return [
145
165
  {
146
166
  name: "zedkit/layers-kit-scope",
@@ -161,24 +181,17 @@ export function defineLayers({ kitPackage, viewDirs, dataDirs, actionPatterns, e
161
181
  ],
162
182
  },
163
183
  },
164
- {
165
- name: "zedkit/layers-view-data",
166
- files: views,
167
- rules: {
168
- "no-restricted-imports": [
169
- "error",
184
+ ...(viewDataPatterns.length > 0
185
+ ? [
170
186
  {
171
- patterns: [
172
- {
173
- group: [...actionPatterns],
174
- message: "Views receive data as props and never import data clients or server actions.",
175
- },
176
- ...extras.viewData,
177
- ],
187
+ name: "zedkit/layers-view-data",
188
+ files: views,
189
+ rules: {
190
+ "no-restricted-imports": ["error", { patterns: viewDataPatterns }],
191
+ },
178
192
  },
179
- ],
180
- },
181
- },
193
+ ]
194
+ : []),
182
195
  {
183
196
  name: "zedkit/layers-data-ui",
184
197
  files: data,