简体   繁体   English

eslint 不忽略 node_modules 并在尝试 lint 时出错

[英]eslint not ignoring node_modules and getting error when try to lint

I'm trying to implement eslint in a Next.js project.The file structure look like below我正在尝试在Next.js项目中实现eslint 。文件结构如下所示

.eslintignore
.eslintrc.js
.next
.prettierrc
.stylelintrc.js
components
forms
modals
modules
node_modules

And I have node_modules/* in my .eslintignore file.我的.eslintignore文件中有node_modules/* When I try to lint these by eslint --fix /sources/**/*.js I am getting below error当我尝试通过eslint --fix /sources/**/*.js对这些进行 lint 时,我遇到了错误

You are linting "/sources/node_modules/ally.js", but all of the files matching the glob pattern "/sources/node_modules/ally.js" are ignored.

Anyone can help me to solve this?任何人都可以帮我解决这个问题吗? Thanks谢谢

If .eslintignore located in the same directory as node_modules you can specify it as node_modules .如果.eslintignore与 node_modules 位于同一目录中, node_modules node_modules

# .eslintignore
node_modules
**/.next/**
**/_next/**
**/dist/**

.eslintignore follows .gitignore syntax. .eslintignore遵循.gitignore语法。 See .gitignore specs for more details.有关更多详细信息,请参阅.gitignore 规范

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

相关问题 忽略Docker卷中的每个`node_modules` - Ignoring every `node_modules` in a docker volume 在 Babel 中禁用目录“node_modules” - Disable directory "node_modules" ignoring in Babel Nuxt.js:模块错误(来自./node_modules/eslint-loader/index.js): - Nuxt.js: Module Error (from ./node_modules/eslint-loader/index.js): 减少 node_modules 后 node_modules 出错 - Error with node_modules after I decreased the node_modules 在 node_modules/ 中使用 ES6 文件运行 Mocha 时出错 - Error when running Mocha with ES6 files in node_modules/ GitLab CI 找不到模块错误(当它在 node_modules 中时) - GitLab CI cannot find module error (when it is in node_modules) 为什么我的应用程序在运行时出现此错误,“ERROR in./node_modules/@nestjs/common/cache/cache.providers.js”? - Why is my app getting this error when I run it, “ERROR in ./node_modules/@nestjs/common/cache/cache.providers.js”? es-lint 发出警告,提示```存在多个名称仅大小写不同的模块。``` 用于 node_modules - es-lint is throwing a warning for ```There are multiple modules with names that only differ in casing.``` for node_modules 更新 npm 后 node_modules 出现错误? - ERROR in node_modules after updating the npm? node_modules 错误未导出统计信息 - 汇总 - Stats is not exported by node_modules error - Rollup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM