eslint-plugin-kerfjs 5.0.0-beta.116 → 5.0.0-beta.118

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 CHANGED
@@ -79,6 +79,8 @@ settings: {
79
79
 
80
80
  For deterministic generated configs, the same settings accept parsed `catalog`, `selectionCatalog`, and `profile` objects. File-based precedence is package defaults, then workspace profile, then root-to-leaf directory profiles. The rules load `application-ui-profile-sync.cjs` from the installed `@kerfjs/ui` package by default because ESLint rule creation is synchronous; `profileContractPath` is only needed when artifacts are vendored, and then its directory must also hold `application-ui-diagnostic-ids-v1.json` and `component-class-owners.cjs` (the class-to-component rule `KUI-L103` shares with `@kerfjs/ui`'s generated component pages) from the same `@kerfjs/ui` release. Every raw layer is schema- and catalog-reference-validated before merge, so a child cannot hide malformed or stale parent policy. Exceptions use exact `KUI-L*` diagnostic ids and repository-relative file or directory targets.
81
81
 
82
+ When linting a nested workspace package, set `workspaceRoot` to the repository root. Installed `@kerfjs/ui` assets still resolve from ESLint's package `cwd`, while profile discovery and exception targets use the workspace root.
83
+
82
84
  `ui-css-values` consumes each catalog entry's property-specific grammar and
83
85
  emits `KUI-L013`–`KUI-L016` with a preferred shorthand or helper. It covers JSX,
84
86
  direct component calls, nested catalog paths, and explicitly configured
@@ -1,6 +1,6 @@
1
1
  # `kerfjs/ai-assistant-configs`
2
2
 
3
- Check that the [kerf-app Claude Code skill](https://github.com/brianwestphal/kerf/blob/main/kerf.claude-skill.md) and [Cursor rules](https://github.com/brianwestphal/kerf/blob/main/kerf.cursorrules) drop-ins are installed in the project and up-to-date with the canonical files bundled inside the consumer's installed `kerfjs` package.
3
+ Check that the [kerf-app Claude Code skill](https://github.com/brianwestphal/kerf/blob/main/kerf.claude-skill.md), [kerf-ui skill](https://github.com/brianwestphal/kerf/blob/main/kerf.ui-skill.md), and [Cursor rules](https://github.com/brianwestphal/kerf/blob/main/kerf.cursorrules) drop-ins are installed in the project and up-to-date with the canonical files bundled inside the consumer's installed `kerfjs` package.
4
4
 
5
5
  Unlike the other AST-based rules in this plugin, this rule reads the **filesystem**, not source code. It runs once per lint pass and reports project-level hygiene issues rather than per-file code defects. Severity in `kerfjs.configs.recommended` is `warn`, not `error` — a missing skill file shouldn't fail CI.
6
6
 
@@ -10,10 +10,11 @@ Maps to design doc [`docs/12-ai-assistant-configs.md`](https://github.com/brianw
10
10
 
11
11
  The rule resolves `kerfjs/ai/manifest.json` from the consumer's installed `kerfjs` (silently no-ops if `kerfjs` isn't a dep). For each bundled file, it picks a trigger heuristic — "is this project using the tool this file is for?" — and only nudges the consumer when the trigger says yes:
12
12
 
13
- | Bundled file | Triggers when | Installed to |
14
- | --------------------------- | -------------------------------------------------- | ---------------------------------- |
15
- | `ai/skill.md` (Claude Code) | `.claude/` directory exists at the project root | `.claude/skills/kerf-app/SKILL.md` |
16
- | `ai/cursorrules` (Cursor) | `.cursorrules` file or `.cursor/` directory exists | `.cursorrules` |
13
+ | Bundled file | Triggers when | Installed to |
14
+ | ------------------------------ | -------------------------------------------------------------------------------------- | ---------------------------------- |
15
+ | `ai/skill.md` (Claude Code) | `.claude/` directory exists at the project root | `.claude/skills/kerf-app/SKILL.md` |
16
+ | `ai/ui-skill.md` (Claude Code) | `.claude/` exists and the project declares `@kerfjs/ui` or setup state records UI mode | `.claude/skills/kerf-ui/SKILL.md` |
17
+ | `ai/cursorrules` (Cursor) | `.cursorrules` file or `.cursor/` directory exists | `.cursorrules` |
17
18
 
18
19
  A triggered file is then classified into one of three reported states (a fourth, "up-to-date," is silent):
19
20
 
@@ -1,6 +1,6 @@
1
1
  # `ui-wiring`
2
2
 
3
- Checks wiring obligations published by the versioned composition catalog. `KUI-L401` reports a used component whose required helper or side-effect registration import is absent. `KUI-L402` reports a helper call whose disposer is discarded.
3
+ Checks wiring obligations published by the versioned composition catalog. `KUI-L401` reports a used component whose required helper or side-effect registration import is absent. `KUI-L402` reports a disposer-returning helper call whose disposer is discarded.
4
4
 
5
5
  Declare application entry modules in the application UI profile to check root wiring once per entry:
6
6
 
@@ -30,6 +30,8 @@ Consumer composition catalogs can name an application helper's defining file in
30
30
 
31
31
  The source path is relative to the catalog package root. The rule resolves relative imports, aliases, and re-export barrels to that file, so another function with the same name does not satisfy the obligation.
32
32
 
33
+ Application-owned helpers default to returning a disposer. If a composition root is typed `void` and owns page-lifetime wiring internally, set `"returnsDisposer": false` on its `wiring.sources` entry. A direct call then satisfies `KUI-L401` without triggering `KUI-L402` or requiring a meaningless `void` operator. Set this only when the exported helper genuinely has no cleanup handle; disposer-returning helpers still need their return value retained or returned.
34
+
33
35
  Required wiring can instead be the application's own root-delegated handlers. List the `data-action` values in `wiring.actions` (required wiring names at least one helper or action):
34
36
 
35
37
  ```json
package/index.js CHANGED
@@ -15,7 +15,7 @@ import uiPublicBoundaries from './lib/rules/ui-public-boundaries.js';
15
15
  import uiWiring from './lib/rules/ui-wiring.js';
16
16
 
17
17
  const plugin = {
18
- meta: { name: 'eslint-plugin-kerfjs', version: '5.0.0-beta.116' },
18
+ meta: { name: 'eslint-plugin-kerfjs', version: '5.0.0-beta.118' },
19
19
  rules: {
20
20
  'no-inline-jsx-event-handlers': noInlineJsxEventHandlers,
21
21
  'no-raw-with-dynamic-arg': noRawWithDynamicArg,
@@ -29,6 +29,10 @@ const VERSION_RE = /kerf-skill-version:\s*(\d+\.\d+\.\d+(?:-[\w.]+)?)/;
29
29
  const VERSION_SCAN_BYTES = 512;
30
30
  const SHARED_SKILL_PREFIX =
31
31
  '---\nname: kerf-app\ndescription: Use the shared workspace guidance for Kerf application work.\n---\n\n@';
32
+ const SHARED_UI_SKILL_PREFIX =
33
+ '---\nname: kerf-ui\ndescription: Use shared workspace guidance and the installed @kerfjs/ui instructions.\n---\n\n@';
34
+ const SHARED_UI_SKILL_SUFFIX =
35
+ '\n\nIn the selected package, read `node_modules/@kerfjs/ui/llms.txt` first, then `node_modules/@kerfjs/ui/ai/skill.md` and the component references they name.\n';
32
36
 
33
37
  function sharedGuidanceSource(cwd) {
34
38
  try {
@@ -61,7 +65,33 @@ function sharedSkill(file, cwd, source) {
61
65
  dirname(join(cwd, file.dest)),
62
66
  join(cwd, source),
63
67
  ).replaceAll('\\', '/');
64
- return `${SHARED_SKILL_PREFIX}${importPath}\n`;
68
+ return file.name === 'ui-skill'
69
+ ? `${SHARED_UI_SKILL_PREFIX}${importPath}${SHARED_UI_SKILL_SUFFIX}`
70
+ : `${SHARED_SKILL_PREFIX}${importPath}\n`;
71
+ }
72
+
73
+ function usesUi(cwd) {
74
+ try {
75
+ const state = JSON.parse(
76
+ readFileSync(join(cwd, '.kerf-ai-setup.json'), 'utf8'),
77
+ );
78
+ if (
79
+ Object.values(state.packages ?? {}).some((entry) => entry.mode === 'ui')
80
+ )
81
+ return true;
82
+ } catch {
83
+ // A consumer may not have run setup yet.
84
+ }
85
+ try {
86
+ const manifest = JSON.parse(
87
+ readFileSync(join(cwd, 'package.json'), 'utf8'),
88
+ );
89
+ return ['dependencies', 'devDependencies', 'peerDependencies'].some(
90
+ (group) => Boolean(manifest[group]?.['@kerfjs/ui']),
91
+ );
92
+ } catch {
93
+ return false;
94
+ }
65
95
  }
66
96
 
67
97
  // Module-level once-per-lint-run guard. ESLint instantiates the rule
@@ -148,13 +178,17 @@ export function classifyFile(file, bundleDir, cwd) {
148
178
  }
149
179
 
150
180
  if (
151
- file.name === 'skill' &&
152
- /^---\nname: kerf-app\n/.test(consumer) &&
153
- /\n@[^\n]+\n$/.test(consumer)
181
+ (file.name === 'skill' || file.name === 'ui-skill') &&
182
+ /^---\nname: kerf-(?:app|ui)\n/.test(consumer) &&
183
+ /\n@[^\n]+\n/.test(consumer)
154
184
  ) {
155
- const match = consumer.match(
156
- /^---\nname: kerf-app\ndescription: Use the shared workspace guidance for Kerf application work\.\n---\n\n@([^\n]+)\n$/,
157
- );
185
+ const prefix =
186
+ file.name === 'ui-skill' ? SHARED_UI_SKILL_PREFIX : SHARED_SKILL_PREFIX;
187
+ const suffix = file.name === 'ui-skill' ? SHARED_UI_SKILL_SUFFIX : '\n';
188
+ const match =
189
+ consumer.startsWith(prefix) && consumer.endsWith(suffix)
190
+ ? [null, consumer.slice(prefix.length, -suffix.length)]
191
+ : null;
158
192
  if (!match)
159
193
  return { state: 'forked', reason: 'malformed shared guidance import' };
160
194
  const sourcePath = resolve(dirname(destAbs), match[1]);
@@ -254,6 +288,8 @@ function loadBundle(cwd) {
254
288
 
255
289
  function isTriggered(name, cwd) {
256
290
  if (name === 'skill') return existsSync(join(cwd, '.claude'));
291
+ if (name === 'ui-skill')
292
+ return existsSync(join(cwd, '.claude')) && usesUi(cwd);
257
293
  if (name === 'cursorrules') {
258
294
  return (
259
295
  existsSync(join(cwd, '.cursorrules')) || existsSync(join(cwd, '.cursor'))
@@ -275,7 +311,11 @@ export function runCheck(cwd) {
275
311
  for (const file of bundle.manifest.files) {
276
312
  if (!isTriggered(file.name, root)) continue;
277
313
  let result = classifyFile(file, bundle.bundleDir, root);
278
- if (file.name === 'skill' && sharedSource && result.state === 'ok') {
314
+ if (
315
+ (file.name === 'skill' || file.name === 'ui-skill') &&
316
+ sharedSource &&
317
+ result.state === 'ok'
318
+ ) {
279
319
  const actual = readFileSync(join(root, file.dest), 'utf8');
280
320
  if (actual !== sharedSkill(file, root, sharedSource))
281
321
  result = {
@@ -295,7 +335,9 @@ export function runCheck(cwd) {
295
335
  */
296
336
  export function applyFix(file, bundleDir, cwd, appendZone) {
297
337
  const bundlePath = join(bundleDir, file.bundle.replace(/^ai\//, ''));
298
- const sharedSource = file.name === 'skill' && sharedGuidanceSource(cwd);
338
+ const sharedSource =
339
+ (file.name === 'skill' || file.name === 'ui-skill') &&
340
+ sharedGuidanceSource(cwd);
299
341
  const canonical = sharedSource
300
342
  ? sharedSkill(file, cwd, sharedSource)
301
343
  : readFileSync(bundlePath, 'utf8');
@@ -350,14 +392,20 @@ function create(context) {
350
392
  if (!checked) return;
351
393
 
352
394
  for (const { file, result } of checked.results) {
353
- if (file.name === 'skill' && !claudeEnabled) continue;
395
+ if (
396
+ (file.name === 'skill' || file.name === 'ui-skill') &&
397
+ !claudeEnabled
398
+ )
399
+ continue;
354
400
  if (file.name === 'cursorrules' && !cursorEnabled) continue;
355
401
  if (result.state === 'ok') continue;
356
402
 
357
403
  const tool =
358
404
  file.name === 'skill'
359
405
  ? 'Claude Code kerf-app skill'
360
- : 'Cursor kerf rules';
406
+ : file.name === 'ui-skill'
407
+ ? 'Claude Code kerf-ui skill'
408
+ : 'Cursor kerf rules';
361
409
  const bundle = file.bundle; // e.g. 'ai/skill.md'
362
410
  const data = { tool, dest: file.dest, bundle };
363
411
 
@@ -250,7 +250,10 @@ export default {
250
250
  const imported = helperCall(node.callee, registry, contract, filename);
251
251
  if (!imported) return;
252
252
  const list = calls.get(imported.imported) ?? [];
253
- list.push({ node, source: imported.source });
253
+ list.push({
254
+ node,
255
+ returnsDisposer: imported.returnsDisposer !== false,
256
+ });
254
257
  calls.set(imported.imported, list);
255
258
  },
256
259
  'Program:exit'(node) {
@@ -337,8 +340,8 @@ export default {
337
340
  );
338
341
  for (const [helper, helperCalls] of calls)
339
342
  if (disposerHelpers.has(helper))
340
- for (const { node: call } of helperCalls)
341
- if (!retained(call))
343
+ for (const { node: call, returnsDisposer } of helperCalls)
344
+ if (returnsDisposer && !retained(call))
342
345
  context.report({
343
346
  node: call,
344
347
  messageId: 'cleanup',
@@ -145,7 +145,8 @@ function loadClassOwnership(profileContractPath) {
145
145
 
146
146
  export function loadUiContract(context) {
147
147
  const settings = context.settings?.kerfjs?.ui ?? {};
148
- const cwd = settings.workspaceRoot ?? context.cwd ?? process.cwd();
148
+ const packageCwd = context.cwd ?? process.cwd();
149
+ const cwd = resolve(settings.workspaceRoot ?? packageCwd);
149
150
  const filename = context.filename ?? context.getFilename();
150
151
  const key = JSON.stringify([cwd, filename, settings]);
151
152
  if (cache.has(key)) return cache.get(key);
@@ -153,13 +154,14 @@ export function loadUiContract(context) {
153
154
  const catalog =
154
155
  settings.catalog ??
155
156
  readJson(
156
- settings.catalogPath ?? packageAsset(cwd, 'component-composition.json'),
157
+ settings.catalogPath ??
158
+ packageAsset(packageCwd, 'component-composition.json'),
157
159
  );
158
160
  const selection =
159
161
  settings.selectionCatalog ??
160
162
  readJson(
161
163
  settings.selectionCatalogPath ??
162
- packageAsset(cwd, 'component-catalog.json'),
164
+ packageAsset(packageCwd, 'component-catalog.json'),
163
165
  );
164
166
  const profiles = settings.profilePath
165
167
  ? [
@@ -168,10 +170,10 @@ export function loadUiContract(context) {
168
170
  profile: readJson(settings.profilePath),
169
171
  },
170
172
  ]
171
- : discoveredProfiles(cwd, filename, settings);
173
+ : discoveredProfiles(packageCwd, filename, settings);
172
174
  const profileContractPath =
173
175
  settings.profileContractPath ??
174
- packageAsset(cwd, 'application-ui-profile-sync.cjs');
176
+ packageAsset(packageCwd, 'application-ui-profile-sync.cjs');
175
177
  if (!profileContractPath)
176
178
  throw new Error(
177
179
  'Cannot resolve @kerfjs/ui/ai/application-ui-profile-sync.cjs; install @kerfjs/ui or set kerfjs.ui.profileContractPath.',
@@ -260,7 +262,10 @@ export function loadUiContract(context) {
260
262
  for (const helper of entry.wiring?.sources ?? [])
261
263
  helperSourceFiles.set(
262
264
  `${resolve(root, helper.source)}\0${helper.export}`,
263
- helper.export,
265
+ {
266
+ imported: helper.export,
267
+ returnsDisposer: helper.returnsDisposer !== false,
268
+ },
264
269
  );
265
270
  }
266
271
  const imports = new Map();
@@ -558,7 +563,7 @@ export function helperCall(callee, registry, contract, filename) {
558
563
  imported,
559
564
  new Set(),
560
565
  );
561
- if (resolved) return { imported: resolved, source };
566
+ if (resolved) return { ...resolved, source };
562
567
  }
563
568
  return undefined;
564
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-kerfjs",
3
- "version": "5.0.0-beta.116",
3
+ "version": "5.0.0-beta.118",
4
4
  "description": "ESLint rules that enforce kerf's hard rules — catches AI-shaped bugs at edit time.",
5
5
  "type": "module",
6
6
  "license": "MIT",