javascriptreactjsbabeljseslintstandardjs

React, Standard & ESLint - 'propTypes' is not defined. (no-undef)


I'm using:

I have this in my package.json:

"standard": {
  "parser": "babel-eslint"
}

I'm writing my React components like:

class MyComponent extends React.Component {
  static propTypes = {}
  static defaultProps = {}
  myMethod = () => {}
  render () {}
}

I'm seeing these errors:

'propTypes' is not defined. (no-undef)

'defaultProps' is not defined. (no-undef)

'myMethod' is not defined. (no-undef)

These errors are winding me up every time I open a component file!

How do I either make ES Lint recognise these class properties as valid, or tell ES Lint to ignore them..?


Solution

  • Updated Standard to 11.0.1 and the errors are gone.

    Thank goodness for that!