Skip to content

Commit 10d8200

Browse files
authored
feat!: Remove ConfigArray#isExplicitMatch() (#53)
1 parent 2edc0f0 commit 10d8200

File tree

2 files changed

+0
-118
lines changed

2 files changed

+0
-118
lines changed

packages/config-array/src/config-array.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -783,54 +783,6 @@ export class ConfigArray extends Array {
783783

784784
/* eslint-enable class-methods-use-this -- Desired as instance methods */
785785

786-
/**
787-
* Determines if a given file path explicitly matches a `files` entry
788-
* and also doesn't match an `ignores` entry. Configs that don't have
789-
* a `files` property are not considered an explicit match.
790-
* @param {string} filePath The complete path of a file to check.
791-
* @returns {boolean} True if the file path matches a `files` entry
792-
* or false if not.
793-
*/
794-
isExplicitMatch(filePath) {
795-
assertNormalized(this);
796-
797-
const cache = dataCache.get(this);
798-
799-
// first check the cache to avoid duplicate work
800-
const result = cache.explicitMatches.get(filePath);
801-
802-
if (typeof result === "boolean") {
803-
return result;
804-
}
805-
806-
// TODO: Maybe move elsewhere? Maybe combine with getConfig() logic?
807-
const relativeFilePath = path.relative(this.basePath, filePath);
808-
809-
if (shouldIgnorePath(this.ignores, filePath, relativeFilePath)) {
810-
debug(`Ignoring ${filePath}`);
811-
812-
// cache and return result
813-
cache.explicitMatches.set(filePath, false);
814-
return false;
815-
}
816-
817-
// filePath isn't automatically ignored, so try to find a match
818-
819-
for (const config of this) {
820-
if (!config.files) {
821-
continue;
822-
}
823-
824-
if (pathMatches(filePath, this.basePath, config)) {
825-
debug(`Matching config found for ${filePath}`);
826-
cache.explicitMatches.set(filePath, true);
827-
return true;
828-
}
829-
}
830-
831-
return false;
832-
}
833-
834786
/**
835787
* Returns the config object for a given file path and a status that can be used to determine why a file has no config.
836788
* @param {string} filePath The complete path of a file to get a config for.

packages/config-array/tests/config-array.test.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,76 +3107,6 @@ describe("ConfigArray", () => {
31073107
});
31083108
});
31093109

3110-
describe("isExplicitMatch()", () => {
3111-
it("should throw an error when not normalized", () => {
3112-
const filename = path.resolve(basePath, "foo.js");
3113-
assert.throws(() => {
3114-
unnormalizedConfigs.isExplicitMatch(filename);
3115-
}, /normalized/u);
3116-
});
3117-
3118-
it("should return true when passed JS filename", () => {
3119-
const filename = path.resolve(basePath, "foo.js");
3120-
3121-
assert.strictEqual(configs.isExplicitMatch(filename), true);
3122-
});
3123-
3124-
it("should return true when passed HTML filename", () => {
3125-
const filename = path.resolve(basePath, "foo.html");
3126-
3127-
assert.strictEqual(configs.isExplicitMatch(filename), true);
3128-
});
3129-
3130-
it("should return true when passed CSS filename", () => {
3131-
const filename = path.resolve(basePath, "foo.css");
3132-
3133-
assert.strictEqual(configs.isExplicitMatch(filename), true);
3134-
});
3135-
3136-
it("should return true when passed EXE filename because it matches !.css", () => {
3137-
const filename = path.resolve(basePath, "foo.exe");
3138-
3139-
assert.strictEqual(configs.isExplicitMatch(filename), true);
3140-
});
3141-
3142-
it("should return false when passed EXE filename because no explicit matches", () => {
3143-
const filename = path.resolve(basePath, "foo.exe");
3144-
configs = new ConfigArray(
3145-
[
3146-
{
3147-
files: ["*.js"],
3148-
},
3149-
],
3150-
{
3151-
basePath,
3152-
},
3153-
);
3154-
configs.normalizeSync();
3155-
3156-
assert.strictEqual(configs.isExplicitMatch(filename), false);
3157-
});
3158-
3159-
it("should return false when passed matching both files and ignores in a config", () => {
3160-
configs = new ConfigArray(
3161-
[
3162-
{
3163-
files: ["**/*.xsl"],
3164-
ignores: ["fixtures/test.xsl"],
3165-
defs: {
3166-
xsl: true,
3167-
},
3168-
},
3169-
],
3170-
{ basePath },
3171-
);
3172-
3173-
configs.normalizeSync();
3174-
const filename = path.resolve(basePath, "fixtures/test.xsl");
3175-
3176-
assert.strictEqual(configs.isExplicitMatch(filename), false);
3177-
});
3178-
});
3179-
31803110
describe("files", () => {
31813111
it("should throw an error when not normalized", () => {
31823112
assert.throws(() => {

0 commit comments

Comments
 (0)