[英]Trying to use eslint to help me, but all I get is errors - Configuration for rule "endOfLine" is invalid
I have followed the advice of using ESlint, because it's suppossed to be helpful, when writing firebase functions code.我遵循了使用 ESlint 的建议,因为它在编写 firebase 函数代码时应该会有所帮助。
However, even the helloWorld function that is initialized by firebase is giving me errors?但是,即使是 firebase 初始化的 helloWorld function 也给我错误?
Prettier and ESlint is conflicting as well - prettier adds spaces between brackets, but ESlint doesn't like that and again giving me errors? Prettier 和 ESlint 也存在冲突 - prettier 在括号之间添加了空格,但 ESlint 不喜欢那样并再次给我错误?
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我认为我可以按照本指南解决此冲突 - 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 -但是我又遇到了这个错误,我不知道
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"').
my.eslintrc.js file:我的.eslintrc.js 文件:
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?我是不是遗漏了什么或者 ESlint 根本没有帮助,为什么括号之间的间距很重要?
ESLint is definitely helpful, and personally I've never noticed a conflict between prettier and eslint. ESLint 绝对有用,我个人从未注意到 prettier 和 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).
如果你问我,括号间距的问题纯粹是审美问题,我个人更喜欢审美问题是格式化领域(更漂亮)的想法,而代码本身组合的最佳实践是 linting (eslint) 领域。
Concretely: I don't know what rules you're getting from airbnb-base, i'm not familiar.具体来说:我不知道您从 airbnb-base 获得了什么规则,我不熟悉。 But I suggest you start with the recommended value for
extends
for a typescript project, something more like:但我建议您从 typescript 项目的
extends
推荐值开始,更像是:
[
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
I'm thinking env
and parserOptions
are specific to your project so I'm not including those.我认为
env
和parserOptions
特定于您的项目,所以我不包括那些。 N.netheless... I don't believe you really need the prettier
plugin. N.netheless...我不相信你真的需要
prettier
的插件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.