[英]How to get rid of Delete `··` (prettier/prettier) errors in a Vue JS project
我正在尝试消除与@vue/prettier
相关的错误。 我尝试了一些东西,但似乎抛出更多错误。
我的.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"
}
};
我在规则部分尝试"endOfLine":"auto"
但这会导致更多和'prettier/prettier': ['error', {endOfLine: 'auto'}]
我已经从下面删除了制表符间距;
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
像这样格式化;
events_filtered_monthsNews: function() {return this.news.filter(u => u.monthsNews)},
这消除了警告,但现在会产生更多错误,并且完全不切实际。
endOfLine
如果您不关心行尾,请将endOfLine
设置为off
:
// .eslintrc.js
module.exports = {
rules: {
"prettier/prettier": ["error", { endOfLine: "off" }],
},
};
tabWidth
您当前的文本使用 4 个空格的制表符,但 Prettier 默认需要 2 个空格的制表符。
所以这个输入:
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
应该是这样的:
events_filtered_monthsNews: function() {
return this.news.filter(u => u.monthsNews)
},
如果您更喜欢 4 空格制表符,请将 Prettier 的tabWidth
配置为4
:
// .eslintrc.js
module.exports = {
rules: {
"prettier/prettier": ["error", { tabWidth: 4 }],
},
};
我在代码的多行中遇到了一些错误,“error Delete ␍
/prettier”,然后我按照以下步骤解决了这个问题:
打开你的项目:
cd "项目文件夹"
此命令可以修复所有错误
npm 运行 lint --fix
然后:
npm 运行棉绒
最初报告错误,但应在 nuxt/create-nuxt-app#100 发布后修复。
如果您收到 endOfLine: "off" 的错误,以下对我有用:
rules: { "prettier/prettier": ["error", { endOfLine: "auto" }] }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.