Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: treat division after } as division in import-case scanner (#12302)

[._.]/ Adam Eivyb4e7bd763c4e
diff --git a/scripts/check-import-case.js b/scripts/check-import-case.js
index d86da95cd4..6d35cb4aa3 100644
--- a/scripts/check-import-case.js
+++ b/scripts/check-import-case.js
@@ -93,7 +93,8 @@ function scanCode(source) {
} else if (ch === '`') {
i = readTemplate(i);
prev = '`';
- } else if (ch === '/' && (prev === '' || '(,=:[!&|?{};+-*%<>~^'.includes(prev)) && !isPostfixStep()) {
+ } else if (ch === '/' && (prev === '' || '(,=:[!&|?{;+-*%<>~^'.includes(prev)) && !isPostfixStep()) {
+ // `}` is deliberately not a regex start: it usually ends an object/function expression (`{} / d`), and mis-scanning a rare regex statement after a block is safer than dropping later imports from the check.
let j = i + 1;
let inClass = false;
while (j < source.length && source[j] !== '\n' && (inClass || source[j] !== '/')) {
diff --git a/scripts/check-import-case.test.js b/scripts/check-import-case.test.js
index 2a94ba8206..1f1613b887 100644
--- a/scripts/check-import-case.test.js
+++ b/scripts/check-import-case.test.js
@@ -55,6 +55,14 @@ describe('relativeSpecifiers ignores non-executable text', () => {
].join("\n");
expect(relativeSpecifiers(source)).toEqual(['./AfterInc.js', './AfterDec.js', './AfterParen.js', './AfterBracket.js', './AfterRegex.js']);
});
+
+ it('treats division after an object literal or function expression as division', () => {
+ const source = [
+ "const ratio = {} / divisor; await import('./AfterObject.js');",
+ "const half = function () {} / 2; await import('./AfterFunction.js');",
+ ].join('\n');
+ expect(relativeSpecifiers(source)).toEqual(['./AfterObject.js', './AfterFunction.js']);
+ });
});
describe('importCaseMismatches', () => {