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>后报错
在.eslinttrc.js中,直接 rules:{"vue/comment-directive": 'off'}, 世界瞬间安静了