Skip to content

vue/no-parsing-error

禁止在 <template> 中解析错误

  • ⚙️ 此规则包含在 "plugin:vue/essential"*.configs["flat/essential"]"plugin:vue/vue2-essential"*.configs["flat/vue2-essential"]"plugin:vue/strongly-recommended"*.configs["flat/strongly-recommended"]"plugin:vue/vue2-strongly-recommended"*.configs["flat/vue2-strongly-recommended"]"plugin:vue/recommended"*.configs["flat/recommended"]"plugin:vue/vue2-recommended"*.configs["flat/vue2-recommended"] 中。

此规则报告 <template> 中的语法错误。例如:

¥This rule reports syntax errors in <template>. For example:

  • 指令中脚本的语法错误。

    ¥Syntax errors of scripts in directives.

  • 胡子中脚本的语法错误。

    ¥Syntax errors of scripts in mustaches.

  • HTML 语法错误。

    ¥Syntax errors of HTML.

📖 规则详情

此规则尝试通过解析 <script> 的解析器解析 <template> 中的指令/mustaches。然后报告语法错误(如果存在)。

¥This rule tries to parse directives/mustaches in <template> by the parser which parses <script>. Then reports syntax errors if exist.

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/no-parsing-error": ["error", {
    "abrupt-closing-of-empty-comment": true,
    "absence-of-digits-in-numeric-character-reference": true,
    "cdata-in-html-content": true,
    "character-reference-outside-unicode-range": true,
    "control-character-in-input-stream": true,
    "control-character-reference": true,
    "eof-before-tag-name": true,
    "eof-in-cdata": true,
    "eof-in-comment": true,
    "eof-in-tag": true,
    "incorrectly-closed-comment": true,
    "incorrectly-opened-comment": true,
    "invalid-first-character-of-tag-name": true,
    "missing-attribute-value": true,
    "missing-end-tag-name": true,
    "missing-semicolon-after-character-reference": true,
    "missing-whitespace-between-attributes": true,
    "nested-comment": true,
    "noncharacter-character-reference": true,
    "noncharacter-in-input-stream": true,
    "null-character-reference": true,
    "surrogate-character-reference": true,
    "surrogate-in-input-stream": true,
    "unexpected-character-in-attribute-name": true,
    "unexpected-character-in-unquoted-attribute-value": true,
    "unexpected-equals-sign-before-attribute-name": true,
    "unexpected-null-character": true,
    "unexpected-question-mark-instead-of-tag-name": true,
    "unexpected-solidus-in-tag": true,
    "unknown-named-character-reference": true,
    "end-tag-with-attributes": true,
    "duplicate-attribute": true,
    "end-tag-with-trailing-solidus": true,
    "non-void-html-element-start-tag-with-trailing-solidus": false,
    "x-invalid-end-tag": true,
    "x-invalid-namespace": true
  }]
}

你可以通过选项禁用 HTML 语法错误。请参阅 WHATWG HTML 规范 了解 HTML 语法错误的详细信息。默认情况下仅禁用 non-void-html-element-start-tag-with-trailing-solidus,因为 Vue.js 支持自闭合标签。

¥You can disable HTML syntax errors by options. Please see WHATWG HTML spec to know the details of HTML syntax errors. Only non-void-html-element-start-tag-with-trailing-solidus is disabled by default because Vue.js supports self-closing tags.

注意

此规则不支持所有这些(例如,它不会捕获有关 DOCTYPE 的错误)。

¥This rule does not support all of those (E.g., it does not catch errors about DOCTYPE).

具有 x- 前缀的错误代码是此规则的原始代码,因为树构造阶段的错误尚未编纂。

¥The error codes which have x- prefix are original of this rule because errors in tree construction phase have not codified yet.

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v3.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号