简体   繁体   English

如何在 React 应用程序中禁用 eslint 类型错误?

[英]How to disable eslint type errors in react app?

I don't use typescript but i have type errors.我不使用 typescript 但我有类型错误。 I want to ignore type errors.我想忽略类型错误。 But i couldn't disable them.但我无法禁用它们。 Does anybody have idea?有人知道吗?

Examples:例子: 在此处输入图像描述

在此处输入图像描述

And this is my package.json:这是我的 package.json: 在此处输入图像描述

I may be wrong, but from your screenshot it seems you are using VSCode as your IDE. If you just want to stop these errors from showing up in the IDE, adding these overrides in your user/workspace settings should help:-我可能是错的,但从你的屏幕截图来看,你似乎正在使用 VSCode 作为你的 IDE。如果你只是想阻止这些错误出现在 IDE 中,在你的用户/工作区设置中添加这些覆盖应该会有所帮助:-

"typescript.validate.enable": false,
"javascript.validate.enable": false,

Also, it looks like a create-react-app scaffolded project, if you do not intend to use Typescript, it would be ideal to scaffold the project again without it, if that is still an option!此外,它看起来像一个create-react-app脚手架项目,如果您不打算使用 Typescript,那么最好在没有它的情况下再次搭建该项目,如果这仍然是一个选项!

I myself found the solution from here Edit.env:我自己从这里 Edit.env 找到了解决方案:

DISABLE_ESLINT_PLUGIN=true DISABLE_ESLINT_PLUGIN=真

Or in package.json:或者在 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"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM