简体   繁体   English

ESLint 是否可以对脚本标记具有属性 type="text/worker" 的 html 文件进行 lint?

[英]Is it possible for ESLint to lint an html file where the script tag has the attribute type="text/worker"?

I maintain a character sheet for Roll20.net and Roll20.net uses a custom script tag where type="text/worker".我为 Roll20.net 维护一个字符表,Roll20.net 使用自定义脚本标签,其中 type="text/worker"。 I'm using ESLint with Visual Studio Code.我在 Visual Studio Code 中使用 ESLint。 Is there a setting for ESLint to treat type="text/worker" as "text/JavaScript"? ESLint 是否有设置将 type="text/worker" 视为“text/JavaScript”? I reviewed the documentation for ESLint but didn't find anything that would help.我查看了ESLint的文档,但没有找到任何有用的信息

All the html and code is saved to a single file, gurps.html.所有的 html 和代码都保存在一个文件 gurps.html 中。

<div class="wrapper">
<!-- html for character sheet -->
</div>

<script type="text/worker">

    var version = "2.1.2";

    var damageTable = [];

    // events and functions for character sheet.

</script>

Assuming you set up the eslint-plugin-html successfully, you can set the html/javascript-mime-types .假设你成功设置了eslint-plugin-html ,你可以设置html/javascript-mime-types

In your case adding the following to your .eslintrc.json will enable linting of <script type="text/worker"> tags:在您的情况下,将以下内容添加到您的.eslintrc.json将启用<script type="text/worker">标签的.eslintrc.json

{
    "plugins": [
        "eslint-plugin-html"
    ],
    "settings": {
        "html/javascript-mime-types": ["text/javascript", "text/worker"]
    }
}

After you have done that the vscode-eslint extension will automatically respect that setting and lint the <script type="text/worker"> tag's content.完成后, vscode-eslint扩展将自动尊重该设置并检查<script type="text/worker">标签的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 html脚本标签不使用类型javascript <script type =“text / html”>? - html script tag not using type javascript <script type=“text/html”>? 是否可以使用 ESLint 来 lint Handlebars 模板? - Is it possible to use ESLint to lint Handlebars template? 理解一个中的“类型”属性<script> tag - Understanding the “type” attribute in a <script> tag nodejs 响应 HTML 文件,其中包含带有 src 属性的脚本标记 - nodejs response HTML file that contain script tag with src attribute ESLint - 显示尝试 Lint 但 Lints 文件的问题 - ESLint - Shows Issue Trying to Lint but Lints File 从 HTML 文件中的脚本标签导入 js。 可能的? - Import js from script tag in HTML file. Possible? 是否可以从HTML文件中的特定脚本标记引用函数或对象 - Is it possible to refer to function or object from particular script tag in HTML file 如何在HTML脚本标签JS上运行Gulp ESLint - How to run Gulp ESLint on HTML script tag JS Firebase TypeScript 上的 FCM:“脚本具有不受支持的 MIME 类型('text/html') - Firebase FCM on TypeScript: "The script has an unsupported MIME type ('text/html') 模拟服务器错误 - 脚本具有不受支持的 MIME 类型 ('text/html') - Mock server error - The script has an unsupported MIME type ('text/html')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM