Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.5k views
in Technique[技术] by (71.8m points)

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>后报错
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

image

这个意思应该是只能在模板里面注释,不能再标签里面注释,你用模板语法试试能不能注释


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...