[英]How to get rid of Delete `··` (prettier/prettier) errors in a Vue JS project
I am trying to get rid of the error in relation to @vue/prettier
.我正在尝试消除与
@vue/prettier
相关的错误。 I have tried a few things, but it seems to throw up even more errors.我尝试了一些东西,但似乎抛出更多错误。
My .eslintrc.js
is as follows:我的
.eslintrc.js
如下:
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "@vue/prettier"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
},
parserOptions: {
parser: "babel-eslint"
}
};
I tried "endOfLine":"auto"
within the rules part but this then cause more and also 'prettier/prettier': ['error', {endOfLine: 'auto'}]
我在规则部分尝试
"endOfLine":"auto"
但这会导致更多和'prettier/prettier': ['error', {endOfLine: 'auto'}]
I have removed tabbed spacing from the bewlow;我已经从下面删除了制表符间距;
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
To be formatted like this;像这样格式化;
events_filtered_monthsNews: function() {return this.news.filter(u => u.monthsNews)},
Which removes warnings but now creates even more errors and is totally impractical for working.这消除了警告,但现在会产生更多错误,并且完全不切实际。
endOfLine
If you don't care about line endings, set endOfLine
to off
:如果您不关心行尾,请将
endOfLine
设置为off
:
// .eslintrc.js
module.exports = {
rules: {
"prettier/prettier": ["error", { endOfLine: "off" }],
},
};
tabWidth
Your current text is using 4-space tabs, but Prettier by default expects 2-space tabs.您当前的文本使用 4 个空格的制表符,但 Prettier 默认需要 2 个空格的制表符。
So this input:所以这个输入:
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
should be this:应该是这样的:
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
If you prefer 4-space tabs, configure Prettier's tabWidth
to 4
:如果您更喜欢 4 空格制表符,请将 Prettier 的
tabWidth
配置为4
:
// .eslintrc.js
module.exports = {
rules: {
"prettier/prettier": ["error", { tabWidth: 4 }],
},
};
I got Some error, "error Delete ␍
prettier/prettier" in multiple lines on my code, then I resolved this issue by follow these steps below:我在代码的多行中遇到了一些错误,“error Delete
␍
/prettier”,然后我按照以下步骤解决了这个问题:
Open Your project:打开你的项目:
cd "project folder"
cd "项目文件夹"
This command can fix all errors此命令可以修复所有错误
npm run lint --fix
npm 运行 lint --fix
Then:然后:
npm run lint
npm 运行棉绒
Initially reports errors, but should be fixed once nuxt/create-nuxt-app#100 is released.最初报告错误,但应在 nuxt/create-nuxt-app#100 发布后修复。
If you get an error for endOfLine: "off", following worked for me:如果您收到 endOfLine: "off" 的错误,以下对我有用:
rules: { "prettier/prettier": ["error", { endOfLine: "auto" }] }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.