[英]React Types not being recognized by ESLint in Webstorm
I have started a new create-react-app (CRA) project to replace an existing React project that did not use CRA.我已经启动了一个新的 create-react-app (CRA) 项目来替换一个没有使用 CRA 的现有 React 项目。 The project is using TypeScript and my IDE is WebStorm.
该项目使用的是 TypeScript,我的 IDE 是 WebStorm。
My package.json file contains the following modules in devDependencies:我的 package.json 文件在 devDependencies 中包含以下模块:
"@types/react": "~16.9.50",
"@typescript-eslint/eslint-plugin": "~4.3.0",
"eslint": "6.6.0",
"eslint-config-airbnb-typescript": "~11.0.0",
"eslint-plugin-import": "~2.22.1",
"eslint-plugin-jsx-a11y": "~6.3.1",
"eslint-plugin-react": "~7.21.3",
"eslint-plugin-react-hooks": "~4.1.2",
"typescript": "~4.0.3"
An example of one component is as follows:一个组件的示例如下:
import React, { FunctionComponent } from 'react';
const Content: FunctionComponent = () => (
<div>Hello</div>
);
export { Content };
ESLint / WebStorm complains with the following error: ESLint / WebStorm 抱怨以下错误:
ESLint: 'FunctionComponent' is defined but never used.(@typescript-eslint/no-unused-vars)
My code still compiles without any errors or warnings and my website works without any issues.我的代码仍然可以编译,没有任何错误或警告,我的网站也没有任何问题。 My previous project did not have any issues recognizing TypeScript types.
我之前的项目在识别 TypeScript 类型方面没有任何问题。 I have the @types modules installed.
我安装了@types 模块。 I think the relevant parts of .eslintrc, tsconfig.json and the relevant settings in WebStorm are identical.
我认为.eslintrc、tsconfig.json 的相关部分和WebStorm 中的相关设置是相同的。
Does anyone have any insight?有没有人有任何见解?
我通过升级到 react-scripts 4.0 解决了这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.