admin管理员组

文章数量:1346053

I am facing this error when I 'npm start' my project:

I already know the problem is in the .eslintrc file so I added this:

"rules": {
    "quotes": [2, "single"],
}

and it's not working and it's the only solution I know

Update:

I tried deleting eslintConfig from package.json and it didn't work

and also "quotes": ["error", "single"] didn't work

I am facing this error when I 'npm start' my project:

I already know the problem is in the .eslintrc file so I added this:

"rules": {
    "quotes": [2, "single"],
}

and it's not working and it's the only solution I know

Update:

I tried deleting eslintConfig from package.json and it didn't work

and also "quotes": ["error", "single"] didn't work

Share Improve this question edited Mar 8, 2021 at 0:50 mai mohamed asked Mar 8, 2021 at 0:12 mai mohamed mai mohamed 1391 gold badge7 silver badges23 bronze badges 18
  • Is there an eslintConfig section in your package.json? That's standard for create-react-app, and it can take precedence over your separate .eslintrc file. – samuei Commented Mar 8, 2021 at 0:17
  • @samuei yes there's one in my package.json, should I delete it? – mai mohamed Commented Mar 8, 2021 at 0:22
  • Is the config meant to be "quotes": ["error", "single"], instead of "quotes": [2, "single"],? – evolutionxbox Commented Mar 8, 2021 at 0:24
  • 1 You can just replace all your double quotes in your project with single quotes. Or you can just disable the rule. – Take-Some-Bytes Commented Mar 10, 2021 at 2:02
  • 1 I'm curious why an eslint rule would prevent the script from piling? – evolutionxbox Commented Mar 11, 2021 at 12:03
 |  Show 13 more ments

4 Answers 4

Reset to default 7 +25

You can try to turn the rule off by passing 0 in the .eslintrc config file:

{
  "rules": {
    "quotes": [0, "single"]
  }
}

Based on the heading the solution is just to add a rule to allow single quotes. Refer below config, checkout rules object:

module.exports = {
  env: {
    browser: true,
    es2020: true,
  },
  extends: ["eslint:remended", "plugin:@typescript-eslint/remended"],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 11,
    sourceType: "module",
  },
plugins: ["@typescript-eslint", "prettier"],
rules: {
  "prettier/prettier": [
    1,
    {
      trailingComma: "es5",
      //to enable single quotes
      singleQuote: true,
      semi: true,
    },
  ],
  ...require("eslint-config-prettier").rules,
  ...require("eslint-config-prettier/@typescript-eslint").rules,
},
};

Try this out. If it doesn't work then share a bit more about the problem. May be write a small code try to replicate the issue and then share it here.

I hope this will help you out.

Cheers :)

Run eslint with the —fix flag and the problem will go away

I think you want to disable "quote" and "prettier/prettier" rules.

Please you can pass 0 to disable a rule.

{
    "rules": {
        "quotes": 0,
        "prettier/prettier": 0
    }
}

本文标签: javascripthow to make eslintrc accept single quotesStack Overflow