@humanwhocodes/config-array
Advanced tools
Comparing version 0.11.2 to 0.11.3
84
api.js
@@ -263,3 +263,3 @@ 'use strict'; | ||
*/ | ||
function shouldIgnoreFilePath(ignores, filePath, relativeFilePath) { | ||
function shouldIgnorePath(ignores, filePath, relativeFilePath) { | ||
@@ -271,39 +271,31 @@ // all files outside of the basePath are ignored | ||
let shouldIgnore = false; | ||
return ignores.reduce((ignored, matcher) => { | ||
for (const matcher of ignores) { | ||
if (!ignored) { | ||
if (typeof matcher === 'function') { | ||
shouldIgnore = shouldIgnore || matcher(filePath); | ||
continue; | ||
} | ||
if (typeof matcher === 'function') { | ||
return matcher(filePath); | ||
} | ||
/* | ||
* If there's a negated pattern, that means anything matching | ||
* must NOT be ignored. To do that, we need to use the `flipNegate` | ||
* option for minimatch to check if the filepath matches the | ||
* pattern specified after the !, and if that result is true, | ||
* then we return false immediately because this file should | ||
* never be ignored. | ||
*/ | ||
if (matcher.startsWith('!')) { | ||
// don't check negated patterns because we're not ignored yet | ||
if (!matcher.startsWith('!')) { | ||
return doMatch(relativeFilePath, matcher); | ||
} | ||
/* | ||
* The file must already be ignored in order to apply a negated | ||
* pattern, because negated patterns simply remove files that | ||
* would already be ignored. | ||
*/ | ||
if (shouldIgnore && | ||
doMatch(relativeFilePath, matcher, { | ||
flipNegate: true | ||
})) { | ||
return false; | ||
} | ||
} else { | ||
shouldIgnore = shouldIgnore || doMatch(relativeFilePath, matcher); | ||
// otherwise we're still not ignored | ||
return false; | ||
} | ||
} | ||
// only need to check negated patterns because we're ignored | ||
if (typeof matcher === 'string' && matcher.startsWith('!')) { | ||
return !doMatch(relativeFilePath, matcher, { | ||
flipNegate: true | ||
}); | ||
} | ||
return shouldIgnore; | ||
return ignored; | ||
}, false); | ||
} | ||
@@ -363,3 +355,3 @@ | ||
if (filePathMatchesPattern && config.ignores) { | ||
filePathMatchesPattern = !shouldIgnoreFilePath(config.ignores, filePath, relativeFilePath); | ||
filePathMatchesPattern = !shouldIgnorePath(config.ignores, filePath, relativeFilePath); | ||
} | ||
@@ -688,3 +680,3 @@ | ||
if (shouldIgnoreFilePath(this.ignores, filePath, relativeFilePath)) { | ||
if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) { | ||
debug(`Ignoring ${filePath}`); | ||
@@ -747,3 +739,3 @@ | ||
if (shouldIgnoreFilePath(this.ignores, filePath, relativeFilePath)) { | ||
if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) { | ||
debug(`Ignoring ${filePath} based on file pattern`); | ||
@@ -858,22 +850,8 @@ | ||
// if we've made it here, it means there's nothing in the cache | ||
const result = this.ignores.some(matcher => { | ||
const result = shouldIgnorePath( | ||
this.ignores.filter(matcher => typeof matcher === 'function' || !matcher.endsWith('/**')), | ||
directoryPath, | ||
relativeDirectoryPath | ||
); | ||
if (typeof matcher === 'function') { | ||
return matcher(relativeDirectoryPath); | ||
} | ||
// skip negated patterns because you can't unignore directories | ||
if (matcher.startsWith('!')) { | ||
return false; | ||
} | ||
// patterns ending with ** never match directories | ||
if (matcher.endsWith('/**')) { | ||
return false; | ||
} | ||
return doMatch(relativeDirectoryPath, matcher); | ||
}); | ||
cache.set(relativeDirectoryPath, result); | ||
@@ -880,0 +858,0 @@ |
# Changelog | ||
## [0.11.3](https://github.com/humanwhocodes/config-array/compare/v0.11.2...v0.11.3) (2022-10-13) | ||
### Bug Fixes | ||
* Ensure directories can be unignored. ([206404c](https://github.com/humanwhocodes/config-array/commit/206404c490d354a4f39ef9b4a6d0ceaec119abc5)) | ||
## [0.11.2](https://github.com/humanwhocodes/config-array/compare/v0.11.1...v0.11.2) (2022-10-03) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@humanwhocodes/config-array", | ||
"version": "0.11.2", | ||
"version": "0.11.3", | ||
"description": "Glob-based configuration matching.", | ||
@@ -53,3 +53,3 @@ "author": "Nicholas C. Zakas", | ||
"chai": "4.3.6", | ||
"eslint": "8.24.0", | ||
"eslint": "8.25.0", | ||
"esm": "3.2.25", | ||
@@ -56,0 +56,0 @@ "lint-staged": "13.0.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55307
693