Skip to content

Commit 7f60186

Browse files
albertonzakas
authored andcommitted
Fix: --ignore-pattern can't uningnore files (fixes #6127) (#6253)
1 parent fea8fe6 commit 7f60186

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/ignored-paths.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ function IgnoredPaths(options) {
124124
if (options.ignore !== false) {
125125
var ignorePath;
126126

127-
if (options.ignorePattern) {
128-
addPattern(this.ig.custom, options.ignorePattern);
129-
addPattern(this.ig.default, options.ignorePattern);
130-
}
131-
132127
if (options.ignorePath) {
133128
debug("Using specific ignore file");
134129

@@ -159,6 +154,10 @@ function IgnoredPaths(options) {
159154
addIgnoreFile(this.ig.default, ignorePath);
160155
}
161156

157+
if (options.ignorePattern) {
158+
addPattern(this.ig.custom, options.ignorePattern);
159+
addPattern(this.ig.default, options.ignorePattern);
160+
}
162161
}
163162

164163
this.options = options;

tests/lib/ignored-paths.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ describe("IgnoredPaths", function() {
340340
assert.isFalse(ignoredPaths.contains(getFixturePath("unignored.js")));
341341
});
342342

343+
it("should return false for ignored file when unignored with ignore pattern", function() {
344+
var ignoredPaths = new IgnoredPaths({ ignore: true, ignorePath: getFixturePath(".eslintignore"), ignorePattern: "!sampleignorepattern", cwd: getFixturePath() });
345+
346+
assert.isFalse(ignoredPaths.contains(getFixturePath("sampleignorepattern")));
347+
348+
});
343349
});
344350

345351
describe("initialization with ignorePath containing commented lines", function() {

0 commit comments

Comments
 (0)