alfianrehanusa
alfianrehanusa

Reputation: 2124

How to disable eslint(prettier/prettier) single quotes error

I have react-native code. I install ESLint. I use it but its show error.

While I use single quotes it show me error

Replace 'react-native' with "react-native" eslint(prettier/prettier)

And when I use double qoutes it show me another error

String must use singlequote. eslint(quotes)

here is the screenshot:

screenshot

What i want is, how to remove error messages about using single quotes? I prefer using single quotes instead double quotes.

Upvotes: 40

Views: 56381

Answers (5)

Sufian
Sufian

Reputation: 6555

None of the solutions worked for me so in my .eslintrc.js file, I replaced the following line:

extends: "@react-native-community",

With:

extends: ["@react-native-community", "prettier"],

This is what my .eslintrc.js file looks like now:

module.exports = {
  root: true,
  extends: ["@react-native-community", "prettier"],
};

Upvotes: 4

jessems
jessems

Reputation: 1592

In my case I needed to implement the changes suggest above AND press CMD + SHIFT + P and select "Reload Window" to reload VS Code for the changes to take effect.

Upvotes: 2

ConcernedHobbit
ConcernedHobbit

Reputation: 874

The two answers here helped me get to the solution that worked for me. In my .eslintrc file, I added the following:

"rules": {
  "prettier/prettier": ["error", { "singleQuote": true }]
}

Upvotes: 15

Barmar
Barmar

Reputation: 782130

In your ESLint configuration you want:

quotes: [2, "single"]

In you Pretty configuration you want:

single-quote: true

You should also be consistent in your use of quotes, so you should use single quotes in the second import line:

import App from './App';

Upvotes: 14

albertTaberner
albertTaberner

Reputation: 2149

In addition to @Barmar answer, you could also use prettier configuration on a .eslintrc.js file using the following, property:

rules: {
    // ...
    'prettier/prettier': ['error', { singleQuote: true }]
  }

Upvotes: 57

Related Questions