[英]ignore folder in eslint react
I'm developing an application using React and eslint.我正在使用 React 和 eslint 开发应用程序。 My problem is that inside my projects
src
folder there is an 'api-client' folder.我的问题是在我的项目
src
文件夹中有一个“api-client”文件夹。 Inside this folder are auto generated files used for managing connection to back-end.此文件夹内是自动生成的文件,用于管理与后端的连接。 My problem is that every time I run or make changes to the app I see lots of errors inside the console regarding
no-unused-vars
and similar.我的问题是,每次我运行或更改应用程序时,我都会在控制台中看到很多关于
no-unused-vars
和类似的错误。 Is there a way to ignore this folder completely?有没有办法完全忽略这个文件夹? I can't move it outside of the
src
folder.我无法将其移出
src
文件夹。 I'm ignoring this folder in .eslintignore
file with the line /src/api-client/*
.我使用
/src/api-client/*
行忽略了.eslintignore
文件中的这个文件夹。 Any help is really appreciated!非常感谢任何帮助!
You can specifically tell ESLint to ignore specific files type你可以明确告诉 ESLint 忽略特定的文件类型
Ignore the folder /src/folder-name
忽略文件夹
/src/folder-name
Ignore the folder and everything inside it /src/folder-name/**
忽略文件夹及其中的所有内容
/src/folder-name/**
Ignore the folder and everything inside it of special file type /src/folder-name/**/*.js
忽略文件夹及其中特殊文件类型
/src/folder-name/**/*.js
的所有内容
I could not find a specific solution but this worked for me.我找不到具体的解决方案,但这对我有用。
I needed to disable some react-app rules in a specific folder.我需要在特定文件夹中禁用一些 react-app 规则。 So I added this in my packages.json and it ignores the folder.
所以我在我的 packages.json 中添加了这个,它忽略了文件夹。 Not sure if there was a way to disable all rules maybe "*" but not sure.
不确定是否有办法禁用所有规则,可能是“*”,但不确定。
"eslintConfig": {
"extends": "react-app",
"overrides": [
{
"files": [
"src/modules/template/*"
],
"rules": {
"no-unused-vars": "off"
}
}
]
}, },
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.