【问题标题】:React, Standard & ESLint - 'propTypes' is not defined. (no-undef)React、Standard 和 ESLint - 'propTypes' 没有定义。 (无非定义)
【发布时间】:2018-09-28 19:47:57
【问题描述】:

我正在使用:

我的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


    【解决方案1】:

    Standard 更新为 11.0.1,错误消失了。

    谢天谢地!

    【讨论】:

      猜你喜欢
      • 2017-01-23
      • 1970-01-01
      • 2018-01-23
      • 2016-05-18
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      • 2018-02-12
      相关资源
      最近更新 更多