Aci*_*dic 11 eslint vue.js prettier
我在我的Vue项目中使用了eslint-plugin-vue.
我有以下.prettierrc
文件:
// /.prettierrc
{
"arrowParens": "avoid",
"bracketSpacing": true,
"insertPragma": false,
"jsxBracketSameLine": false,
"printWidth": 80,
"proseWrap": "preserve",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
Run Code Online (Sandbox Code Playgroud)
以下.eslintrc.js
文件:
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/recommended',
'@vue/prettier',
],
rules: {
'linebreak-style': ['error', 'unix'],
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'vue/max-attributes-per-line': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
svg: 'always',
math: 'always',
},
],
},
plugins: ['vue'],
parserOptions: {
parser: 'babel-eslint',
},
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,更漂亮的人认为
<template>
<header><a href="/" class="logo"> Home </a></header>
</template>
Run Code Online (Sandbox Code Playgroud)
比较漂亮
<template>
<header>
<a href="/" class="logo">
Home
</a>
</header>
</template>
Run Code Online (Sandbox Code Playgroud)
如何在Vue模板中保留更漂亮的垂直空白?
有没有类似于我想要的规则?
小智 0
以下是 eslint 中 vue 的规则列表: https: //vuejs.github.io/eslint-plugin-vue/rules/ 但如果您禁用规则,它将应用于您的所有代码。
另外,似乎你可以告诉 Prettier 忽略一个块: https: //prettier.io/docs/en/ignore.html#html
此外,我认为这更“可读”,但这是我的观点:)
<template>
<header>
<a href="/" class="logo">Home</a>
</header>
</template>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
461 次 |
最近记录: |