为什么我不能使用 eslint-config-rallycoding npm 包来检查我的 create-react-app 项目?
Why can't I lint my create-react-app project with the eslint-config-rallycoding npm package?
我已经能够在多个 React 和 React Native 项目中使用 npm 包 eslint-config-rallycoding
,但是在使用 create-react-app
尝试时我 运行 遇到了问题。我需要执行其他步骤吗?
通常只需要:
- 创建项目
npm i --save-dev eslint-config-rallycoding
- 触摸.eslintrc
- 将
{ "extends": "rallycoding" }
添加到 .eslintrc 文件
我使用的是 sublime text 3,这适用于其他项目。我知道 create-react-app 有一堆额外的样板文件,也许我需要覆盖一些东西?
https://www.npmjs.com/package/eslint-config-rallycoding
https://github.com/facebookincubator/create-react-app
阅读 create-react-app 自述文件中的以下几行后,我注意到已经包含了 linting:
You would need to install an ESLint plugin for your editor first.
Then, add a file called .eslintrc
to the project root:
js { "extends": "react-app" }
Now your editor should report the linting warnings.
要像上面那样使用特定的 linting 包进一步自定义它,您需要弹出到 运行 npm run eject
这将从您的项目中删除单个构建依赖项,从而允许自定义 babel、webpack , 和 eslint 文件。
我已经能够在多个 React 和 React Native 项目中使用 npm 包 eslint-config-rallycoding
,但是在使用 create-react-app
尝试时我 运行 遇到了问题。我需要执行其他步骤吗?
通常只需要:
- 创建项目
npm i --save-dev eslint-config-rallycoding
- 触摸.eslintrc
- 将
{ "extends": "rallycoding" }
添加到 .eslintrc 文件
我使用的是 sublime text 3,这适用于其他项目。我知道 create-react-app 有一堆额外的样板文件,也许我需要覆盖一些东西?
https://www.npmjs.com/package/eslint-config-rallycoding https://github.com/facebookincubator/create-react-app
阅读 create-react-app 自述文件中的以下几行后,我注意到已经包含了 linting:
You would need to install an ESLint plugin for your editor first. Then, add a file called
.eslintrc
to the project root:
js { "extends": "react-app" }
Now your editor should report the linting warnings.
要像上面那样使用特定的 linting 包进一步自定义它,您需要弹出到 运行 npm run eject
这将从您的项目中删除单个构建依赖项,从而允许自定义 babel、webpack , 和 eslint 文件。