AI-native design editor. Open-source Figma alternative.
build(lint): generalize sibling domain suffix rule
Danila Poyarkov1c1753c4a07c
diff --git a/lint/plugin.js b/lint/plugin.jsindex 3db1fb19a..f4d2fa44b 100644--- a/lint/plugin.js+++ b/lint/plugin.js@@ -1,9 +1,14 @@import { existsSync } from 'node:fs'+import path from 'node:path'function normalizedFilename(context) {return (context.filename ?? context.getFilename?.() ?? '').replace(/\\/g, '/')}+function relativeFromRepo(file) {+ return path.relative(process.cwd(), file).replace(/\\/g, '/')+}+function importSource(node) {return typeof node.source?.value === 'string' ? node.source.value : null}@@ -1490,6 +1495,11 @@ const noDirectOpenPencilWindowInternals = {}}+const SIBLING_DOMAIN_FILENAME_ALLOWLIST = new Set([+ 'packages/core/src/canvas/ai-overlays.ts',+ 'packages/core/src/canvas/selection-labels.ts'+])+const noTopLevelPrefixedTestFiles = createProgramFilenameRule({description: 'Disallow top-level test files that encode domains as filename prefixes',check(file) {@@ -1509,11 +1519,13 @@ const noSiblingDomainPrefixedFiles = createProgramFilenameRule({const parts = name.split('-')if (parts.length < 2) return false+ if (SIBLING_DOMAIN_FILENAME_ALLOWLIST.has(relativeFromRepo(file))) return false+const prefix = parts[0]const suffix = parts.at(-1)const domain = existsSync(`${dir}${prefix}`)? prefix- : suffix === 'menu' && existsSync(`${dir}${suffix}`)+ : suffix && existsSync(`${dir}${suffix}`)? suffix: nullif (!domain) return false