* Checks import layer boundaries for projects with layer architecture. * Only fires if the project has a layer config in harness.json or uses * common alias patterns (@kernel, @os, @domains).
(filePath, relativePath)
| 183 | case 'cross-reference': |
| 184 | docStalenessCheck(filePath, relativePath); |
| 185 | return 0; |
| 186 | default: |
| 187 | return 0; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // ── Structural Lint (hot-path) ────────────────────────────────────────────── |
| 192 | |
| 193 | /** |
| 194 | * Checks import layer boundaries for projects with layer architecture. |
| 195 | * Only fires if the project has a layer config in harness.json or uses |
| 196 | * common alias patterns (@kernel, @os, @domains). |
| 197 | */ |
| 198 | function structuralLint(filePath, relativePath) { |
| 199 | if (!/\.(ts|tsx|js|jsx)$/.test(filePath)) return; |
| 200 | |
| 201 | let content; |
| 202 | try { |
| 203 | content = fs.readFileSync(filePath, 'utf8'); |
| 204 | } catch { |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | const warnings = []; |
| 209 | |
| 210 | // Detect file's layer from path |
| 211 | const layer = detectLayer(relativePath); |
| 212 | if (!layer) return; |
| 213 | |
| 214 | // Check import violations |
| 215 | const importRegex = /(?:import|from)\s+['"](@(?:kernel|os|domains|ui|canvas)[^'"]*)['"]/g; |
| 216 | let match; |
| 217 | while ((match = importRegex.exec(content)) !== null) { |
| 218 | const importedAlias = match[1]; |
| 219 | const violation = checkLayerViolation(layer, importedAlias); |
| 220 | if (violation) { |
no test coverage detected