希望这是一个合理的问题,但我可能会误解某些事情。当我从grunt运行ESLint时,我在项目的.js
依赖项目录中的9个看似随机的node_modules
文件中引发了此警告。例如:
node_modules/cosmiconfig/node_modules/js-yaml/lib/js-yaml/type/js/function.js
0:0 warning File ignored by default. Use "--ignore-pattern '!node_modules/*'" to override
默认情况下会忽略项目根目录中的/ node_modules / *和/ bower_components / *
这一切都很好,但我不想在每次提取实际代码时都会提出这些警告。
我已尝试将/node_modules/*
模式明确添加到项目根目录中的.eslintignore
,但这并没有帮助。使用命令行标志建议只是让ESLint在我的依赖项上引发错误,这也不是我想要的。
有没有办法告诉ESLint我明确表示不想隐瞒我的依赖关系以便不会引发此警告?有一个默认会引发警告但不能被关掉似乎很傻。
感谢您的帮助。以下是一些相关的配置(完整代码在repo中,但当然node_modules
未签入):
https://github.com/jshields/joshuashields.com/blob/master/.eslintrc.js
https://github.com/jshields/joshuashields.com/blob/master/.eslintignore
https://github.com/jshields/joshuashields.com/blob/master/package.json
答案 0 :(得分:2)
您可以尝试添加**/node_modules/*
和**/bower_components/*
,看看它是否解决了问题? (可能是你有嵌套的node_modules和bower_components)。
结果.eslintignore:
/node_modules/*
**/node_modules/*
/bower_components/*
**/bower_components/*
答案 1 :(得分:1)
我的问题是我在Gruntfile.js
中定位的文件。我的任务是深入到node_modules
而不是我自己的代码。我将'**/js/*.js'
更改为'js/*.js'
:
diff --git a/Gruntfile.js b/Gruntfile.js
index 6b549f7..872abb2 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
//configFile:
},
files: {
- src: ['Gruntfile.js', 'stylelint.config.js', '**/js/*.js']
+ src: ['Gruntfile.js', 'stylelint.config.js', 'js/*.js']
}
}
},