Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to parse ReactJS contextTypes using Standard + babel-eslint in SublimeText 3 (SublimeLinter) #613

Closed
dustypomerleau opened this issue Sep 6, 2016 · 2 comments

Comments

@dustypomerleau
Copy link

commented Sep 6, 2016

I am using this React Native sample code as a template to add tabbed navigation to a React Native mobile app:
https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/js/NavigationExperimental/NavigationCardStack-NavigationHeader-Tabs-example.js

In my project, the following code can't be parsed:

function createAppNavigationContainer (ComponentClass) {
  const key = '_containerNavigateCall'

  class Container extends Component {

    // commenting out the two contextTypes declarations below returns normal behavior
    static contextTypes = { // unable to parse this => 'unexpected token'
      [key]: PropTypes.func
    }; // dropping the semi here also results in a parsing error

    static childContextTypes = { // same issue here
      [key]: PropTypes.func.isRequired
    };

    getChildContext () {
      return {
        [key]:
          this.context[key] ||
          this.props.navigate
      }
    }

    render () {
      const navigate =
        this.context[key] ||
        this.props.navigate

      return <ComponentClass
        {...this.props}
        navigate={navigate}
      />
    }

  }

  return Container
}

In my SublimeLinter settings I have:

"linters": {
  "standard": {
      "@disable": false,
      "args": [],
      "excludes": [],
      "parser": "babel-eslint",
      "plugins": [
          "react"
      ]
  }
},

All npm packages are installed globally:
standard@8.0.0
babel-eslint@6.1.2
eslint-plugin-react@6.2.0

I have installed SublimeLinter-contrib-standard via ST3 package control, and I don't have any other linters.

EDIT: I should mention that the app performs as expected, without errors. Thanks in advance,

DP

@feross feross added the question label Sep 10, 2016

@feross

This comment has been minimized.

Copy link
Member

commented Sep 10, 2016

The correct place to add the "parser": "babel-eslint" line is in the "standard" property of "package.json".

See the instructions here: http://standardjs.com/#can-i-use-a-custom-js-parser-for-bleeding-edge-es-next-support

@feross feross closed this Sep 10, 2016

@dustypomerleau

This comment has been minimized.

Copy link
Author

commented Sep 11, 2016

Outstanding, thanks (for the answer and the linter)!

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.