简体   繁体   中英

Eslint Parsing error: Unexpected token

I'm getting the error Parsing error: Unexpected token .. from eslint for this snippet. What's wrong with that?

const Public = ({ loggingIn, authenticated, component, ...rest }) => (
    <Route {...rest} render={(props) => {
        if (loggingIn) return <div></div>
        return !authenticated
            ? (React.createElement(component, { ...props, loggingIn, authenticated }))
            : (<Redirect to="/" />);
    }} />
)

You probably need to configure eslint to use the right parser for your project. If you're using babel you'll need babel-eslint:

npm install --save-dev babel-eslint

And then add this to your .eslintrc file:

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

If you're not using babel check out http://eslint.org/docs/user-guide/configuring#specifying-parser-options for other options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM