我正在尝试将vsc设置为具有react的代码。现在我要解决这个问题。我收到有关报价的错误。漂亮的eslint告诉我将“”替换为“”。我希望能够同时使用单引号和双引号而不会出现任何错误。 例如:
Failed to compile.
./src/registerServiceWorker.js
Line 12: Replace `'localhost'` with `"localhost"` prettier/prettier
我拥有最新版本的vsc,eslint,更漂亮,react,node,并且我正在使用ubuntu 18.04。我已经安装了诸如eslint-config-prettier之类的东西以及我在网上找到的其他东西。但我仍然收到此错误。我猜接下来要做的就是在.prettierrc.json文件中添加“ prettier / prettier”规则:[“ error”,{“ singleQuote”:false}]。但是我不知道这个文件在哪里。它不在我现在正在工作的项目的根目录中。我尝试根据规则将其添加到.eslintrc.json文件,但仍然收到错误。请需要帮助!!!如何摆脱这个错误?
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-console": 0,
"prettier/prettier": ["error", {"singleQuote": false}]
}
}
最后,有什么方法可以同时使用单引号''和双引号“”,而不会从其中任何一个得到错误?