[英]Vuejs/Eslint/Prettier - Eslint complaining about tabwith and not correcting issues
Trying to get Eslint and Prettier to work on Vue projects.试图让 Eslint 和 Prettier 参与 Vue 项目。 Having a couple of issues though.
虽然有几个问题。
For example, I have a rule setup is Eslint to add a space before function parens but it won't format:例如,我有一个规则设置是 Eslint 在 function 括号之前添加一个空格,但它不会格式化:
Another issue is, I get a error about the tab width in the template section (but I've specified I want 4 spaces in Prettier).另一个问题是,我在模板部分收到一个关于标签宽度的错误(但我已经指定我想要 Prettier 中的 4 个空格)。 Any where would this rule be coming from?
这个规则是从哪里来的? I haven't put 2 spaces for template section anywhere in the code:
我没有在代码中的任何地方为模板部分放置 2 个空格:
As an FYI, I'm running Lunvarvim , which (not to blow too much smoke) is a great IDE which I'd like to continue to use if I can resolve this few pain points.作为一个仅供参考,我正在运行Lunvarvim ,它(不要吹太多烟)是一个很棒的 IDE 如果我能解决这几个痛点,我想继续使用它。
Here is my setup:这是我的设置:
module.exports = {
env: {
browser: true,
es6: true,
amd: true,
jquery: true,
jest: true,
'jest/globals': true,
},
extends: [
'plugin:jest/recommended',
'plugin:cypress/recommended',
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:vue/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
$: true,
M: true,
Vue: true,
axios: true,
moment: true,
get: true,
process: true,
global: true,
accounting: true,
Qty: true,
Stripe: true,
Chart: true,
_: true,
},
parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['vue'],
overrides: [
{
files: ['*.spec.js'],
rules: {
'no-unused-expressions': 0,
},
},
],
rules: {
'object-curly-spacing': ['error', 'always', { objectsInObjects: true }],
'space-in-parens': ['error', 'never'],
'array-bracket-spacing': ['error', 'never'],
'space-before-function-paren': ['error', 'always'],
'vue/component-name-in-template-casing': [
'error',
'kebab-case',
{
registeredComponentsOnly: true,
ignores: [],
},
],
'vue/no-unused-properties': [
'error',
{
groups: ['props', 'data', 'computed', 'methods'],
},
],
indent: ['error', 4],
'linebreak-style': 0,
'global-require': 0,
quotes: ['error', 'single'],
semi: ['error', 'always'],
'no-trailing-spaces': ['warn', { skipBlankLines: true }],
'eol-last': ['warn', 'always'],
'vue/html-self-closing': [
'error',
{
html: {
normal: 'any',
},
},
],
'vue/valid-v-slot': [
'error',
{
allowModifiers: true,
},
],
},
};
{
"tabWidth": 4,
"singleQuote": true
}
Try to move the Prettier configuration into your package.json and make sure you have installed eslint-config-prettier尝试将 Prettier 配置移动到您的 package.json 并确保您已安装eslint-config-prettier
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.