Skip to content

Is it possbile to eslint-disable a script(type=module)?  #188

Closed
@wxiaoguang

Description

@wxiaoguang

When working with backend MVC projects, sometimes the code could be:

<!-- I want to disable eslint-plugin-html for this script block -->
<script type="module">
    window.myGlobal.var = {{.MyData}};  // here is invalid JS syntax, but it's rendered by backend template engine correctly.
</script>

<!--  eslint-plugin-html works well for this block, and it should be enabled -->
<script type="module">
    console.log(window.myGlobal.var);
</script>

What we need here is to make eslint-plugin-html skip a whole <script> block because code inside it is not valid JS syntax.

When using eslint-plugin-html, I can not find a proper way to disable the eslint for the script(type=module) block (I do not want ignore the whole file).

I know a trick that: <script><!-- /* eslint-disable */ --></script>, but it doesn't work for script(type=module)

For traditional <script> we can use <script><!-- /* eslint-disable */ --></script>.

But for <script type=module>, this trick doesn't work anymore because the module script doesn't accept <!-- HTML comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions