Skip to content

linter does not accept script of inline type="importmap" or inline type="module" #929

@gongfan99

Description

@gongfan99

Describe the bug

linter does not accept script of inline type="importmap" or inline type="module"
The cause seems to be: in invalid_inline_script_syntax of packages/core/src/lint/rules/core.ts, only src= or type="application/json" gets exempted from the checking by new Function(...) which does not accept import statement or a json payload.
Is there a particular reason that inline type="importmap" or inline type="module" does not get the exemption?

Link to reproduction

see the steps below

Steps to reproduce

running npx hyperframes lint in a folder with the following index.html will fail.

<!doctype html>
<html lang="en">
  <body>
    <div
      id="takeshape-ad"
      data-composition-id="takeshape-ad"
      data-start="0"
      data-duration="58"
      data-width="1920"
      data-height="1080"
      >
    </div>
    <script type="importmap">
      {
        "imports": {
          "three": "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.module.js",
          "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.182.0/examples/jsm/"
        }
      }
    </script>
    <script type="module">
      import * as THREE from "three";
    </script>
    <script>
      window.__timelines = window.__timelines || {};
    </script>
  </body>
</html>

Expected behavior

lint should pass.

Actual behavior

Linting index.html

  ✗ invalid_inline_script_syntax: Inline script has invalid syntax: Unexpected token ':'
    Fix: Fix the inline script syntax before render verification.
  ✗ invalid_inline_script_syntax: Inline script has invalid syntax: Cannot use import statement outside a module
    Fix: Fix the inline script syntax before render verification.

◇  2 error(s), 0 warning(s)

Environment

hyperframes doctor

  ✓ Version          0.6.20 (latest)
  ✓ Node.js          v24.15.0 (win32 x64)
  ✓ CPU              8 cores · 12th Gen Intel(R) Core(TM) i3-1215U @ 2496MHz
  ✓ Memory           23.7 GB total · 10.3 GB free
  ✓ Disk             421.0 GB free
  ✓ Environment      Native terminal
  ✓ FFmpeg           D:\ffmpeg-8.1-essentials_build\bin\ffmpeg.exe
  ✓ FFprobe          ffprobe version 8.1-essentials_build-www.gyan.dev Copyright (c) 2007-2026 the FFmpeg developers
  ✓ Chrome           cache: C:\Users\dingh\.cache\hyperframes\chrome\chrome-headless-shell\win64-131.0.6778.85\chrome-headless-shell-win64\chrome-headless-shell.exe
  ✓ Docker           Docker version 28.3.2, build 578ccf6
  ✗ Docker running   Not running
                     Start Docker Desktop or run: sudo systemctl start docker

  ◇  Some checks failed — see hints above

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions