@nifrajs/cli 5.5.1 → 5.6.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/dist/cdn-check.d.ts +7 -6
  3. package/dist/cdn-check.d.ts.map +1 -1
  4. package/dist/cdn-check.js +13 -1
  5. package/dist/cdn-check.js.map +1 -1
  6. package/dist/check-diagnostics.d.ts.map +1 -1
  7. package/dist/check-diagnostics.js +5 -3
  8. package/dist/check-diagnostics.js.map +1 -1
  9. package/dist/check-scan.d.ts.map +1 -1
  10. package/dist/check-scan.js +29 -2
  11. package/dist/check-scan.js.map +1 -1
  12. package/dist/cli.d.ts.map +1 -1
  13. package/dist/cli.js +14 -5
  14. package/dist/cli.js.map +1 -1
  15. package/dist/command-catalog.d.ts +14 -1
  16. package/dist/command-catalog.d.ts.map +1 -1
  17. package/dist/command-catalog.js +93 -0
  18. package/dist/command-catalog.js.map +1 -1
  19. package/dist/doctor.d.ts +9 -1
  20. package/dist/doctor.d.ts.map +1 -1
  21. package/dist/doctor.js +52 -0
  22. package/dist/doctor.js.map +1 -1
  23. package/dist/fix-recipes.d.ts.map +1 -1
  24. package/dist/fix-recipes.js +27 -0
  25. package/dist/fix-recipes.js.map +1 -1
  26. package/dist/frontend-guidance.d.ts +1 -1
  27. package/dist/frontend-guidance.d.ts.map +1 -1
  28. package/dist/frontend-guidance.js +17 -8
  29. package/dist/frontend-guidance.js.map +1 -1
  30. package/dist/introspect.js +1 -1
  31. package/dist/introspect.js.map +1 -1
  32. package/dist/load.d.ts +4 -1
  33. package/dist/load.d.ts.map +1 -1
  34. package/dist/load.js +8 -0
  35. package/dist/load.js.map +1 -1
  36. package/dist/mcp-exec.d.ts.map +1 -1
  37. package/dist/mcp-exec.js +57 -3
  38. package/dist/mcp-exec.js.map +1 -1
  39. package/dist/mcp-http.d.ts +2 -1
  40. package/dist/mcp-http.d.ts.map +1 -1
  41. package/dist/mcp-http.js +3 -2
  42. package/dist/mcp-http.js.map +1 -1
  43. package/dist/mcp-tool-meta.d.ts +21 -0
  44. package/dist/mcp-tool-meta.d.ts.map +1 -0
  45. package/dist/mcp-tool-meta.js +246 -0
  46. package/dist/mcp-tool-meta.js.map +1 -0
  47. package/dist/mcp.d.ts +3 -2
  48. package/dist/mcp.d.ts.map +1 -1
  49. package/dist/mcp.js +36 -98
  50. package/dist/mcp.js.map +1 -1
  51. package/dist/output-schemas.d.ts +8 -0
  52. package/dist/output-schemas.d.ts.map +1 -1
  53. package/dist/output-schemas.js +14 -0
  54. package/dist/output-schemas.js.map +1 -1
  55. package/dist/ppr-read-fix.d.ts +8 -0
  56. package/dist/ppr-read-fix.d.ts.map +1 -0
  57. package/dist/ppr-read-fix.js +356 -0
  58. package/dist/ppr-read-fix.js.map +1 -0
  59. package/dist/recipes/5.6.0.d.ts +10 -0
  60. package/dist/recipes/5.6.0.d.ts.map +1 -0
  61. package/dist/recipes/5.6.0.js +68 -0
  62. package/dist/recipes/5.6.0.js.map +1 -0
  63. package/dist/recipes/index.d.ts.map +1 -1
  64. package/dist/recipes/index.js +2 -0
  65. package/dist/recipes/index.js.map +1 -1
  66. package/dist/review.d.ts.map +1 -1
  67. package/dist/review.js +7 -2
  68. package/dist/review.js.map +1 -1
  69. package/dist/rules/codes.d.ts +8 -3
  70. package/dist/rules/codes.d.ts.map +1 -1
  71. package/dist/rules/codes.js +9 -4
  72. package/dist/rules/codes.js.map +1 -1
  73. package/dist/rules/explanations.d.ts.map +1 -1
  74. package/dist/rules/explanations.js +39 -13
  75. package/dist/rules/explanations.js.map +1 -1
  76. package/dist/rules/islands.d.ts +91 -0
  77. package/dist/rules/islands.d.ts.map +1 -1
  78. package/dist/rules/islands.js +757 -3
  79. package/dist/rules/islands.js.map +1 -1
  80. package/dist/rules/ppr.d.ts +16 -0
  81. package/dist/rules/ppr.d.ts.map +1 -0
  82. package/dist/rules/ppr.js +114 -0
  83. package/dist/rules/ppr.js.map +1 -0
  84. package/dist/rules/swap.d.ts +7 -0
  85. package/dist/rules/swap.d.ts.map +1 -0
  86. package/dist/rules/swap.js +338 -0
  87. package/dist/rules/swap.js.map +1 -0
  88. package/dist/scaffold-hole.d.ts +105 -0
  89. package/dist/scaffold-hole.d.ts.map +1 -0
  90. package/dist/scaffold-hole.js +688 -0
  91. package/dist/scaffold-hole.js.map +1 -0
  92. package/dist/scaffold.d.ts +5 -3
  93. package/dist/scaffold.d.ts.map +1 -1
  94. package/dist/scaffold.js +56 -46
  95. package/dist/scaffold.js.map +1 -1
  96. package/dist/verification-plan.d.ts.map +1 -1
  97. package/dist/verification-plan.js +12 -1
  98. package/dist/verification-plan.js.map +1 -1
  99. package/dist/web-app-options.d.ts +1 -1
  100. package/dist/web-app-options.d.ts.map +1 -1
  101. package/dist/web-app-options.js.map +1 -1
  102. package/docs/examples.json +63 -9
  103. package/docs/llms-full.txt +2060 -430
  104. package/docs/types.json +1300 -270
  105. package/package.json +11 -11
  106. package/src/cdn-check.ts +21 -7
  107. package/src/check-diagnostics.ts +5 -3
  108. package/src/check-scan.ts +34 -3
  109. package/src/cli.ts +14 -5
  110. package/src/command-catalog.ts +126 -0
  111. package/src/doctor.ts +44 -1
  112. package/src/fix-recipes.ts +28 -0
  113. package/src/frontend-guidance.ts +20 -8
  114. package/src/introspect.ts +1 -1
  115. package/src/load.ts +13 -0
  116. package/src/mcp-exec.ts +74 -3
  117. package/src/mcp-http.ts +3 -2
  118. package/src/mcp-tool-meta.ts +268 -0
  119. package/src/mcp.ts +35 -99
  120. package/src/output-schemas.ts +28 -0
  121. package/src/ppr-read-fix.ts +426 -0
  122. package/src/recipes/5.6.0.ts +69 -0
  123. package/src/recipes/index.ts +2 -0
  124. package/src/review.ts +7 -2
  125. package/src/rules/codes.ts +9 -4
  126. package/src/rules/explanations.ts +39 -13
  127. package/src/rules/islands.ts +875 -3
  128. package/src/rules/ppr.ts +143 -0
  129. package/src/rules/swap.ts +402 -0
  130. package/src/scaffold-hole.ts +880 -0
  131. package/src/scaffold.ts +60 -49
  132. package/src/verification-plan.ts +20 -1
  133. package/src/web-app-options.ts +1 -0
  134. package/dist/rules/nano.d.ts +0 -6
  135. package/dist/rules/nano.d.ts.map +0 -1
  136. package/dist/rules/nano.js +0 -273
  137. package/dist/rules/nano.js.map +0 -1
  138. package/src/rules/nano.ts +0 -307
@@ -57,6 +57,9 @@ function parsedTree(
57
57
 
58
58
  type EnhancerFn = TSApi.ArrowFunction | TSApi.FunctionExpression
59
59
 
60
+ // The calls that mount islands from an enhancer map.
61
+ const MOUNT_CALLS = new Set(["mountIslands", "enableSwap"])
62
+
60
63
  function isEnhancerFn(ts: typeof TSApi, node: TSApi.Node): node is EnhancerFn {
61
64
  return ts.isArrowFunction(node) || ts.isFunctionExpression(node)
62
65
  }
@@ -101,7 +104,7 @@ function returnsCleanup(ts: typeof TSApi, fn: EnhancerFn): boolean {
101
104
  }
102
105
 
103
106
  /** The inline enhancer functions authored in `file`: the argument to `defineIsland(...)` and every
104
- * function-typed value of a `mountIslands({ ... })` object literal. */
107
+ * function-typed value of a `mountIslands({ ... })` or `enableSwap({ ... })` object literal. */
105
108
  function enhancerFns(ts: typeof TSApi, tree: TSApi.SourceFile): EnhancerFn[] {
106
109
  const out: EnhancerFn[] = []
107
110
  const visit = (node: TSApi.Node): void => {
@@ -110,7 +113,7 @@ function enhancerFns(ts: typeof TSApi, tree: TSApi.SourceFile): EnhancerFn[] {
110
113
  if (callee === "defineIsland") {
111
114
  const arg = node.arguments[0]
112
115
  if (arg !== undefined && isEnhancerFn(ts, arg)) out.push(arg)
113
- } else if (callee === "mountIslands") {
116
+ } else if (MOUNT_CALLS.has(callee)) {
114
117
  const arg = node.arguments[0]
115
118
  if (arg !== undefined && ts.isObjectLiteralExpression(arg)) {
116
119
  for (const prop of arg.properties) {
@@ -176,4 +179,873 @@ export const islandCleanupRule: CheckRule = {
176
179
  },
177
180
  }
178
181
 
179
- export const islandRules = Object.freeze([islandCleanupRule])
182
+ export const lineOf = (tree: TSApi.SourceFile, node: TSApi.Node): number =>
183
+ tree.getLineAndCharacterOfPosition(node.getStart(tree)).line + 1
184
+
185
+ export function toolchainMissing(code: string, title: string): Diagnostic {
186
+ return diagnostic({
187
+ code,
188
+ severity: "warn",
189
+ message: `${title} (${code}) did NOT run - TypeScript is not installed, so this report says nothing about it`,
190
+ fix: { recipe: "toolchain.install-typescript", command: "bun add -d typescript" },
191
+ verify: "nifra check --lints-only",
192
+ })
193
+ }
194
+
195
+ /** The names a parameter binds: its identifier, or each identifier its destructuring pattern binds. */
196
+ function boundNames(
197
+ ts: typeof TSApi,
198
+ name: TSApi.BindingName,
199
+ out = new Set<string>(),
200
+ ): Set<string> {
201
+ if (ts.isIdentifier(name)) out.add(name.text)
202
+ else
203
+ for (const element of name.elements)
204
+ if (!ts.isOmittedExpression(element)) boundNames(ts, element.name, out)
205
+ return out
206
+ }
207
+
208
+ /** Whether `node` reads any of `names` (a property name such as the `id` of `x.id` is not a read). */
209
+ function readsAny(ts: typeof TSApi, node: TSApi.Node, names: ReadonlySet<string>): boolean {
210
+ if (ts.isIdentifier(node)) return names.has(node.text)
211
+ if (ts.isPropertyAccessExpression(node)) return readsAny(ts, node.expression, names)
212
+ return ts.forEachChild(node, (child) => readsAny(ts, child, names) || undefined) ?? false
213
+ }
214
+
215
+ const POSITION_CALLS = new Set(["indexOf", "lastIndexOf", "findIndex", "findLastIndex"])
216
+
217
+ /** A `bindList` key that reads a position: a second parameter it reads (`bindList` passes none, so
218
+ * it is always `undefined`) or an `indexOf`-family call handed the item, which shifts on every insert
219
+ * and removal. An `indexOf` over the item's own data, such as `u.email.indexOf("@")`, is not one. */
220
+ function positionalKey(ts: typeof TSApi, call: TSApi.CallExpression): EnhancerFn | undefined {
221
+ const options = call.arguments[2]
222
+ if (options === undefined || !ts.isObjectLiteralExpression(options)) return undefined
223
+ for (const prop of options.properties) {
224
+ if (
225
+ !ts.isPropertyAssignment(prop) ||
226
+ !ts.isIdentifier(prop.name) ||
227
+ prop.name.text !== "key" ||
228
+ !isEnhancerFn(ts, prop.initializer)
229
+ )
230
+ continue
231
+ const key = prop.initializer
232
+ const [item, position] = key.parameters
233
+ if (position !== undefined && readsAny(ts, key.body, boundNames(ts, position.name))) return key
234
+ // A destructured second parameter throws on the `undefined` bindList passes.
235
+ if (position !== undefined && !ts.isIdentifier(position.name)) return key
236
+ if (item === undefined) continue
237
+ const itemNames = boundNames(ts, item.name)
238
+ const handedTheItem = (node: TSApi.Node): true | undefined =>
239
+ (ts.isCallExpression(node) &&
240
+ ts.isPropertyAccessExpression(node.expression) &&
241
+ POSITION_CALLS.has(node.expression.name.text) &&
242
+ node.arguments.some((arg) => readsAny(ts, arg, itemNames))) ||
243
+ ts.forEachChild(node, handedTheItem)
244
+ if (ts.forEachChild(key, handedTheItem)) return key
245
+ }
246
+ return undefined
247
+ }
248
+
249
+ export const islandListKeyRule: CheckRule = {
250
+ code: "NF-C022",
251
+ title: "bindList key check",
252
+ async scan(ctx) {
253
+ const loaded = await loadRuleTypeScript(ctx)
254
+ if (loaded.diagnostics !== undefined) return loaded.diagnostics
255
+ const ts = loaded.compiler
256
+ if (ts === undefined) return [toolchainMissing("NF-C022", "bindList key check")]
257
+ const findings: Diagnostic[] = []
258
+ for (const file of ctx.project.source.files) {
259
+ const tree = parsedTree(ts, ctx.project.source, file)
260
+ if (tree === undefined) continue
261
+ const visit = (node: TSApi.Node): void => {
262
+ if (
263
+ ts.isCallExpression(node) &&
264
+ ts.isIdentifier(node.expression) &&
265
+ node.expression.text === "bindList"
266
+ ) {
267
+ const key = positionalKey(ts, node)
268
+ if (key !== undefined) {
269
+ findings.push(
270
+ diagnostic({
271
+ code: "NF-C022",
272
+ severity: "warn",
273
+ file,
274
+ line: lineOf(tree, key),
275
+ message:
276
+ "bindList key reads the item's position - an insert, removal or reorder hands a node to the wrong item. Key by a stable id on the item instead",
277
+ evidence: ["key: (item, i) => i or key: (item) => list.indexOf(item)"],
278
+ fix: { recipe: "islands.stable-key", command: "nifra_docs islands" },
279
+ verify: "nifra check --lints-only",
280
+ }),
281
+ )
282
+ }
283
+ }
284
+ ts.forEachChild(node, visit)
285
+ }
286
+ visit(tree)
287
+ }
288
+ return findings
289
+ },
290
+ }
291
+
292
+ /** What markup may name inside one island: `undefined` when the setup is not fully literal, so a name
293
+ * cannot be judged and nothing is reported. */
294
+ type IslandNames =
295
+ | {
296
+ readonly kind: "bind"
297
+ readonly state: ReadonlySet<string> | undefined
298
+ readonly handlers: ReadonlySet<string> | undefined
299
+ }
300
+ | { readonly kind: "imperative" }
301
+
302
+ export const UNKNOWN = Symbol("unknown")
303
+
304
+ function literalKeys(
305
+ ts: typeof TSApi,
306
+ node: TSApi.ObjectLiteralExpression,
307
+ ): Set<string> | undefined {
308
+ const keys = new Set<string>()
309
+ for (const prop of node.properties) {
310
+ if (ts.isSpreadAssignment(prop) || prop.name === undefined) return undefined
311
+ if (ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name)) keys.add(prop.name.text)
312
+ else return undefined
313
+ }
314
+ return keys
315
+ }
316
+
317
+ /** Whether `node` names a property (`x.state`, `{ state: 1 }`, `{ state() {} }`) rather than a value. */
318
+ function isPropertyName(ts: typeof TSApi, node: TSApi.Identifier): boolean {
319
+ const parent = node.parent
320
+ return (
321
+ ((ts.isPropertyAccessExpression(parent) ||
322
+ ts.isPropertyAssignment(parent) ||
323
+ ts.isMethodDeclaration(parent) ||
324
+ ts.isGetAccessorDeclaration(parent) ||
325
+ ts.isSetAccessorDeclaration(parent) ||
326
+ ts.isPropertyDeclaration(parent)) &&
327
+ parent.name === node) ||
328
+ (ts.isBindingElement(parent) && parent.propertyName === node)
329
+ )
330
+ }
331
+
332
+ /** The state keys and handler names of a `bindIsland(setup)` whose setup is an inline function. */
333
+ function bindIslandNames(
334
+ ts: typeof TSApi,
335
+ setup: TSApi.Expression | undefined,
336
+ ): IslandNames | typeof UNKNOWN {
337
+ if (setup === undefined || !isEnhancerFn(ts, setup)) return UNKNOWN
338
+ const param = setup.parameters[0]
339
+ let stateName: string | undefined
340
+ let ctxName: string | undefined
341
+ if (param !== undefined) {
342
+ if (ts.isIdentifier(param.name)) ctxName = param.name.text
343
+ else if (ts.isObjectBindingPattern(param.name)) {
344
+ for (const element of param.name.elements) {
345
+ const prop = element.propertyName ?? element.name
346
+ if (ts.isIdentifier(prop) && prop.text === "state" && ts.isIdentifier(element.name))
347
+ stateName = element.name.text
348
+ else if (element.dotDotDotToken !== undefined && ts.isIdentifier(element.name))
349
+ ctxName = element.name.text
350
+ }
351
+ } else return UNKNOWN
352
+ }
353
+ let state: Set<string> | undefined = new Set()
354
+ const ctxProperty = (node: TSApi.Node): node is TSApi.PropertyAccessExpression =>
355
+ ctxName !== undefined &&
356
+ ts.isPropertyAccessExpression(node) &&
357
+ ts.isIdentifier(node.expression) &&
358
+ node.expression.text === ctxName
359
+ // The keys are known only while `state` is called directly: an alias, a destructuring or a helper
360
+ // that receives `state` or the context may declare keys this walk cannot see.
361
+ const walk = (node: TSApi.Node): void => {
362
+ if (state === undefined) return
363
+ if (ts.isCallExpression(node)) {
364
+ const callee = node.expression
365
+ if (
366
+ (ts.isIdentifier(callee) && callee.text === stateName) ||
367
+ (ctxProperty(callee) && callee.name.text === "state")
368
+ ) {
369
+ const key = node.arguments[0]
370
+ if (key !== undefined && ts.isStringLiteralLike(key)) state.add(key.text)
371
+ else state = undefined
372
+ for (const arg of node.arguments) walk(arg)
373
+ return
374
+ }
375
+ }
376
+ // `ctx.root`, `ctx.props` and `ctx.onDispose` reach no state; `ctx.state` read as a value does.
377
+ if (ctxProperty(node)) {
378
+ if (node.name.text === "state") state = undefined
379
+ return
380
+ }
381
+ if (ts.isIdentifier(node)) {
382
+ if ((node.text === stateName || node.text === ctxName) && !isPropertyName(ts, node))
383
+ state = undefined
384
+ return
385
+ }
386
+ ts.forEachChild(node, walk)
387
+ }
388
+ ts.forEachChild(setup.body, walk)
389
+ const returned = (expr: TSApi.Expression | undefined): Set<string> | undefined => {
390
+ if (expr === undefined) return new Set()
391
+ let inner = expr
392
+ while (ts.isParenthesizedExpression(inner)) inner = inner.expression
393
+ if (ts.isObjectLiteralExpression(inner)) return literalKeys(ts, inner)
394
+ if (ts.isIdentifier(inner) && inner.text === "undefined") return new Set()
395
+ if (ts.isVoidExpression(inner)) return new Set()
396
+ return undefined
397
+ }
398
+ let handlers: Set<string> | undefined
399
+ if (!ts.isBlock(setup.body)) handlers = returned(setup.body)
400
+ else {
401
+ handlers = new Set()
402
+ const walkReturns = (node: TSApi.Node): void => {
403
+ if (isEnhancerFn(ts, node) || ts.isFunctionDeclaration(node)) return
404
+ if (ts.isReturnStatement(node)) {
405
+ const keys = returned(node.expression)
406
+ if (keys === undefined) handlers = undefined
407
+ else for (const key of keys) handlers?.add(key)
408
+ }
409
+ ts.forEachChild(node, walkReturns)
410
+ }
411
+ ts.forEachChild(setup.body, walkReturns)
412
+ }
413
+ return { kind: "bind", state, handlers }
414
+ }
415
+
416
+ /** What an enhancer expression mounts: a `bindIsland(...)`, an imperative enhancer, or unknown. */
417
+ function enhancerNames(
418
+ ts: typeof TSApi,
419
+ expr: TSApi.Expression,
420
+ locals: ReadonlyMap<string, TSApi.Expression>,
421
+ ): IslandNames | typeof UNKNOWN {
422
+ let target: TSApi.Expression | undefined = expr
423
+ if (ts.isIdentifier(expr)) target = locals.get(expr.text)
424
+ if (target === undefined) return UNKNOWN
425
+ if (isEnhancerFn(ts, target)) return { kind: "imperative" }
426
+ if (ts.isCallExpression(target) && ts.isIdentifier(target.expression)) {
427
+ if (target.expression.text === "defineIsland") return { kind: "imperative" }
428
+ if (target.expression.text === "bindIsland") return bindIslandNames(ts, target.arguments[0])
429
+ }
430
+ return UNKNOWN
431
+ }
432
+
433
+ /** Every island id mounted in the project, with what its markup may name. An id mounted with
434
+ * different or unresolvable enhancers maps to UNKNOWN. */
435
+ function mountedIslands(
436
+ ts: typeof TSApi,
437
+ trees: ReadonlyArray<TSApi.SourceFile>,
438
+ ): Map<string, IslandNames | typeof UNKNOWN> {
439
+ const ids = new Map<string, IslandNames | typeof UNKNOWN>()
440
+ for (const tree of trees) {
441
+ const locals = new Map<string, TSApi.Expression>()
442
+ const mounts: TSApi.ObjectLiteralExpression[] = []
443
+ const visit = (node: TSApi.Node): void => {
444
+ if (
445
+ ts.isVariableDeclaration(node) &&
446
+ ts.isIdentifier(node.name) &&
447
+ node.initializer !== undefined
448
+ )
449
+ locals.set(node.name.text, node.initializer)
450
+ if (
451
+ ts.isCallExpression(node) &&
452
+ ts.isIdentifier(node.expression) &&
453
+ MOUNT_CALLS.has(node.expression.text)
454
+ ) {
455
+ const map = node.arguments[0]
456
+ if (map !== undefined && ts.isObjectLiteralExpression(map)) mounts.push(map)
457
+ }
458
+ ts.forEachChild(node, visit)
459
+ }
460
+ visit(tree)
461
+ for (const map of mounts) {
462
+ for (const prop of map.properties) {
463
+ let id: string | undefined
464
+ let names: IslandNames | typeof UNKNOWN = UNKNOWN
465
+ if (ts.isShorthandPropertyAssignment(prop)) {
466
+ id = prop.name.text
467
+ names = enhancerNames(ts, prop.name, locals)
468
+ } else if (
469
+ ts.isPropertyAssignment(prop) &&
470
+ (ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name))
471
+ ) {
472
+ id = prop.name.text
473
+ names = enhancerNames(ts, prop.initializer, locals)
474
+ }
475
+ if (id === undefined) continue
476
+ ids.set(id, ids.has(id) ? UNKNOWN : names)
477
+ }
478
+ }
479
+ }
480
+ return ids
481
+ }
482
+
483
+ /** One `data-bind-*` attribute in markup, with the island host it belongs to. */
484
+ interface MarkupBinding {
485
+ readonly attribute: string
486
+ /** Signal names (`handler: false`) or handler names (`handler: true`) the attribute refers to. */
487
+ readonly names: ReadonlyArray<{ readonly name: string; readonly handler: boolean }>
488
+ /** The nearest enclosing host's id: `null` when there is none, UNKNOWN when it is not literal. */
489
+ readonly island: string | null | typeof UNKNOWN
490
+ /** A `data-swap-slot` between the binding and its host, whose swap replaces the bound element. */
491
+ readonly slot: string | null | typeof UNKNOWN
492
+ readonly node: TSApi.Node
493
+ /** The line of its tag, when `node` is the whole template. */
494
+ readonly line?: number
495
+ }
496
+
497
+ /** A `data-swap` link or form, or a `data-swap-slot` element. */
498
+ export interface SwapMarkup {
499
+ readonly kind: "swap" | "slot"
500
+ readonly tag: string
501
+ /** The attribute's value: UNKNOWN when it is not literal. */
502
+ readonly value: string | typeof UNKNOWN
503
+ /** A link's `href` or a form's `action`, interpolations as HOLE: `undefined` when absent, UNKNOWN
504
+ * when a JSX value is not literal. */
505
+ readonly url: string | undefined | typeof UNKNOWN
506
+ /** A slot's content in an `html` template, interpolations as HOLE, with their expressions in
507
+ * order. Absent in JSX and when the element does not close in its template. */
508
+ content?: { readonly text: string; readonly holes: readonly TSApi.Expression[] }
509
+ readonly jsx: boolean
510
+ readonly node: TSApi.Node
511
+ /** The line of its tag, when `node` is the whole template. */
512
+ readonly line?: number
513
+ }
514
+
515
+ /** Where an interpolation of an `html` template sits: inside which slot, and whether it is the
516
+ * slot's whole content. */
517
+ export interface HolePlacement {
518
+ readonly slot: string | null | typeof UNKNOWN
519
+ readonly sole: boolean
520
+ }
521
+
522
+ interface MarkupFacts {
523
+ readonly hasHost: boolean
524
+ readonly bindings: MarkupBinding[]
525
+ readonly swaps: SwapMarkup[]
526
+ }
527
+
528
+ // Where an interpolation sat in a template; an attribute value holding one is not literal.
529
+ export const HOLE = "\u0000"
530
+
531
+ function bindingNames(attribute: string, value: string): MarkupBinding["names"] | undefined {
532
+ if (value.includes(HOLE)) return undefined
533
+ const kind = attribute.slice("data-bind-".length)
534
+ if (kind === "text" || kind === "show" || kind === "value")
535
+ return value.trim() === "" ? [] : [{ name: value.trim(), handler: false }]
536
+ if (kind !== "class" && kind !== "attr" && kind !== "on") return undefined
537
+ const out: Array<{ name: string; handler: boolean }> = []
538
+ for (const part of value.split(",")) {
539
+ const sep = part.indexOf(":")
540
+ if (sep <= 0) continue
541
+ const name = part.slice(sep + 1).trim()
542
+ if (part.slice(0, sep).trim() && name) out.push({ name, handler: kind === "on" })
543
+ }
544
+ return out
545
+ }
546
+
547
+ const VOID_ELEMENTS = new Set([
548
+ "area",
549
+ "base",
550
+ "br",
551
+ "col",
552
+ "embed",
553
+ "hr",
554
+ "img",
555
+ "input",
556
+ "link",
557
+ "meta",
558
+ "source",
559
+ "track",
560
+ "wbr",
561
+ ])
562
+
563
+ /** The attributes of one tag's inside (`name a="1" b`), in order. */
564
+ function tagAttributes(inside: string): Array<[string, string]> {
565
+ const out: Array<[string, string]> = []
566
+ let i = 0
567
+ while (i < inside.length) {
568
+ while (i < inside.length && /[\s/]/.test(inside.charAt(i))) i++
569
+ const start = i
570
+ while (i < inside.length && !/[\s/=>]/.test(inside.charAt(i))) i++
571
+ const name = inside.slice(start, i).toLowerCase()
572
+ if (name === "") break
573
+ while (i < inside.length && /\s/.test(inside.charAt(i))) i++
574
+ let value = ""
575
+ if (inside.charAt(i) === "=") {
576
+ i++
577
+ while (i < inside.length && /\s/.test(inside.charAt(i))) i++
578
+ const quote = inside.charAt(i)
579
+ if (quote === '"' || quote === "'") {
580
+ const end = inside.indexOf(quote, i + 1)
581
+ const stop = end < 0 ? inside.length : end
582
+ value = inside.slice(i + 1, stop)
583
+ i = stop + 1
584
+ } else {
585
+ const begin = i
586
+ while (i < inside.length && !/\s/.test(inside.charAt(i))) i++
587
+ value = inside.slice(begin, i)
588
+ }
589
+ }
590
+ out.push([name, value])
591
+ }
592
+ return out
593
+ }
594
+
595
+ interface OpenElement {
596
+ readonly tag: string
597
+ readonly island: string | null | typeof UNKNOWN
598
+ readonly slot: SwapMarkup | undefined
599
+ /** Where the element's content starts in the template text. */
600
+ readonly start: number
601
+ }
602
+
603
+ /** The island a binding belongs to, and a slot between them, from the elements open around it. */
604
+ function ownerOf(stack: readonly OpenElement[]): Pick<MarkupBinding, "island" | "slot"> {
605
+ let slot: string | null | typeof UNKNOWN = null
606
+ for (let i = stack.length - 1; i >= 0; i--) {
607
+ const entry = stack[i]
608
+ if (entry === undefined) continue
609
+ if (entry.slot !== undefined && slot === null) slot = entry.slot.value
610
+ if (entry.island !== null) return { island: entry.island, slot }
611
+ }
612
+ return { island: null, slot: null }
613
+ }
614
+
615
+ /**
616
+ * The bindings, swap links, forms and slots of an `html` template's text, and whether it holds an
617
+ * island host. `holes` are the template's interpolations, in order; `placement` learns where each
618
+ * one sits. A linear scan: an unclosed tag ends it.
619
+ */
620
+ function templateMarkup(
621
+ text: string,
622
+ holes: readonly TSApi.Expression[],
623
+ node: TSApi.Node,
624
+ placement: Map<TSApi.Node, HolePlacement>,
625
+ lineAt: (offset: number) => number,
626
+ ): MarkupFacts {
627
+ const stack: OpenElement[] = []
628
+ const bindings: MarkupBinding[] = []
629
+ const swaps: SwapMarkup[] = []
630
+ const positions: number[] = []
631
+ for (let i = text.indexOf(HOLE); i >= 0; i = text.indexOf(HOLE, i + 1)) positions.push(i)
632
+ const holesIn = (from: number, to: number): TSApi.Expression[] => {
633
+ const out: TSApi.Expression[] = []
634
+ positions.forEach((position, i) => {
635
+ const hole = holes[i]
636
+ if (position >= from && position < to && hole !== undefined) out.push(hole)
637
+ })
638
+ return out
639
+ }
640
+ // Innermost first, so each interpolation is placed in the element nearest to it.
641
+ const close = (from: number, at: number): void => {
642
+ for (let i = stack.length - 1; i >= from; i--) {
643
+ const entry = stack[i]
644
+ if (entry === undefined) continue
645
+ const inside = holesIn(entry.start, at)
646
+ const sole = entry.slot !== undefined && text.slice(entry.start, at).trim() === HOLE
647
+ for (const hole of inside)
648
+ if (!placement.has(hole)) placement.set(hole, { slot: entry.slot?.value ?? null, sole })
649
+ if (entry.slot !== undefined)
650
+ entry.slot.content = { text: text.slice(entry.start, at), holes: inside }
651
+ }
652
+ stack.length = from
653
+ }
654
+ let hasHost = false
655
+ let at = text.indexOf("<")
656
+ while (at >= 0) {
657
+ let end = at + 1
658
+ let quote = ""
659
+ while (end < text.length) {
660
+ const c = text.charAt(end)
661
+ if (quote !== "") {
662
+ if (c === quote) quote = ""
663
+ } else if (c === '"' || c === "'") quote = c
664
+ else if (c === ">") break
665
+ end++
666
+ }
667
+ if (end >= text.length) break
668
+ const inside = text.slice(at + 1, end)
669
+ // An interpolation in a tag is an attribute value, never content.
670
+ for (const hole of holesIn(at, end)) placement.set(hole, { slot: null, sole: false })
671
+ const tagAt = at
672
+ at = text.indexOf("<", end + 1)
673
+ if (inside.startsWith("/")) {
674
+ const tag = inside.slice(1).trim().toLowerCase()
675
+ const open = stack.map((entry) => entry.tag).lastIndexOf(tag)
676
+ if (open >= 0) close(open, tagAt)
677
+ continue
678
+ }
679
+ const tag = /^[a-zA-Z][\w-]*/.exec(inside)?.[0]?.toLowerCase()
680
+ if (tag === undefined) continue
681
+ const attributes = tagAttributes(inside.slice(tag.length))
682
+ const attribute = (name: string): string | undefined =>
683
+ attributes.find(([key]) => key === name)?.[1]
684
+ const literal = (value: string): string | typeof UNKNOWN =>
685
+ value.includes(HOLE) ? UNKNOWN : value
686
+ const hostId = attribute("data-island")
687
+ const island = hostId === undefined ? null : literal(hostId)
688
+ if (island !== null) hasHost = true
689
+ const owner = ownerOf(stack)
690
+ const line = lineAt(tagAt)
691
+ for (const [name, value] of attributes) {
692
+ if (!name.startsWith("data-bind-")) continue
693
+ const names = bindingNames(name, value)
694
+ if (names !== undefined) bindings.push({ attribute: name, names, ...owner, node, line })
695
+ }
696
+ const swap = attribute("data-swap")
697
+ const url = tag === "a" ? attribute("href") : tag === "form" ? attribute("action") : undefined
698
+ if (swap !== undefined)
699
+ swaps.push({ kind: "swap", tag, value: literal(swap), url, jsx: false, node, line })
700
+ const slotName = attribute("data-swap-slot")
701
+ const slot: SwapMarkup | undefined =
702
+ slotName === undefined
703
+ ? undefined
704
+ : { kind: "slot", tag, value: literal(slotName), url: undefined, jsx: false, node, line }
705
+ if (slot !== undefined) swaps.push(slot)
706
+ if (!VOID_ELEMENTS.has(tag) && !inside.trimEnd().endsWith("/"))
707
+ stack.push({ tag, island, slot, start: end + 1 })
708
+ }
709
+ return { hasHost, bindings, swaps }
710
+ }
711
+
712
+ /** The source line of an offset in a template's text: its newlines, and the lines each
713
+ * interpolation spans in the source. */
714
+ function templateLines(
715
+ tree: TSApi.SourceFile,
716
+ template: TSApi.TemplateLiteral,
717
+ text: string,
718
+ spans: readonly TSApi.TemplateSpan[],
719
+ ): (offset: number) => number {
720
+ const lineOfPosition = (position: number): number =>
721
+ tree.getLineAndCharacterOfPosition(position).line + 1
722
+ const first = lineOfPosition(template.getStart(tree))
723
+ return (offset) => {
724
+ let line = first
725
+ let hole = 0
726
+ for (let i = 0; i < offset && i < text.length; i++) {
727
+ const c = text.charAt(i)
728
+ if (c === "\n") line++
729
+ else if (c === HOLE) {
730
+ const span = spans[hole++]
731
+ if (span !== undefined)
732
+ line +=
733
+ lineOfPosition(span.literal.getStart(tree)) -
734
+ lineOfPosition(span.expression.getStart(tree))
735
+ }
736
+ }
737
+ return line
738
+ }
739
+ }
740
+
741
+ /** The text of an `html\`...\`` template, each interpolation replaced by HOLE. */
742
+ function templateText(ts: typeof TSApi, template: TSApi.TemplateLiteral): string {
743
+ if (ts.isNoSubstitutionTemplateLiteral(template)) return template.text
744
+ let text = template.head.text
745
+ for (const span of template.templateSpans) text += HOLE + span.literal.text
746
+ return text
747
+ }
748
+
749
+ /** The literal string value of a JSX attribute, `undefined` when absent, UNKNOWN when not literal. */
750
+ function jsxAttribute(
751
+ ts: typeof TSApi,
752
+ element: TSApi.JsxOpeningLikeElement,
753
+ name: string,
754
+ ): string | undefined | typeof UNKNOWN {
755
+ for (const attr of element.attributes.properties) {
756
+ if (ts.isJsxSpreadAttribute(attr)) continue
757
+ if (attr.name.getText() !== name) continue
758
+ const init = attr.initializer
759
+ if (init === undefined) return ""
760
+ if (ts.isStringLiteral(init)) return init.text
761
+ if (
762
+ ts.isJsxExpression(init) &&
763
+ init.expression !== undefined &&
764
+ ts.isStringLiteralLike(init.expression)
765
+ )
766
+ return init.expression.text
767
+ return UNKNOWN
768
+ }
769
+ return undefined
770
+ }
771
+
772
+ /** The bindings, swap links, forms and slots of one outermost JSX tree, and whether it holds an
773
+ * island host. */
774
+ function jsxMarkup(
775
+ ts: typeof TSApi,
776
+ root: TSApi.JsxElement | TSApi.JsxSelfClosingElement | TSApi.JsxFragment,
777
+ ): MarkupFacts {
778
+ const bindings: MarkupBinding[] = []
779
+ const swaps: SwapMarkup[] = []
780
+ let hasHost = false
781
+ const walk = (node: TSApi.Node, owner: Pick<MarkupBinding, "island" | "slot">): void => {
782
+ let opening: TSApi.JsxOpeningLikeElement | undefined
783
+ if (ts.isJsxElement(node)) opening = node.openingElement
784
+ else if (ts.isJsxSelfClosingElement(node)) opening = node
785
+ let inner = owner
786
+ if (opening !== undefined) {
787
+ const tag = opening.tagName.getText()
788
+ const host =
789
+ tag === "Island"
790
+ ? jsxAttribute(ts, opening, "id")
791
+ : jsxAttribute(ts, opening, "data-island")
792
+ if (host !== undefined) {
793
+ hasHost = true
794
+ inner = { island: host, slot: null }
795
+ }
796
+ for (const attr of opening.attributes.properties) {
797
+ if (ts.isJsxSpreadAttribute(attr)) continue
798
+ const name = attr.name.getText()
799
+ if (!name.startsWith("data-bind-")) continue
800
+ const value = jsxAttribute(ts, opening, name)
801
+ if (value === UNKNOWN || value === undefined) continue
802
+ const names = bindingNames(name, value)
803
+ if (names !== undefined) bindings.push({ attribute: name, names, ...owner, node: attr })
804
+ }
805
+ const swap = jsxAttribute(ts, opening, "data-swap")
806
+ if (swap !== undefined) {
807
+ const url =
808
+ tag === "a"
809
+ ? jsxAttribute(ts, opening, "href")
810
+ : tag === "form"
811
+ ? jsxAttribute(ts, opening, "action")
812
+ : undefined
813
+ swaps.push({ kind: "swap", tag, value: swap, url, jsx: true, node: opening })
814
+ }
815
+ const slot = jsxAttribute(ts, opening, "data-swap-slot")
816
+ if (slot !== undefined) {
817
+ swaps.push({ kind: "slot", tag, value: slot, url: undefined, jsx: true, node: opening })
818
+ inner = { island: inner.island, slot }
819
+ }
820
+ }
821
+ ts.forEachChild(node, (child) => walk(child, inner))
822
+ }
823
+ walk(root, { island: null, slot: null })
824
+ return { hasHost, bindings, swaps }
825
+ }
826
+
827
+ /** The `slot` names a file imports from `@nifrajs/web-vanilla`. */
828
+ function slotImports(ts: typeof TSApi, tree: TSApi.SourceFile): Set<string> {
829
+ const names = new Set<string>()
830
+ for (const statement of tree.statements) {
831
+ if (
832
+ !ts.isImportDeclaration(statement) ||
833
+ !ts.isStringLiteral(statement.moduleSpecifier) ||
834
+ statement.moduleSpecifier.text !== "@nifrajs/web-vanilla"
835
+ )
836
+ continue
837
+ const bound = statement.importClause?.namedBindings
838
+ if (bound === undefined || !ts.isNamedImports(bound)) continue
839
+ for (const element of bound.elements)
840
+ if ((element.propertyName ?? element.name).text === "slot") names.add(element.name.text)
841
+ }
842
+ return names
843
+ }
844
+
845
+ /** One `slot(name, content)` call of `@nifrajs/web-vanilla`. */
846
+ export interface SlotCall {
847
+ readonly name: string | typeof UNKNOWN
848
+ readonly node: TSApi.CallExpression
849
+ }
850
+
851
+ /** The markup of one file: every tree's bindings (those with a host), swap uses and slot calls. */
852
+ function fileMarkup(
853
+ ts: typeof TSApi,
854
+ tree: TSApi.SourceFile,
855
+ ): {
856
+ readonly bindings: MarkupBinding[]
857
+ readonly swaps: SwapMarkup[]
858
+ readonly slotCalls: SlotCall[]
859
+ readonly placement: Map<TSApi.Node, HolePlacement>
860
+ } {
861
+ const bindings: MarkupBinding[] = []
862
+ const swaps: SwapMarkup[] = []
863
+ const slotCalls: SlotCall[] = []
864
+ const placement = new Map<TSApi.Node, HolePlacement>()
865
+ const slotNames = slotImports(ts, tree)
866
+ const take = (found: MarkupFacts): void => {
867
+ // A fragment with no host of its own may render inside one elsewhere, so it is not judged.
868
+ if (found.hasHost) bindings.push(...found.bindings)
869
+ swaps.push(...found.swaps)
870
+ }
871
+ const visit = (node: TSApi.Node): void => {
872
+ if (
873
+ ts.isTaggedTemplateExpression(node) &&
874
+ ts.isIdentifier(node.tag) &&
875
+ node.tag.text === "html"
876
+ ) {
877
+ const spans = ts.isTemplateExpression(node.template) ? node.template.templateSpans : []
878
+ const text = templateText(ts, node.template)
879
+ const holes = spans.map((span) => span.expression)
880
+ const lineAt = templateLines(tree, node.template, text, spans)
881
+ take(templateMarkup(text, holes, node, placement, lineAt))
882
+ } else if (
883
+ ts.isJsxElement(node) ||
884
+ ts.isJsxSelfClosingElement(node) ||
885
+ ts.isJsxFragment(node)
886
+ ) {
887
+ take(jsxMarkup(ts, node))
888
+ return
889
+ } else if (
890
+ ts.isCallExpression(node) &&
891
+ ts.isIdentifier(node.expression) &&
892
+ slotNames.has(node.expression.text)
893
+ ) {
894
+ const first = node.arguments[0]
895
+ slotCalls.push({
896
+ name: first !== undefined && ts.isStringLiteralLike(first) ? first.text : UNKNOWN,
897
+ node,
898
+ })
899
+ }
900
+ ts.forEachChild(node, visit)
901
+ }
902
+ visit(tree)
903
+ return { bindings, swaps, slotCalls, placement }
904
+ }
905
+
906
+ interface MarkupFinding {
907
+ readonly file: string
908
+ readonly line: number
909
+ readonly binding: MarkupBinding
910
+ readonly islands: Map<string, IslandNames | typeof UNKNOWN>
911
+ }
912
+
913
+ /** A file's markup facts, for the swap rules. */
914
+ export interface FileMarkup {
915
+ readonly file: string
916
+ readonly tree: TSApi.SourceFile
917
+ readonly swaps: readonly SwapMarkup[]
918
+ readonly slotCalls: readonly SlotCall[]
919
+ readonly placement: ReadonlyMap<TSApi.Node, HolePlacement>
920
+ }
921
+
922
+ export interface ProjectMarkup {
923
+ readonly bindings: readonly MarkupFinding[]
924
+ readonly files: readonly FileMarkup[]
925
+ }
926
+
927
+ // NF-C047, NF-C048 and the swap rules judge the same markup, so one walk of the project serves all.
928
+ const markupCache = new WeakMap<SourceIndex, ProjectMarkup>()
929
+
930
+ /** Markup across the project: each binding with the island map it is judged against, and each
931
+ * file's swap facts. */
932
+ export async function projectMarkup(
933
+ ctx: Parameters<CheckRule["scan"]>[0],
934
+ code: string,
935
+ title: string,
936
+ ): Promise<{
937
+ readonly diagnostics?: readonly Diagnostic[]
938
+ readonly ts?: typeof TSApi
939
+ readonly markup: ProjectMarkup
940
+ }> {
941
+ const empty: ProjectMarkup = { bindings: [], files: [] }
942
+ const loaded = await loadRuleTypeScript(ctx)
943
+ if (loaded.diagnostics !== undefined) return { diagnostics: loaded.diagnostics, markup: empty }
944
+ const ts = loaded.compiler
945
+ if (ts === undefined) return { diagnostics: [toolchainMissing(code, title)], markup: empty }
946
+ const cached = markupCache.get(ctx.project.source)
947
+ if (cached !== undefined) return { ts, markup: cached }
948
+ const trees: Array<{ readonly file: string; readonly tree: TSApi.SourceFile }> = []
949
+ for (const file of ctx.project.source.files) {
950
+ const tree = parsedTree(ts, ctx.project.source, file)
951
+ if (tree !== undefined) trees.push({ file, tree })
952
+ }
953
+ const islands = mountedIslands(
954
+ ts,
955
+ trees.map((entry) => entry.tree),
956
+ )
957
+ const bindings: MarkupFinding[] = []
958
+ const files: FileMarkup[] = []
959
+ for (const { file, tree } of trees) {
960
+ const found = fileMarkup(ts, tree)
961
+ for (const binding of found.bindings)
962
+ bindings.push({ file, line: binding.line ?? lineOf(tree, binding.node), binding, islands })
963
+ files.push({ file, tree, ...found })
964
+ }
965
+ const markup = { bindings, files }
966
+ markupCache.set(ctx.project.source, markup)
967
+ return { ts, markup }
968
+ }
969
+
970
+ export const islandBindingNameRule: CheckRule = {
971
+ code: "NF-C047",
972
+ title: "Island binding name check",
973
+ async scan(ctx) {
974
+ const { diagnostics, markup } = await projectMarkup(ctx, "NF-C047", "Island binding name check")
975
+ if (diagnostics !== undefined) return diagnostics
976
+ const findings: Diagnostic[] = []
977
+ for (const { file, line, binding, islands } of markup.bindings) {
978
+ if (typeof binding.island !== "string") continue
979
+ const names = islands.get(binding.island)
980
+ if (names === undefined || names === UNKNOWN || names.kind !== "bind") continue
981
+ for (const { name, handler } of binding.names) {
982
+ const known = handler ? names.handlers : names.state
983
+ if (known === undefined || known.has(name)) continue
984
+ findings.push(
985
+ diagnostic({
986
+ code: "NF-C047",
987
+ severity: "warn",
988
+ file,
989
+ line,
990
+ message: handler
991
+ ? `${binding.attribute} names handler "${name}", which the bindIsland setup mounted as "${binding.island}" does not return - the listener is never added`
992
+ : `${binding.attribute} names "${name}", which the bindIsland setup mounted as "${binding.island}" never declares with state("${name}", ...) - the binding is skipped`,
993
+ evidence: [`${binding.attribute} -> ${name}`],
994
+ fix: { recipe: "islands.binding-names", command: "nifra_docs islands" },
995
+ verify: "nifra check --lints-only",
996
+ }),
997
+ )
998
+ }
999
+ }
1000
+ return findings
1001
+ },
1002
+ }
1003
+
1004
+ export const islandBindingHostRule: CheckRule = {
1005
+ code: "NF-C048",
1006
+ title: "Island binding outside a bindIsland host",
1007
+ async scan(ctx) {
1008
+ const { diagnostics, markup } = await projectMarkup(
1009
+ ctx,
1010
+ "NF-C048",
1011
+ "Island binding outside a bindIsland host",
1012
+ )
1013
+ if (diagnostics !== undefined) return diagnostics
1014
+ const findings: Diagnostic[] = []
1015
+ for (const { file, line, binding, islands } of markup.bindings) {
1016
+ let message: string | undefined
1017
+ if (binding.island === null)
1018
+ message = `${binding.attribute} never binds: it sits outside every data-island host. Move it inside a host mounted with bindIsland`
1019
+ else if (typeof binding.island === "string") {
1020
+ const names = islands.get(binding.island)
1021
+ if (names !== undefined && names !== UNKNOWN && names.kind === "imperative")
1022
+ message = `${binding.attribute} never binds: island "${binding.island}" is mounted with an imperative enhancer, which runs no bindings. Move it inside a host mounted with bindIsland`
1023
+ }
1024
+ if (message === undefined && binding.island !== null && binding.slot !== null) {
1025
+ const slot = typeof binding.slot === "string" ? `"${binding.slot}"` : "around it"
1026
+ message = `${binding.attribute} sits in data-swap-slot ${slot} but belongs to an island outside it: a swap replaces its element and the binding stops. Bind it from an island inside the slot`
1027
+ }
1028
+ if (message === undefined) continue
1029
+ findings.push(
1030
+ diagnostic({
1031
+ code: "NF-C048",
1032
+ severity: "warn",
1033
+ file,
1034
+ line,
1035
+ message,
1036
+ evidence: [binding.attribute],
1037
+ fix: { recipe: "islands.binding-host", command: "nifra_docs islands" },
1038
+ verify: "nifra check --lints-only",
1039
+ }),
1040
+ )
1041
+ }
1042
+ return findings
1043
+ },
1044
+ }
1045
+
1046
+ export const islandRules = Object.freeze([
1047
+ islandCleanupRule,
1048
+ islandListKeyRule,
1049
+ islandBindingNameRule,
1050
+ islandBindingHostRule,
1051
+ ])