fix(lint): detect Three.js loaded via importmap or ES module import

The missing_three_script rule only checked <script src> attributes
for Three.js. Now also detects:
- importmap entries defining "three"
- ES module import/from statements referencing "three"

Closes #931
This commit is contained in:
Miguel Ángel
2026-05-18 11:06:51 -04:00
parent 15c2d7644d
commit 9f18425eae
+9 -1
View File
@@ -37,8 +37,16 @@ export const adapterRules: Array<(ctx: LintContext) => HyperframeLintFinding[]>
const usesThree = allScriptTexts.some((t) => /\bTHREE\./.test(t));
const hasThreeScript = allScriptSrcs.some((src) => /three/i.test(src));
const hasThreeImportMap = allScriptTexts.some(
(t) =>
/["']three["']/.test(t) &&
/importmap/.test(scripts.find((s) => s.content === t)?.attrs || ""),
);
const hasThreeModuleImport = allScriptTexts.some(
(t) => /\bimport\b.*['"]three['"]/.test(t) || /\bfrom\s+['"]three['"]/.test(t),
);
if (!usesThree || hasThreeScript) return [];
if (!usesThree || hasThreeScript || hasThreeImportMap || hasThreeModuleImport) return [];
return [
{
code: "missing_three_script",