繁体   English   中英

Eslint解析错误:意外的令牌

[英]Eslint Parsing error: Unexpected token

我收到此代码段的错误Parsing error: Unexpected token ..来自eslint的 Parsing error: Unexpected token .. 怎么了

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="/" />);
    }} />
)

您可能需要将eslint配置为对项目使用正确的解析器。 如果您正在使用babel,则需要babel-eslint:

npm install --save-dev babel-eslint

然后将其添加到您的.eslintrc文件中:

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

如果您不使用babel,请查看http://eslint.org/docs/user-guide/configuring#specifying-parser-options中的其他选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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