问题描述
当我运行npm run lint
(从package.json调用"lint": "vue-cli-service lint"
)时,我在HTML属性中得到了以下更改:
- :auth0Login="auth0Login"
+ :auth0login="auth0Login"
这破坏了代码,我不希望它发生。我尝试了以下规则来防止这种情况:
"vue/camelcase": "off","vue/name-property-casing": "off","vue/custom-event-name-casing": "off","vue/component-definition-name-casing": "off","vue/prop-name-casing": "off","vue/component-name-in-template-casing": "off",
这些都不起作用,这并不令人惊讶,因为它们都不指定HTML属性。我能找到的所有与套管有关的东西。
我知道整理不是严格必要的,并且开始感觉它产生的问题比解决的问题多,但是如果有人知道解决方案,我还是想做这项工作。
package.json中的eslintConfig的astebin:https://pastebin.com/h52YxjRd
解决方法
规则是vue /强烈推荐的“ vue /属性-连字符”。
此问题已解决:
"vue/attribute-hyphenation": "off"
这是因为 vue / attribute-hyphenation 规则
vue /属性连字符
-
在模板中的自定义组件上强制属性命名样式
-
此规则包含在“ plugin:vue / vue3-strong-recommended”,“ plugin:vue / strong-recommended”,“ plugin:vue / vue3-recommended”和“ plugin:vue /推荐”
示例:
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template>
<!-- ✓ GOOD -->
<MyComponent my-prop="prop" />
<!-- ✗ BAD -->
<MyComponent myProp="prop" />
</template>
您可以通过在规则中添加以下行来忽略此功能
rules: {
"vue/attribute-hyphenation": "off"
}
官方DOC:https://eslint.vuejs.org/rules/attribute-hyphenation.html