尝试使用 eslint 来帮助我,但我得到的只是错误 - Configuration for Rule “endOfLine”无效
我遵循了使用 ESlint 的建议,因为在编写 firebase 函数代码时它应该很有帮助。
但是,即使是由 firebase 初始化的 helloWorld 函数也会给我错误?
Prettier 和 ESlint 也有冲突 - Prettier 在括号之间添加了空格,但 ESlint 不喜欢这样,并且再次给我错误?
我认为我可以通过遵循本指南来解决此冲突 - https://dev.to/s2engineers/how-to-make-eslint-work-with-prettier-avoiding-conflicts-and-problems-57pi
但我又收到了这个错误,我不知道不知道 endOfLine
规则应该做什么,但它给了我错误 -
Error: ../.eslintrc.json:
Configuration for rule "endOfLine" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '"auto"').
我的 .eslintrc.js 文件:
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ["airbnb-base"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["prettier"],
rules: {},
};
我是否缺少某些东西或 ESlint 根本没有帮助,为什么之间的间距括号重要吗?
I have followed the advice of using ESlint, because it's suppossed to be helpful, when writing firebase functions code.
However, even the helloWorld function that is initialized by firebase is giving me errors?
Prettier and ESlint is conflicting as well - prettier adds spaces between brackets, but ESlint doesn't like that and again giving me errors?
I thought that I could fix this conflict by following this guide - https://dev.to/s2engineers/how-to-make-eslint-work-with-prettier-avoiding-conflicts-and-problems-57pi
But again I got this error, that I don't know what endOfLine
rule supposed to do, but its giving me error -
Error: ../.eslintrc.json:
Configuration for rule "endOfLine" is invalid:
Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '"auto"').
my .eslintrc.js file:
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ["airbnb-base"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["prettier"],
rules: {},
};
Am I missing something or ESlint is not helpful at all, why does spacing between brackets matter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ESLint 绝对有帮助,就我个人而言,我从未注意到 prettier 和 eslint 之间存在冲突。如果你问我的话,括号间距的问题纯粹是美学问题,我个人更喜欢这样的想法:美学问题是格式化(更漂亮)的领域,而代码本身组成的最佳实践是 linting(eslint)的领域。
具体来说:我不知道你从airbnb-base 得到了什么规则,我不熟悉。但我建议您从打字稿项目的
extends
的推荐值开始,更像是:我认为
env
和parserOptions
是特定的到你的项目,所以我不包括那些。尽管如此......我不相信你真的需要prettier
插件。ESLint is definitely helpful, and personally I've never noticed a conflict between prettier and eslint. The question of bracket spacing is purely aesthetic if you ask me, and personally I prefer the idea that aesthetic questions are the domain of formatting (prettier), whereas best practices for the composition of the code itself is the domain of linting (eslint).
Concretely: I don't know what rules you're getting from airbnb-base, i'm not familiar. But I suggest you start with the recommended value for
extends
for a typescript project, something more like:I'm thinking
env
andparserOptions
are specific to your project so I'm not including those. Nonetheless ... I don't believe you really need theprettier
plugin.