如何 运行 在创建 React 应用程序时使用 eslint

How to run eslint in create react app

帮助 运行 eslint 创建 React 应用程序。

我用 tutorial

创建了 React 应用

然后我安装了

babel-eslint

standard

snazzy

然后我在下一行package.json中添加到脚本

"lint": "standart --verbose | snazzy"

现在我尝试 运行 eslint 命令:npm run lint

但是我有一个错误Parsing error: Unexpected token = null

我的完整package.json低于

{
  "name": "square_app_react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-scripts": "1.0.10"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint": "standart --verbose | snazzy"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.3",
    "standard": "^10.0.2"
  }
}

请帮助了解如何修复它或如何在我的情况下更正 运行 eslint。

提前谢谢你。

您的 package.json 脚本中的拼写错误。应该是:

"lint": "standard --verbose | snazzy"

您还需要配置标准才能使用 babel-eslint。确保将此添加到您的 package.json.

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

至 运行 EsLint inside src 文件夹:

./node_modules/react-scripts/node_modules/.bin/eslint src