[英].eslintrc.js for React 17 and JSX without import 'react'
in react 17 is not necessarily use在反应 17 中不一定使用
import React from 'react';
but if i don't have it, so eslint gave me error但是如果我没有它,那么 eslint 给了我错误
'React' must be in scope when using JSX react/react-in-jsx-scope
any idea how modify .eslintrc.js知道如何修改 .eslintrc.js
module.exports = {
parser: "babel-eslint",
env: {
browser: true,
node: true,
es6: true,
jest: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended"
],
plugins: [
"react",
"react-hooks",
"jsx-a11y",
],
rules: {
strict: 0,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
},
settings: {
react: {
version: "detect"
}
}
}
for react 17?反应 17?
Thank's a lot非常感谢
You can read about it in React docs .你可以在React docs 中阅读它。
If you are using
eslint-plugin-react
, thereact/jsx-uses-react
andreact/react-in-jsx-scope
rules are no longer necessary and can be turned off or removed.如果您使用
eslint-plugin-react
,则react/jsx-uses-react
和react/react-in-jsx-scope
规则不再需要,可以关闭或删除。
{
// ...
"rules": {
// ...
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
}
To make it work, you should add those rules to your eslint
config, see Extending or replacing the default ESLint config for Create-React-App specifics, every framework should have related section in their docs.为了使其工作,您应该将这些规则添加到您的
eslint
配置中,请参阅扩展或替换Create-React-App 细节的默认 ESLint 配置,每个框架都应在其文档中具有相关部分。
You need to add plugin:react/jsx-runtime
to extends
in the .eslintrc.js
file.你需要在
.eslintrc.js
文件中添加plugin:react/jsx-runtime
来extends
。
like is:喜欢是:
module.exports = {
extends: [
'plugin:react/recommended',
'airbnb',
'plugin:react/jsx-runtime',
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.