WebStorm 无法识别 JSX 内部组件的使用

WebStorm doesn't recognise use of components inside JSX

假设我正在导入一个组件:

const MyComponent   = require('./components/MyComponent');

然后在 JSX 块中使用它:

const App = props => (<MyComponent/>)

我在 WebStorm 中收到来自 Eslint 的错误:

'MyComponent' is assigned a value but never used (no-unused-vars)

如何让 WebStorm 理解我正在使用这个变量?

不是 WebStorm 而是 ESLint 无法识别您的 JSX 变量。你有安装 eslint-plugin-react 吗?我猜你错过了 jsx-uses-vars 规则。有关提示,请参阅 https://github.com/eslint/eslint/issues/2156, https://github.com/hyperapp/hyperapp/issues/557