【问题标题】:Eslint Parsing error: Unexpected tokenEslint 解析错误:意外的令牌
【发布时间】:2017-06-22 23:20:05
【问题描述】:

我从 eslint 收到此 sn-p 的错误 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="/" />);
    }} />
)

【问题讨论】:

标签: javascript reactjs eslint


【解决方案1】:

你可能需要配置 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 了解其他选项。

【讨论】:

    猜你喜欢
    • 2019-12-25
    • 2022-01-02
    • 2017-11-21
    • 2017-07-16
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    相关资源
    最近更新 更多