首页 > 解决方案 > 禁用 create-react-app 提供的 ESLint

问题描述

create-react-appv3.0.0 已发布。它在内部支持 TypeScript linting。(太好了!)我想我了解 TSLint 开启的情况,并计划用 ESLint 替换它,但现在不是。

如何禁用该 linting 步骤react-scripts start

/* eslint-disable */其他人不是我要找的人。

标签: reactjstypescripteslintcreate-react-app

解决方案


react-scriptsv4.0.2 开始,您现在可以使用环境变量选择退出 ESLint。您可以通过将其添加到.env文件中或在 package.json 文件中为脚本添加前缀来完成此操作。

例如在.env

DISABLE_ESLINT_PLUGIN=true

或者在你的 package.json 中:

{
  "scripts": {
    "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
    "build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
    "test": "DISABLE_ESLINT_PLUGIN=true react-scripts test"
  }
}

https://github.com/facebook/create-react-app/pull/10170


推荐阅读