Local environment:
JavasSript React
import React from 'react';
A syntax error message appears:
Replace `'react'` with `"react"`eslint(prettier/prettier)
How can I configure it?
in .eslintrc.js
module.exports = {
root: true,
extends: '@react-native-community',
rules: {
quotes: [1, 'single'],
}
};
Thank you for your answer. Rules
can be solved
But I want to know where @react-native-community
comes from. I didn't see this file.
You can try something like this, it works for me.
package.json
"devDependencies": {
"eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.18.2"
},
.eslintrc
{
"extends": "react-app",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
.prettierrc
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 3
}
You can do the configuration by adapting .eslintrc
within your project. The error above is related to the quotes rule .
In eslint/ prettier configuration, you have enabled double quotes
.
check the following:
(ctrl +,) (cmd +,)
and search for single quote
and disable it.
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.