简体   繁体   English

尝试使用 eslint 来帮助我,但我得到的只是错误 - 规则“endOfLine”的配置无效

[英]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.我认为envparserOptions特定于您的项目,所以我不包括那些。 N.netheless... I don't believe you really need the prettier plugin. N.netheless...我不相信你真的需要prettier的插件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在尝试使用eslint nodejs api时未应用eslint插件? - Why eslint plugins are not applied when I am trying to use eslint nodejs api? 如何获取我的 MERN 应用程序上的所有帖子? 请帮我 - How can i get all posts on my MERN App? Please Help me 我一直尝试使用 require 来加载节点 fs 模块,它一直给我无效的回调错误,我该如何纠正这个问题 - I keep trying to use require to load in node fs module and it keeps giving me invalid callback error, how do i rectify this 我正在尝试通过运行“yarn”在 react web 应用程序中安装依赖项,但出现此错误,有人可以帮助我解决该问题 - Am trying to install dependencies in a react web app by running "yarn" but i get this error ,could someone help me on how to solve it 开玩笑的配置,帮我破译一下这个文件模式:[/\\\\] - Jest configuration, help me decipher this file pattern: [/\\\\] 请帮助我理解我从 DELETE 方法得到的这个错误 - Please help me understand this error I get from DELETE method Webpack 配置错误 - 请帮我纠正 - Webpack Configuration Error - please help me correct 部署到 Vercel 时出现错误。 谁能帮我解决下面的问题? - I am getting errors when deploying to Vercel. Can anyone help me with the my issues below? ESLint 不会对命令行中的所有错误进行 lint - ESLint doesn't lint ALL errors in command-line 我正在尝试使用yeoman和骨干创建示例应用程序,但显示一些错误有人可以帮助我吗? - I am trying to create sample app using yeoman and backbone but display some error can anyone help me?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM