mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user