简体   繁体   中英

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.

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

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

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';

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.

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"],
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM