ESlint报错提示clear
Vscode中编写的html文件末尾ESlint(vue/comment-directive)报错提示clear
环境背景
使用Vue3 + TypeScript 搭建的项目
相关代码
eslintrc文件代码
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/vue3-essential',
'@vue/standard',
'@vue/typescript/recommended'
],
parserOptions: {
ecmaVersion: 2020
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'comma-dangle': ['error', 'always-multiline'],
camelcase: process.env.NODE_ENV === 'production' ? 'error' : 'off',
'import/order': ['error', {
'groups': ['builtin', 'external', 'parent', 'sibling', 'index'],
}],
'vue/html-closing-bracket-newline': ['error', {
multiline: 'never',
}],
'vue/html-closing-bracket-spacing': ['error', {
startTag: 'never',
endTag: 'never',
selfClosingTag: 'always',
}],
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
'vue/html-quotes': ['error', 'double'],
'vue/html-self-closing': ['error', {
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
}],
'vue/order-in-components': ['error', {
order: [
'el',
'name',
'parent',
'functional',
['delimiters', 'comments'],
['components', 'directives', 'filters'],
'extends',
'mixins',
'inheritAttrs',
'model',
['props', 'propsData'],
'data',
'computed',
'watch',
'LIFECYCLE_HOOKS',
'methods',
['template', 'render'],
'renderError',
],
}],
'no-useless-catch': 0,
'no-prototype-builtins': 0,
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true,
},
},
],
报错文件代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>xxx</title>
<script>
function setAttribute(params, link) {
for (var k in params) {
link.setAttribute(k, params[k]);
}
head.appendChild(link);
};
var link32 = document.createElement('link');
var link16 = document.createElement('link');
var linkSafari = document.createElement('link');
var head = document.getElementsByTagName('head')[0];
var icon32 = {
'rel': 'icon',
'type': 'image/png',
'sizes': '32x32',
'href': '/api/v1/infos/favicon?' + Math.random()
};
var icon16 = {
'rel': 'icon',
'type': 'image/png',
'sizes': '16x16',
'href': '/api/v1/infos/favicon?' + Math.random()
};
var iconSafari = {
'rel': 'icon',
'type': 'image/png',
'sizes': '180x180',
'href': '/api/v1/infos/favicon?' + Math.random()
};
setAttribute(icon16, link16);
setAttribute(icon32, link32);
setAttribute(iconSafari, linkSafari);
</script>
</head>
<body>
<noscript>
<strong>We're sorry but xxx doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
文件末尾的</html>后报错
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在.eslinttrc.js中,直接 rules:{"vue/comment-directive": 'off'}, 世界瞬间安静了
这个意思应该是只能在模板里面注释,不能再标签里面注释,你用模板语法试试能不能注释