奇怪的 Vue linter 行为:H2 多行标记中的“123 {{ v }} 123”导致错误
Weird Vue linter behavior: "123 {{ v }} 123" within H2 multi-line tag caused error
我刚刚设置了我的开发环境,新安装的 Vue.js 和 NUXTJS 的 linter 和 prettier
我用
检查了我的配置
npx eslint --print-config ./pages/index.vue | npx eslint-config-prettier-check
和
No rules that are unnecessary or conflict with Prettier were found.
当我写下类似下面的内容和 eslint 弹出窗口并说,嘿,漂亮的不希望你这样做,有人知道为什么吗?在这种情况下,我不想让 linter 忽略,因为这种风格在我的代码中似乎很常见。如有任何帮助,我们将不胜感激!
错误:
代码:
<h2 class="subtitle">
123 {{ env }} 123
</h2>
<h2 class="subtitle">
{{ env }}
</h2>
<h1 class="title">
reborn
</h1>
我的.eslintrc.js如下所示:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
plugins: ['prettier', 'vue'],
rules: {
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debuger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/max-attributes-per-line': 'off',
'nuxt/no-cjs-in-config': 'off'
},
globals: {
$nuxt: true
},
extends: [
'@nuxtjs',
'plugin:prettier/recommended',
'plugin:nuxt/recommended',
'plugin:vue/recommended',
'prettier',
'prettier/babel',
'prettier/vue',
'prettier/unicorn'
]
}
linter 抱怨你的 return 个字符,请注意开头的 return 字符和第二个 123 之后的字符。
我相信这是说你应该把它们都放在同一行,即
<h2 class="subtitle">123 {{ env }} 123</h2>
当然,如果自动格式化程序上有一条冲突的规则说不要把它放在一行上,我也不会感到惊讶。你需要决定你更喜欢哪一个。就个人而言,我会找到并关闭该间距规则,因为我更喜欢您已有的格式。
我刚刚设置了我的开发环境,新安装的 Vue.js 和 NUXTJS 的 linter 和 prettier 我用
检查了我的配置npx eslint --print-config ./pages/index.vue | npx eslint-config-prettier-check
和
No rules that are unnecessary or conflict with Prettier were found.
当我写下类似下面的内容和 eslint 弹出窗口并说,嘿,漂亮的不希望你这样做,有人知道为什么吗?在这种情况下,我不想让 linter 忽略,因为这种风格在我的代码中似乎很常见。如有任何帮助,我们将不胜感激!
错误:
代码:
<h2 class="subtitle">
123 {{ env }} 123
</h2>
<h2 class="subtitle">
{{ env }}
</h2>
<h1 class="title">
reborn
</h1>
我的.eslintrc.js如下所示:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
plugins: ['prettier', 'vue'],
rules: {
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debuger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/max-attributes-per-line': 'off',
'nuxt/no-cjs-in-config': 'off'
},
globals: {
$nuxt: true
},
extends: [
'@nuxtjs',
'plugin:prettier/recommended',
'plugin:nuxt/recommended',
'plugin:vue/recommended',
'prettier',
'prettier/babel',
'prettier/vue',
'prettier/unicorn'
]
}
linter 抱怨你的 return 个字符,请注意开头的 return 字符和第二个 123 之后的字符。
我相信这是说你应该把它们都放在同一行,即
<h2 class="subtitle">123 {{ env }} 123</h2>
当然,如果自动格式化程序上有一条冲突的规则说不要把它放在一行上,我也不会感到惊讶。你需要决定你更喜欢哪一个。就个人而言,我会找到并关闭该间距规则,因为我更喜欢您已有的格式。