-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linting ignored files triggers a warning #119
Comments
I have the same problem. I tried applying the fix from here: eslint/eslint#5623 (comment) But if I specify |
Yeah, this is actually a bit non-intuitive and might be worthy of documentation. The solution is to not include them in the first place: "target": {
"src": [
"files/*/js/**/*.js",
"!files/*/js/*.min.js",
"!files/js/**/*.js",
"!files/*/js/*.js",
"!files/shared/js/vendor/**/*.js",
"!files/shared/js/found*/*.js",
"!files/bolt/**/*.js",
"!files/clean/js/codemirror/**/*.js",
"!files/clean/js/vendor/**/*.js",
"!files/clean/js/image-viewer_depricated/**/*.js",
"!files/clean/js/slick/**/*.js",
"!files/my-lists/**/*.js",
"!files/jv1/**/*.js",
"!files/testTarget/**/*.js",
"!files/jstor/**/*.js",
"!files/ui-guide/js/views/run_prettify.js"
]
} The better solution is to not need to exclude them because vendor files and dependencies aren't organized in the same tree. But this is the real world so use the above. 😉 |
@markelog Can this be closed? The eslint behaviour is (currently) "by design". Whereas grunt-eslint is a grunt plugin. If you need to ignore files, then use grunt's globbing patterns, as @StevenACoffman has suggested. |
@markelog <https://github.com/markelog> Can this be closed? The eslint
behaviour is (currently) "by design".
Whereas grunt-eslint is a grunt plugin. If you need to ignore files, then
use grunt's globbing patterns
<http://gruntjs.com/configuring-tasks#globbing-patterns>, as
@StevenACoffman <https://github.com/StevenACoffman> has suggested.
Such a solution requires duplicating the list of ignored files. I don't
think that's a good solution.
A proper solution would be to utilize the CLIEngine to silence this kind of
warning. That's why it was created in the first place.
|
I second utilizing the CLIEngine if possible. Adding a list of source patterns not to lint appears to greatly reduce performance. |
Hacky and dirty but satisfying workaround :)
Then below use:
|
Improved to allow for in-line comments as:
|
I figured out how to use @simlu's workaround for a package/repo which has multiple eslint configurations. Say a repo has this file structure:
This is an example of how to configure grunt-eslint to use both sets of eslint files: Codevar Path = require('path');
function trimComments(lines) {
return lines.map(function(line) {
var parts = line.split('#', 1);
var noncomment = parts[0];
// var comment = parts[1];
return noncomment;
});
}
function trimWhitespace(lines) {
return lines.map(function(line) {
return line.trim();
});
}
function rejectBlank(lines) {
return lines.filter(function(line) {
var isBlank = (line === '');
return !isBlank;
});
}
function prependDir(lines, dpath) {
return lines.map(function(line) {
var isNegater = line.startsWith('!');
return (isNegater)
? prependToNegater(line, dpath)
: prependToMatcher(line, dpath);
});
}
function prependToNegater(line, dpath) {
var fpath = line.slice(1);
var joined = Path.join(dpath, fpath);
return `!${joined}`;
}
function prependToMatcher(line, dpath) {
var fpath = line;
var joined = Path.join(dpath, fpath);
return joined;
}
function invertGlobs(lines) {
return lines.map(function(line) {
var isNegater = line.startsWith('!');
return (isNegater) ? line.slice(1) : `!${line}`;
});
}
module.exports = function(grunt) {
function ignoreFile(fpath) {
var dpath = Path.dirname(fpath);
var content = grunt.file.read(fpath);
var lines = content.split('\n');
lines = trimComments(lines);
lines = trimWhitespace(lines);
lines = rejectBlank(lines);
lines = prependDir(lines, dpath);
lines = invertGlobs(lines);
return lines;
}
grunt.config('eslint', {
backend: {
options: {
configFile: '.eslintrc.js',
ignore: false // suppress warnings when files are being ignored
},
src: [
'**/*.js',
...ignoreFile('.eslintignore') // but still ignore files
]
},
frontend: {
options: {
configFile: 'public/.eslintrc.js',
ignore: false // suppress warnings when files are being ignored
},
src: [
'public/**/*.js',
...ignoreFile('public/.eslintignore') // but still ignore files
]
}
});
grunt.loadNpmTasks('grunt-eslint');
}; |
Duplicate of #22, but despite that issue being "fixed" it is still reproducible.
Comment #22 (comment) wasn't answered, so re-creating it here, with hopes to clarify plugin current state.
Thank you.
The text was updated successfully, but these errors were encountered: