mai mohamed
mai mohamed

Reputation: 139

how to make .eslintrc accept single quotes

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

enter image description here

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

Upvotes: 4

Views: 5020

Answers (4)

Gh05d
Gh05d

Reputation: 8982

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

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

Upvotes: 7

First Arachne
First Arachne

Reputation: 829

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
    }
}

Upvotes: 0

Mohit Mishra
Mohit Mishra

Reputation: 97

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:recommended", "plugin:@typescript-eslint/recommended"],
  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 :)

Upvotes: 2

David Bradshaw
David Bradshaw

Reputation: 13077

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

Upvotes: 0

Related Questions