如何在反应中删除.eslintcache文件?

我是 React 的新手。我有一个我无法解决的问题。我有一个“.eslintcache”文件,它是在我使用“create-react-app”在 React 中创建一个新应用程序后自动为我创建的。我不知道为什么我有这个文件。我试图删除它,但它总是回来。我运行这个命令 - “npm uninstall -g eslint --save” - 删除 eslint 的目录,但它没有帮助。我不知道如何处理它,我没有找到解决方案,我很乐意提供帮助。

回答

它是 CRA 捆绑包的一部分。.gitignore如果它不在那里,我建议只将它添加到文件中。

从ESLint 文档:

存储有关已处理文件的信息,以便仅对已更改的文件进行操作。默认情况下,缓存存储在 .eslintcache 中。启用此选项可以通过确保仅对更改的文件进行 linted 来显着提高 ESLint 的运行时间。

  • It's good to mention that this fix is temporary, as the create-react-app team recently made some work to move the .eslintcache file under the node_modules/.cache folder, which can be followed on this [pull-request](https://github.com/facebook/create-react-app/pull/9977) and this [issue](https://github.com/facebook/create-react-app/issues/10161). Until the 4.0.2 is released, you better add it to your `.gitignore` and be careful of any ESLint errors not being updated in the `.eslintcache` (see [this issue comment](https://github.com/facebook/create-react-app/issues/10161#issuecomment-737065960))

回答

它似乎是 React App 中的新问题(此问题于 2020 年 11 月 27 日开放)

.eslintcache.gitignore也这样做:

git rm -rf --cached .eslintcache
git add .

git rm: 从工作树中删除文件...

-r:在目录名称的情况下递归删除...

-f-force:覆盖最新检查。

详情:https : //git-scm.com/docs/git-rm


回答

这个文件是新版create-react-app包的一部分,你无法避免添加它,就像添加其他文件一样。这是捆绑包。

  • Don't just delete things, read about them before you delete.

回答

这是 react 新版本的一部分。我还有文件“reportWebVitals”和“setupTests”,我删除了它们,一切正常。

使用“reportWebVitals”,您可以跟踪您网站上的真实用户表现。使用“setupTests”初始化测试环境

此功能可用于 react-scripts@4.0.0 及更高版本

我不需要这些属性,只是删除了它们,就是这样,eslintcache 不能被删除是包的一部分。


以上是如何在反应中删除.eslintcache文件?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>