MCPcopy Create free account
hub / github.com/SethGammon/Citadel / checkLayerViolation

Function checkLayerViolation

hooks_src/post-edit.js:227–247  ·  view source on GitHub ↗
(layer, importAlias)

Source from the content-addressed store, hash-verified

225 if (warnings.length > 0) {
226 hookOutput('post-edit', 'warned',
227 `[structural] ${relativePath}:\n` + warnings.map(w => ` - ${w}`).join('\n') + '\n',
228 { file: relativePath, warnings, lens: 'structural' });
229 }
230}
231
232function detectLayer(relativePath) {
233 if (/^src\/kernel\//.test(relativePath)) return 'kernel';
234 if (/^src\/os\//.test(relativePath)) return 'os';
235 if (/^src\/domains\//.test(relativePath)) return 'domains';
236 if (/^src\/canvas\//.test(relativePath)) return 'canvas';
237 return null;
238}
239
240function checkLayerViolation(layer, importAlias) {
241 const importLayer = importAlias.split('/')[0].replace('@', '');
242
243 const rules = {
244 kernel: [], // kernel cannot import app layers
245 os: ['kernel'], // os can import kernel only
246 domains: ['kernel', 'os'], // domains can import kernel + os
247 canvas: ['kernel', 'os', 'ui'], // canvas can import kernel + os + design system
248 };
249
250 const allowed = rules[layer];

Callers 1

structuralLintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected