@starci/eslint-canon-be 3.8.20 → 3.9.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 (164) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/runtime/bundle.json +192 -0
  4. package/runtime/engine/by-code-unit.mjs +6 -6
  5. package/runtime/engine/model-config.mjs +98 -76
  6. package/runtime/engine/orca-config.mjs +22 -17
  7. package/runtime/engine/release-config.mjs +22 -18
  8. package/runtime/engine/removed-vocabulary.mjs +21 -20
  9. package/runtime/engine/resources-config.mjs +42 -35
  10. package/runtime/engine/runtime-root.mjs +11 -13
  11. package/runtime/engine/secrets.mjs +170 -102
  12. package/runtime/engine/sonar-config.mjs +16 -13
  13. package/runtime/engine/temp-root.mjs +3 -9
  14. package/runtime/knowledge/hfs/canon-pins.yaml +10 -10
  15. package/runtime/knowledge/hfs/rules.yaml +6 -6
  16. package/runtime/knowledge/hfs/slots.yaml +2 -2
  17. package/runtime/knowledge/sonar-gate.yaml +1 -1
  18. package/runtime/packages/hfs/templates/app/package-scripts/package.json +1 -1
  19. package/runtime/scripts/api/git/cat-file.mjs +0 -1
  20. package/runtime/scripts/api/git/config-get.mjs +1 -2
  21. package/runtime/scripts/api/git/diff.mjs +0 -1
  22. package/runtime/scripts/api/git/lib.mjs +32 -32
  23. package/runtime/scripts/api/git/ls-files.mjs +0 -1
  24. package/runtime/scripts/api/git/ls-tree.mjs +0 -1
  25. package/runtime/scripts/api/git/merge-base.mjs +2 -3
  26. package/runtime/scripts/api/git/remote.mjs +0 -1
  27. package/runtime/scripts/api/git/rev-parse-query.mjs +0 -1
  28. package/runtime/scripts/api/git/show.mjs +0 -1
  29. package/runtime/scripts/hfs/allows.mjs +37 -38
  30. package/runtime/scripts/hfs/architecture/ast-walks.mjs +180 -163
  31. package/runtime/scripts/hfs/architecture/automatic-gates.mjs +80 -73
  32. package/runtime/scripts/hfs/architecture/backend-app-files.mjs +88 -77
  33. package/runtime/scripts/hfs/architecture/backend.mjs +378 -357
  34. package/runtime/scripts/hfs/architecture/background-unowned.mjs +201 -187
  35. package/runtime/scripts/hfs/architecture/canon-clones.mjs +260 -209
  36. package/runtime/scripts/hfs/architecture/canon-jsx-clones.mjs +149 -116
  37. package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +72 -68
  38. package/runtime/scripts/hfs/architecture/clones.mjs +212 -217
  39. package/runtime/scripts/hfs/architecture/config-unread.mjs +7 -9
  40. package/runtime/scripts/hfs/architecture/config.mjs +302 -268
  41. package/runtime/scripts/hfs/architecture/connection-map.mjs +258 -225
  42. package/runtime/scripts/hfs/architecture/constructor-deps.mjs +80 -71
  43. package/runtime/scripts/hfs/architecture/context-coupling.mjs +82 -77
  44. package/runtime/scripts/hfs/architecture/context-map.mjs +267 -234
  45. package/runtime/scripts/hfs/architecture/context-owner.mjs +73 -61
  46. package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +47 -43
  47. package/runtime/scripts/hfs/architecture/context-transaction.mjs +54 -52
  48. package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +113 -104
  49. package/runtime/scripts/hfs/architecture/contracts-readonly.mjs +288 -270
  50. package/runtime/scripts/hfs/architecture/contracts.mjs +408 -393
  51. package/runtime/scripts/hfs/architecture/cross-app-duplicate.mjs +50 -51
  52. package/runtime/scripts/hfs/architecture/dead-exports-bindings.mjs +143 -119
  53. package/runtime/scripts/hfs/architecture/dead-exports.mjs +286 -228
  54. package/runtime/scripts/hfs/architecture/default-deny.mjs +129 -110
  55. package/runtime/scripts/hfs/architecture/doc-language.mjs +24 -19
  56. package/runtime/scripts/hfs/architecture/entity-registry.mjs +20 -22
  57. package/runtime/scripts/hfs/architecture/entrypoint.mjs +47 -45
  58. package/runtime/scripts/hfs/architecture/error-codes.mjs +37 -35
  59. package/runtime/scripts/hfs/architecture/error-masked.mjs +55 -59
  60. package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +24 -23
  61. package/runtime/scripts/hfs/architecture/feature-shape.mjs +40 -38
  62. package/runtime/scripts/hfs/architecture/framework-pinned.mjs +21 -21
  63. package/runtime/scripts/hfs/architecture/frontend-block-render.mjs +106 -98
  64. package/runtime/scripts/hfs/architecture/frontend-grammar.mjs +153 -150
  65. package/runtime/scripts/hfs/architecture/frontend-routing.mjs +161 -149
  66. package/runtime/scripts/hfs/architecture/frontend-world-render.mjs +343 -305
  67. package/runtime/scripts/hfs/architecture/frontend-world.mjs +340 -294
  68. package/runtime/scripts/hfs/architecture/frontend.mjs +174 -184
  69. package/runtime/scripts/hfs/architecture/function-spec-providers.mjs +124 -106
  70. package/runtime/scripts/hfs/architecture/hfs-graph.mjs +52 -48
  71. package/runtime/scripts/hfs/architecture/hooks-are-hooks.mjs +81 -71
  72. package/runtime/scripts/hfs/architecture/i18n-keys.mjs +155 -141
  73. package/runtime/scripts/hfs/architecture/identity.mjs +141 -125
  74. package/runtime/scripts/hfs/architecture/index.mjs +272 -272
  75. package/runtime/scripts/hfs/architecture/injection-token-exported.mjs +45 -43
  76. package/runtime/scripts/hfs/architecture/jwt-ast.mjs +195 -176
  77. package/runtime/scripts/hfs/architecture/machine-ast.mjs +163 -155
  78. package/runtime/scripts/hfs/architecture/managed-scripts.mjs +19 -20
  79. package/runtime/scripts/hfs/architecture/module-per-transport.mjs +177 -172
  80. package/runtime/scripts/hfs/architecture/next-data-contract.mjs +100 -78
  81. package/runtime/scripts/hfs/architecture/next-data-inference.mjs +170 -154
  82. package/runtime/scripts/hfs/architecture/next-data-key.mjs +311 -275
  83. package/runtime/scripts/hfs/architecture/next-data-symbols.mjs +17 -17
  84. package/runtime/scripts/hfs/architecture/next-data.mjs +351 -334
  85. package/runtime/scripts/hfs/architecture/operation-contract-roots.mjs +39 -37
  86. package/runtime/scripts/hfs/architecture/owners.mjs +97 -98
  87. package/runtime/scripts/hfs/architecture/package-shape.mjs +56 -55
  88. package/runtime/scripts/hfs/architecture/presentation.mjs +138 -130
  89. package/runtime/scripts/hfs/architecture/reachability.mjs +258 -241
  90. package/runtime/scripts/hfs/architecture/register-once.mjs +152 -139
  91. package/runtime/scripts/hfs/architecture/registration.mjs +301 -267
  92. package/runtime/scripts/hfs/architecture/required-files.mjs +172 -167
  93. package/runtime/scripts/hfs/architecture/route-files-thin.mjs +85 -77
  94. package/runtime/scripts/hfs/architecture/schema-owner.mjs +206 -181
  95. package/runtime/scripts/hfs/architecture/server-action.mjs +48 -48
  96. package/runtime/scripts/hfs/architecture/side-boundary.mjs +2 -5
  97. package/runtime/scripts/hfs/architecture/source-names-shape.mjs +261 -259
  98. package/runtime/scripts/hfs/architecture/source-names.mjs +304 -278
  99. package/runtime/scripts/hfs/architecture/sql-keys.mjs +277 -194
  100. package/runtime/scripts/hfs/architecture/sql-owner.mjs +236 -194
  101. package/runtime/scripts/hfs/architecture/sql-returning.mjs +46 -45
  102. package/runtime/scripts/hfs/architecture/sql-token-forms.mjs +86 -74
  103. package/runtime/scripts/hfs/architecture/sql-tokens.mjs +456 -341
  104. package/runtime/scripts/hfs/architecture/staged-consumers.mjs +35 -30
  105. package/runtime/scripts/hfs/architecture/surface.mjs +64 -74
  106. package/runtime/scripts/hfs/architecture/symbols.mjs +209 -216
  107. package/runtime/scripts/hfs/architecture/test-world-files.mjs +165 -155
  108. package/runtime/scripts/hfs/architecture/tiers.mjs +161 -154
  109. package/runtime/scripts/hfs/architecture/transport-owner.mjs +155 -149
  110. package/runtime/scripts/hfs/architecture/type-context.mjs +255 -250
  111. package/runtime/scripts/hfs/architecture/typescript.mjs +358 -318
  112. package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +110 -92
  113. package/runtime/scripts/hfs/declaration-shape.mjs +140 -103
  114. package/runtime/scripts/hfs/declaration-slots.mjs +64 -61
  115. package/runtime/scripts/hfs/edition-slots.mjs +43 -40
  116. package/runtime/scripts/hfs/linear-text.mjs +20 -20
  117. package/runtime/scripts/hfs/param-names.mjs +6 -11
  118. package/runtime/scripts/hfs/path-findings.mjs +120 -100
  119. package/runtime/scripts/hfs/repo-identity.mjs +55 -42
  120. package/runtime/scripts/hfs/rule-catalog.mjs +353 -257
  121. package/runtime/scripts/hfs/rule-params-shape.mjs +60 -47
  122. package/runtime/scripts/hfs/rules/database-migrations.mjs +428 -388
  123. package/runtime/scripts/hfs/rules/fe-no-tests.mjs +37 -36
  124. package/runtime/scripts/hfs/rules/read.mjs +19 -15
  125. package/runtime/scripts/hfs/rules/secrets.mjs +1 -1
  126. package/runtime/scripts/hfs/rules/spec-placement.mjs +12 -13
  127. package/runtime/scripts/hfs/slot-app-view.mjs +69 -74
  128. package/runtime/scripts/hfs/slot-classify.mjs +42 -38
  129. package/runtime/scripts/hfs/slot-errors.mjs +8 -7
  130. package/runtime/scripts/hfs/slot-imports.mjs +70 -63
  131. package/runtime/scripts/hfs/slot-manifest-shape.mjs +74 -52
  132. package/runtime/scripts/hfs/slot-match.mjs +122 -111
  133. package/runtime/scripts/hfs/slot-path.mjs +0 -2
  134. package/runtime/scripts/hfs/slot-required.mjs +65 -59
  135. package/runtime/scripts/hfs/slot-semantic-problems.mjs +138 -112
  136. package/runtime/scripts/hfs/slot-side-problems.mjs +23 -19
  137. package/runtime/scripts/hfs/slots.mjs +175 -152
  138. package/runtime/scripts/hfs/test-world-slot.mjs +0 -1
  139. package/runtime/scripts/hfs/trailing-slashes.mjs +4 -4
  140. package/runtime/scripts/hfs/typescript-programs.mjs +66 -69
  141. package/runtime/scripts/hfs/view.mjs +38 -40
  142. package/runtime/scripts/lib/dockerfile.mjs +131 -114
  143. package/runtime/scripts/lib/env.mjs +3 -6
  144. package/runtime/scripts/lib/event-contract.mjs +73 -78
  145. package/runtime/scripts/lib/git.mjs +15 -16
  146. package/runtime/scripts/lib/glob.mjs +23 -14
  147. package/runtime/scripts/lib/grammar-lint.mjs +33 -37
  148. package/runtime/scripts/lib/i18n.mjs +32 -35
  149. package/runtime/scripts/lib/in-order.mjs +57 -38
  150. package/runtime/scripts/lib/json-clone.mjs +45 -36
  151. package/runtime/scripts/lib/json.mjs +26 -14
  152. package/runtime/scripts/lib/language.mjs +133 -129
  153. package/runtime/scripts/lib/list.mjs +9 -14
  154. package/runtime/scripts/lib/mutation-fence.mjs +10 -5
  155. package/runtime/scripts/lib/path-key.mjs +53 -38
  156. package/runtime/scripts/lib/read-text.mjs +30 -17
  157. package/runtime/scripts/lib/regex.mjs +1 -2
  158. package/runtime/scripts/lib/same-text.mjs +0 -1
  159. package/runtime/scripts/lib/sops-envelope.mjs +148 -120
  160. package/runtime/scripts/lib/stack-services.mjs +128 -129
  161. package/runtime/scripts/lib/ts-analysis.mjs +28 -26
  162. package/runtime/scripts/lib/ts-ast.mjs +36 -42
  163. package/runtime/scripts/lib/walk.mjs +33 -27
  164. package/runtime/scripts/lib/yaml-cached.mjs +4 -4
@@ -3,163 +3,171 @@ import path from 'node:path';
3
3
  import { repositoryName } from '../repo-identity.mjs';
4
4
  import { managedScriptNames } from './managed-scripts.mjs';
5
5
  import { trimTrailingChars } from '../linear-text.mjs';
6
-
7
6
  const RUNTIME_ROOT_MARKDOWN = new Set(['README.md', 'CONTEXT.md', 'CONTRIBUTING.md', 'CHANGELOG.md', 'THIRD_PARTY_NOTICES.md']);
8
7
  const PRODUCT_ROOT_MARKDOWN = new Set(['README.md']);
9
8
  const README_SECTIONS = ['Overview', 'Stack', 'Repository layout', 'Development'];
10
9
  const DEVELOPMENT_SCRIPTS = ['typecheck', 'lint', 'build', 'test'];
11
- const README_HEADING = new RegExp(['^## ', '(.+?)', String.raw`\s*$`].join(''), 'u');
12
- const README_URL = new RegExp(['https?:', String.raw`\/\/`, String.raw`[^\s<>)"']+`].join(''), 'giu');
13
-
10
+ const README_HEADING = new RegExp(['^## ', '(.+?)', String.raw `\s*$`].join(''), 'u');
11
+ const README_URL = new RegExp(['https?:', String.raw `\/\/`, String.raw `[^\s<>)"']+`].join(''), 'giu');
14
12
  function privateHost(hostname) {
15
- const host = hostname.toLowerCase().replace(/^\[|\]$/g, '').replace(/\.$/, '');
16
- if (host === 'localhost' || host === '::1' || host === '0.0.0.0' ||
17
- /(?:\.localhost|\.local|\.internal|\.lan)$/u.test(host)) return true;
18
- if (host.includes(':')) return /^(?:::|f[cd][0-9a-f]*:|fe[89ab][0-9a-f]*:)/iu.test(host);
19
- if (!host.includes('.')) return true;
20
- const octets = host.split('.');
21
- if (octets.length !== 4 || !octets.every(part => /^\d{1,3}$/u.test(part) && Number(part) <= 255)) return false;
22
- const [a, b] = octets.map(Number);
23
- return a === 0 || a === 10 || a === 127 || a === 169 && b === 254 ||
24
- a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 100 && b >= 64 && b <= 127;
25
- }
26
-
13
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, '').replace(/\.$/, '');
14
+ if (host === 'localhost' || host === '::1' || host === '0.0.0.0' ||
15
+ /(?:\.localhost|\.local|\.internal|\.lan)$/u.test(host))
16
+ return true;
17
+ if (host.includes(':'))
18
+ return /^(?:::|f[cd][0-9a-f]*:|fe[89ab][0-9a-f]*:)/iu.test(host);
19
+ if (!host.includes('.'))
20
+ return true;
21
+ const octets = host.split('.');
22
+ if (octets.length !== 4 || !octets.every(part => /^\d{1,3}$/u.test(part) && Number(part) <= 255))
23
+ return false;
24
+ const [a = Number.NaN, b = Number.NaN] = octets.map(Number);
25
+ return a === 0 || a === 10 || a === 127 || a === 169 && b === 254 ||
26
+ a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 100 && b >= 64 && b <= 127;
27
+ }
27
28
  function scriptCommand(name) {
28
- const escaped = name.replace(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`);
29
- return new RegExp(name === 'test' ? String.raw`npm (?:run test|test)(?![\w:-])` : String.raw`npm run ${escaped}(?![\w:-])`, 'u');
29
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/gu, String.raw `\$&`);
30
+ return new RegExp(name === 'test' ? String.raw `npm (?:run test|test)(?![\w:-])` : String.raw `npm run ${escaped}(?![\w:-])`, 'u');
30
31
  }
31
-
32
32
  function addFinding(state, ruleId, entry, message, line = 1) {
33
- state.violations.push({ ruleId, path: entry, line, column: 1, message });
33
+ state.violations.push({ ruleId, path: entry, line, column: 1, message });
34
34
  }
35
-
36
35
  function checkRootPackageManager(state) {
37
- try {
38
- const pkg = JSON.parse(fs.readFileSync(path.join(state.root, 'package.json'), 'utf8'));
39
- if (pkg.packageManager && !/^npm@\d/u.test(pkg.packageManager))
40
- addFinding(state, 'HFS_PACKAGE_MANAGER_MIXED', 'package.json', `packageManager ${pkg.packageManager} contradicts the npm package-lock.json contract.`);
41
- } catch { /* The repository's package/config checks own unreadable or invalid JSON. */ }
36
+ try {
37
+ const pkg = JSON.parse(fs.readFileSync(path.join(state.root, 'package.json'), 'utf8'));
38
+ if (pkg.packageManager && !/^npm@\d/u.test(pkg.packageManager))
39
+ addFinding(state, 'HFS_PACKAGE_MANAGER_MIXED', 'package.json', `packageManager ${pkg.packageManager} contradicts the npm package-lock.json contract.`);
40
+ }
41
+ catch { /* The repository's package/config checks own unreadable or invalid JSON. */ }
42
42
  }
43
-
44
43
  function checkRootPresentation(state) {
45
- const { runtime, tree } = state;
46
- for (const entry of tree.top) {
47
- if (/\.md$/iu.test(entry) && !(runtime ? RUNTIME_ROOT_MARKDOWN : PRODUCT_ROOT_MARKDOWN).has(entry))
48
- addFinding(state, 'HFS_ROOT_MARKDOWN_FORBIDDEN', entry, `Root Markdown ${entry} belongs under docs/ or the owning Work record.`);
49
- if (state.nonNpmEntries.has(entry)) addFinding(state, 'HFS_PACKAGE_MANAGER_MIXED', entry, `${entry} contradicts the npm package manager contract.`);
50
- }
51
- for (const entry of ['.gitattributes', 'README.md']) {
52
- if (!tree.hasFile(entry)) addFinding(state, 'HFS_ROOT_ENTRY_MISSING', entry, `Repository presentation requires root ${entry}.`);
53
- }
54
- if (tree.hasFile('package.json')) checkRootPackageManager(state);
55
- }
56
-
44
+ const { runtime, tree } = state;
45
+ for (const entry of tree.top) {
46
+ if (/\.md$/iu.test(entry) && !(runtime ? RUNTIME_ROOT_MARKDOWN : PRODUCT_ROOT_MARKDOWN).has(entry))
47
+ addFinding(state, 'HFS_ROOT_MARKDOWN_FORBIDDEN', entry, `Root Markdown ${entry} belongs under docs/ or the owning Work record.`);
48
+ if (state.nonNpmEntries.has(entry))
49
+ addFinding(state, 'HFS_PACKAGE_MANAGER_MIXED', entry, `${entry} contradicts the npm package manager contract.`);
50
+ }
51
+ for (const entry of ['.gitattributes', 'README.md']) {
52
+ if (!tree.hasFile(entry))
53
+ addFinding(state, 'HFS_ROOT_ENTRY_MISSING', entry, `Repository presentation requires root ${entry}.`);
54
+ }
55
+ if (tree.hasFile('package.json'))
56
+ checkRootPackageManager(state);
57
+ }
57
58
  function readmeSectionBody(lines, headings, section) {
58
- const start = headings.find(item => item.name === section)?.index;
59
- if (start === undefined) return '';
60
- const end = headings.find(item => item.index > start)?.index ?? lines.length;
61
- return lines.slice(start + 1, end).join('\n');
59
+ const start = headings.find(item => item.name === section)?.index;
60
+ if (start === undefined)
61
+ return '';
62
+ const end = headings.find(item => item.index > start)?.index ?? lines.length;
63
+ return lines.slice(start + 1, end).join('\n');
62
64
  }
63
-
64
65
  function checkReadmeHeadings(state, lines) {
65
- const { root, runtime, tree } = state;
66
- const name = runtime ? 'StarCi' : repositoryName(root);
67
- if (lines[0].trim().toLowerCase() !== `# ${name}`.toLowerCase())
68
- addFinding(state, 'HFS_README_TITLE_INVALID', 'README.md', `README.md must start with # ${name}.`);
69
- const description = lines.slice(1).find(line => line.trim());
70
- if (!description || /^\s*(?:#|!\[|\[!\[)/u.test(description) || description.trim().length > 240)
71
- addFinding(state, 'HFS_README_DESCRIPTION_INVALID', 'README.md', 'Place one concise description line directly below the repository name.');
72
- const headings = lines.map((line, index) => ({ name: README_HEADING.exec(line)?.[1], index })).filter(item => item.name);
73
- const required = [...README_SECTIONS, ...(tree.hasDir('.starciwork') ? ['Work'] : [])];
74
- let previous = -1;
75
- for (const section of required) {
76
- const found = headings.find(item => item.name === section);
77
- if (!found) addFinding(state, 'HFS_README_SECTION_MISSING', 'README.md', `README.md requires a ## ${section} section.`);
78
- else if (found.index <= previous) addFinding(state, 'HFS_README_SECTION_ORDER', 'README.md', `## ${section} must follow the preceding standard section.`, found.index + 1);
79
- else previous = found.index;
80
- }
81
- return headings;
82
- }
83
-
66
+ const { root, runtime, tree } = state;
67
+ const name = runtime ? 'StarCi' : repositoryName(root);
68
+ if ((lines[0] ?? '').trim().toLowerCase() !== `# ${name}`.toLowerCase())
69
+ addFinding(state, 'HFS_README_TITLE_INVALID', 'README.md', `README.md must start with # ${name}.`);
70
+ const description = lines.slice(1).find(line => line.trim());
71
+ if (!description || /^\s*(?:#|!\[|\[!\[)/u.test(description) || description.trim().length > 240)
72
+ addFinding(state, 'HFS_README_DESCRIPTION_INVALID', 'README.md', 'Place one concise description line directly below the repository name.');
73
+ const headings = lines.map((line, index) => ({ name: README_HEADING.exec(line)?.[1], index })).filter((item) => Boolean(item.name));
74
+ const required = [...README_SECTIONS, ...(tree.hasDir('.starciwork') ? ['Work'] : [])];
75
+ let previous = -1;
76
+ for (const section of required) {
77
+ const found = headings.find(item => item.name === section);
78
+ if (!found)
79
+ addFinding(state, 'HFS_README_SECTION_MISSING', 'README.md', `README.md requires a ## ${section} section.`);
80
+ else if (found.index <= previous)
81
+ addFinding(state, 'HFS_README_SECTION_ORDER', 'README.md', `## ${section} must follow the preceding standard section.`, found.index + 1);
82
+ else
83
+ previous = found.index;
84
+ }
85
+ return headings;
86
+ }
84
87
  function checkReadmeDevelopment(state, lines, headings) {
85
- if (state.runtime || !headings.some(item => item.name === 'Development')) return;
86
- const development = readmeSectionBody(lines, headings, 'Development');
87
- const scripts = DEVELOPMENT_SCRIPTS.filter(name => managedScriptNames(state.profile, state.edition).has(name));
88
- const commands = [/npm (?:ci|install)/u, ...scripts.map(scriptCommand)];
89
- if (commands.some(command => !command.test(development))) {
90
- addFinding(state, 'HFS_README_DEVELOPMENT_INCOMPLETE', 'README.md', 'Development must show npm install and the managed script commands: '
91
- + scripts.map(name => (name === 'test' ? 'npm test' : `npm run ${name}`)).join(', ') + '.');
92
- }
93
- }
94
-
88
+ if (state.runtime || !headings.some(item => item.name === 'Development'))
89
+ return;
90
+ const development = readmeSectionBody(lines, headings, 'Development');
91
+ const scripts = DEVELOPMENT_SCRIPTS.filter(name => managedScriptNames(state.profile, state.edition).has(name));
92
+ const commands = [/npm (?:ci|install)/u, ...scripts.map(scriptCommand)];
93
+ if (commands.some(command => !command.test(development))) {
94
+ addFinding(state, 'HFS_README_DEVELOPMENT_INCOMPLETE', 'README.md', 'Development must show npm install and the managed script commands: '
95
+ + scripts.map(name => (name === 'test' ? 'npm test' : `npm run ${name}`)).join(', ') + '.');
96
+ }
97
+ }
95
98
  function checkReadmeWorkPointer(state, lines, headings) {
96
- if (state.tree.hasDir('.starciwork') && headings.some(item => item.name === 'Work') &&
97
- !/\.starciwork\b/u.test(readmeSectionBody(lines, headings, 'Work')))
98
- addFinding(state, 'HFS_README_WORK_POINTER_MISSING', 'README.md', 'Work must point at the backend .starciwork tree.');
99
+ if (state.tree.hasDir('.starciwork') && headings.some(item => item.name === 'Work') &&
100
+ !/\.starciwork\b/u.test(readmeSectionBody(lines, headings, 'Work')))
101
+ addFinding(state, 'HFS_README_WORK_POINTER_MISSING', 'README.md', 'Work must point at the backend .starciwork tree.');
99
102
  }
100
-
101
103
  function inspectReadmeUrl(state, value, line) {
102
- try {
103
- if (privateHost(new URL(value).hostname))
104
- addFinding(state, 'HFS_README_PRIVATE_URL', 'README.md', `README URL ${value} points at a local or private host.`, line);
105
- } catch { /* Malformed URLs are outside this presentation rule. */ }
104
+ try {
105
+ if (privateHost(new URL(value).hostname))
106
+ addFinding(state, 'HFS_README_PRIVATE_URL', 'README.md', `README URL ${value} points at a local or private host.`, line);
107
+ }
108
+ catch { /* Malformed URLs are outside this presentation rule. */ }
106
109
  }
107
-
108
110
  function badgeTargets(prose) {
109
- return [
110
- ...[...prose.matchAll(/!\[([^\]]*)\]\(([^)]+)\)/gu)].map(match => ({ alt: match[1], target: match[2] })),
111
- ...[...prose.matchAll(/<img\b[^>]*>/giu)].map(match => ({
112
- alt: /\balt=["']([^"']*)["']/iu.exec(match[0])?.[1] ?? '',
113
- target: /\bsrc=["']([^"']*)["']/iu.exec(match[0])?.[1] ?? '',
114
- })),
115
- ];
116
- }
117
-
111
+ return [
112
+ ...[...prose.matchAll(/!\[([^\]]*)\]\(([^)]+)\)/gu)].map(match => ({ alt: match[1] ?? '', target: match[2] ?? '' })),
113
+ ...[...prose.matchAll(/<img\b[^>]*>/giu)].map(match => ({
114
+ alt: /\balt=["']([^"']*)["']/iu.exec(match[0])?.[1] ?? '',
115
+ target: /\bsrc=["']([^"']*)["']/iu.exec(match[0])?.[1] ?? '',
116
+ })),
117
+ ];
118
+ }
118
119
  function inspectBadgeTarget(state, alt, rawTarget, line) {
119
- const target = rawTarget.trim().replace(/^<|>$/gu, '');
120
- if (!/badge/iu.test(alt) && !/badge|shields\.io|badgen\.net/iu.test(target)) return;
121
- try {
122
- const url = new URL(target);
123
- if (url.protocol !== 'https:' || privateHost(url.hostname) ||
124
- /^(?:img\.shields\.io|badgen\.net)$/iu.test(url.hostname) && url.pathname.startsWith('/badge/'))
125
- addFinding(state, 'HFS_README_BADGE_NOT_LIVE', 'README.md', `Badge ${target} must represent a live external HTTPS service.`, line);
126
- } catch { addFinding(state, 'HFS_README_BADGE_NOT_LIVE', 'README.md', `Badge ${target} must use a live external HTTPS service.`, line); }
127
- }
128
-
120
+ const target = rawTarget.trim().replace(/^<|>$/gu, '');
121
+ if (!/badge/iu.test(alt) && !/badge|shields\.io|badgen\.net/iu.test(target))
122
+ return;
123
+ try {
124
+ const url = new URL(target);
125
+ if (url.protocol !== 'https:' || privateHost(url.hostname) ||
126
+ /^(?:img\.shields\.io|badgen\.net)$/iu.test(url.hostname) && url.pathname.startsWith('/badge/'))
127
+ addFinding(state, 'HFS_README_BADGE_NOT_LIVE', 'README.md', `Badge ${target} must represent a live external HTTPS service.`, line);
128
+ }
129
+ catch {
130
+ addFinding(state, 'HFS_README_BADGE_NOT_LIVE', 'README.md', `Badge ${target} must use a live external HTTPS service.`, line);
131
+ }
132
+ }
129
133
  function inspectReadmeLine(state, line, index, scan) {
130
- if (/^\s*```/u.test(line)) {
131
- scan.fenced = !scan.fenced;
132
- return;
133
- }
134
- if (scan.fenced) return;
135
- const prose = line.replace(/`[^`]*`/gu, '');
136
- for (const match of prose.matchAll(README_URL)) inspectReadmeUrl(state, trimTrailingChars(match[0], '.,;!?'), index + 1);
137
- for (const badge of badgeTargets(prose)) inspectBadgeTarget(state, badge.alt, badge.target, index + 1);
138
- }
139
-
134
+ if (/^\s*```/u.test(line)) {
135
+ scan.fenced = !scan.fenced;
136
+ return;
137
+ }
138
+ if (scan.fenced)
139
+ return;
140
+ const prose = line.replace(/`[^`]*`/gu, '');
141
+ for (const match of prose.matchAll(README_URL))
142
+ inspectReadmeUrl(state, trimTrailingChars(match[0], '.,;!?'), index + 1);
143
+ for (const badge of badgeTargets(prose))
144
+ inspectBadgeTarget(state, badge.alt, badge.target, index + 1);
145
+ }
140
146
  function checkReadmeLines(state, lines) {
141
- const scan = { fenced: false };
142
- for (let index = 0; index < lines.length; index += 1) inspectReadmeLine(state, lines[index], index, scan);
147
+ const scan = { fenced: false };
148
+ for (let index = 0; index < lines.length; index += 1)
149
+ inspectReadmeLine(state, lines[index] ?? '', index, scan);
143
150
  }
144
-
145
151
  function presentationResult(state) {
146
- return { violations: state.violations, coverage: { status: 'checked', source: state.tree.source } };
152
+ return { violations: state.violations, coverage: { status: 'checked', source: state.tree.source } };
147
153
  }
148
-
149
154
  export function checkRepoPresentationImpl({ root, runtime, tree, profile, edition, nonNpmEntries }) {
150
- const state = { root, runtime, tree, profile, edition, nonNpmEntries, violations: [] };
151
- checkRootPresentation(state);
152
- if (!tree.hasFile('README.md')) return presentationResult(state);
153
- let readme;
154
- try { readme = fs.readFileSync(path.join(root, 'README.md'), 'utf8'); }
155
- catch {
156
- addFinding(state, 'HFS_ROOT_ENTRY_MISSING', 'README.md', 'Tracked README.md is not readable.');
155
+ const state = { root, runtime, tree, profile, edition, nonNpmEntries, violations: [] };
156
+ checkRootPresentation(state);
157
+ if (!tree.hasFile('README.md'))
158
+ return presentationResult(state);
159
+ let readme;
160
+ try {
161
+ readme = fs.readFileSync(path.join(root, 'README.md'), 'utf8');
162
+ }
163
+ catch {
164
+ addFinding(state, 'HFS_ROOT_ENTRY_MISSING', 'README.md', 'Tracked README.md is not readable.');
165
+ return presentationResult(state);
166
+ }
167
+ const lines = readme.split(/\r?\n/u);
168
+ const headings = checkReadmeHeadings(state, lines);
169
+ checkReadmeDevelopment(state, lines, headings);
170
+ checkReadmeWorkPointer(state, lines, headings);
171
+ checkReadmeLines(state, lines);
157
172
  return presentationResult(state);
158
- }
159
- const lines = readme.split(/\r?\n/u);
160
- const headings = checkReadmeHeadings(state, lines);
161
- checkReadmeDevelopment(state, lines, headings);
162
- checkReadmeWorkPointer(state, lines, headings);
163
- checkReadmeLines(state, lines);
164
- return presentationResult(state);
165
173
  }