From 1c1753c4a07ce85478106d88390b18d75d513b2a Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sun, 17 May 2026 15:44:55 +0300 Subject: [PATCH] build(lint): generalize sibling domain suffix rule --- lint/plugin.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lint/plugin.js b/lint/plugin.js index 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 : null if (!domain) return false