eslint-plugin-kerfjs 5.0.0-beta.117 → 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.
@@ -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.117' },
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',
@@ -262,7 +262,10 @@ export function loadUiContract(context) {
262
262
  for (const helper of entry.wiring?.sources ?? [])
263
263
  helperSourceFiles.set(
264
264
  `${resolve(root, helper.source)}\0${helper.export}`,
265
- helper.export,
265
+ {
266
+ imported: helper.export,
267
+ returnsDisposer: helper.returnsDisposer !== false,
268
+ },
266
269
  );
267
270
  }
268
271
  const imports = new Map();
@@ -560,7 +563,7 @@ export function helperCall(callee, registry, contract, filename) {
560
563
  imported,
561
564
  new Set(),
562
565
  );
563
- if (resolved) return { imported: resolved, source };
566
+ if (resolved) return { ...resolved, source };
564
567
  }
565
568
  return undefined;
566
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-kerfjs",
3
- "version": "5.0.0-beta.117",
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",