Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

switched matching to use fnmatch

  • Loading branch information...
commit e65b2f99b171c2328a0a94f3ba689e79f6a81811 1 parent 936475f
@brentlintner brentlintner authored
View
6 .jshintignore
@@ -1,3 +1,3 @@
-node_modules
-packages
-.git/
+node_modules/*
+packages/*
+.git/*
View
4 README.md
@@ -52,7 +52,9 @@ If there is a .jshintrc file in the current working directory, any of those opti
## Ignoring Files and Directories
-If there is a .jshintignore file in the current working directory, then any directories or files will be skipped over.
+If there is a .jshintignore file in the current working directory, then any directories or files will be skipped over (see root directory for example).
+
+Note: Pattern matching is similar to a .gitignore file (uses FNM_PATHNAME flag)
## Installing dependencies for development
View
11 lib/hint.js
@@ -1,5 +1,6 @@
var fs = require('fs'),
sys = require('sys'),
+ glob = require('glob'),
path = require('path'),
jshint = require('./../packages/jshint/jshint.js'),
_reporter = require('./reporters/default').reporter;
@@ -31,16 +32,14 @@ function _lint(file, results, config, data) {
}
}
-function _shouldIgnore(path, toIgnore) {
- var endOfPath = new RegExp(path + "\\s?$");
- return !toIgnore || path === "." ? false : toIgnore.some(function (ignore) {
- var startOfPath = new RegExp(("^" + ignore));
- return ignore.match(endOfPath) || path.match(startOfPath);
+function _shouldIgnore(somePath, ignore) {
+ return ignore.some(function (ignorePath) {
+ return glob.fnmatch(ignorePath, somePath, glob.FNM_PATHNAME);
});
}
function _collect(filePath, files, ignore) {
- if (_shouldIgnore(filePath, ignore)) {
+ if (ignore && _shouldIgnore(filePath, ignore)) {
return;
}
View
3  package.json
@@ -24,7 +24,8 @@
"lib"
],
"dependencies": {
- "argsparser": ">=0.0.3"
+ "argsparser": ">=0.0.3",
+ "glob": ">=2.0.7"
},
"preferGlobal" : true
}
View
5 test/hint.js
@@ -152,8 +152,8 @@ describe("hint", function () {
});
it("ignores directories", function () {
- var targets = [".", "dir/file.js", "dir2/foo/file.js", "file0.js"],
- ignore = ["dir2"];
+ var targets = ["dir/file.js", "dir2/foo/file.js", "file0.js"],
+ ignore = ["dir2/*"];
spyOn(fs, "readFileSync").andReturn("data");
@@ -166,7 +166,6 @@ describe("hint", function () {
expect(fs.readFileSync.callCount).toBe(2);
expect(fs.readFileSync.argsForCall[1][0]).toBe("file0.js");
expect(fs.readFileSync.argsForCall[0][0]).toBe("dir/file.js");
- expect(fs.statSync).not.toHaveBeenCalledWith(targets[0]);
});
// TODO: support more robust ignore paths (ex foo/**/*.js)
Please sign in to comment.
Something went wrong with that request. Please try again.