Skip to content

Commit

Permalink
fix!: treat * as a universal pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jun 7, 2024
1 parent 16ee1fa commit 210aa2a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/config-array/src/config-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ export class ConfigArray extends Array {

const matchingConfigIndices = [];
let matchFound = false;
const universalPattern = /\/\*{1,2}$/;
const universalPattern = /^\*$|\/\*{1,2}$/;

this.forEach((config, index) => {
if (!config.files) {
Expand All @@ -905,8 +905,8 @@ export class ConfigArray extends Array {
}

/*
* If a config has a files pattern ending in /** or /*, and the
* filePath only matches those patterns, then the config is only
* If a config has a files pattern * or patterns ending in /** or /*,
* and the filePath only matches those patterns, then the config is only
* applied if there is another config where the filePath matches
* a file with a specific extensions such as *.js.
*/
Expand Down
20 changes: 20 additions & 0 deletions packages/config-array/tests/config-array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,26 @@ describe("ConfigArray", () => {
);
});

it('should return "unconfigured" when there is only * pattern', () => {
configs = new ConfigArray(
[
{
files: ["*"],
},
],
{
basePath,
},
);

configs.normalizeSync();

assert.strictEqual(
configs.getConfigStatus(path.join(basePath, "a.js")),
"unconfigured",
);
});

it('should return "matched" when files pattern matches and there is a pattern ending with /**', () => {
configs = new ConfigArray(
[
Expand Down

0 comments on commit 210aa2a

Please sign in to comment.