【发布时间】:2018-09-28 19:47:57
【问题描述】:
我正在使用:
- React 16.2.0
- Standard 10.0.3
- Babel ES Lint 8.2.3
- @babel/plugin-proposal-class-properties 7.0.0-beta.40
- VS Code
我的package.json中有这个:
"standard": {
"parser": "babel-eslint"
}
我正在编写我的 React 组件,例如:
class MyComponent extends React.Component {
static propTypes = {}
static defaultProps = {}
myMethod = () => {}
render () {}
}
我看到了这些错误:
'propTypes' 未定义。 (无非定义)
'defaultProps' 未定义。 (无非定义)
'myMethod' 未定义。 (无非定义)
每次我打开组件文件时,这些错误都会让我感到头疼!
如何让 ES Lint 将这些类属性识别为有效,或者告诉 ES Lint 忽略它们..?
【问题讨论】:
标签: javascript reactjs babeljs eslint standardjs