[英]Replace `'react'` with `“react”` eslint(prettier/prettier)
Local environment:当地环境:
JavasSript React
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
在
.eslintrc.js
中
module.exports = {
root: true,
extends: '@react-native-community',
rules: {
quotes: [1, 'single'],
}
};
Thank you for your answer.谢谢您的回答。
Rules
can be solved Rules
可以解决
But I want to know where @react-native-community
comes from.但我想知道
@react-native-community
来自哪里。 I didn't see this file.我没有看到这个文件。
You can try something like this, it works for me.你可以试试这样的东西,它对我有用。
package.json package.json
"devDependencies": {
"eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.18.2"
},
.eslintrc .eslintrc
{
"extends": "react-app",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
.prettierrc .prettierrc
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 3
}
Have a look at the documentation here .看看这里的文档。 It specifies the singleQuote option, which could be configured in a configuration file for prettier or in the package.json, ie:
它指定了 singleQuote 选项,可以在 prettier 的配置文件或 package.json 中配置,即:
"prettier": {
"singleQuote": true
}
For other options of configuration, have a look here .有关其他配置选项,请查看此处。
You can do the configuration by adapting .eslintrc
within your project.您可以通过在项目中调整
.eslintrc
来进行配置。 The error above is related to the quotes rule .上面的错误与引号规则有关。
In eslint/ prettier configuration, you have enabled double quotes
.在 eslint/prettier 配置中,您启用
double quotes
。
check the following:检查以下内容:
(ctrl +,) (cmd +,)
and search for single quote
and disable it.(ctrl +,) (cmd +,)
并搜索single quote
并将其禁用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.