Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 286f489

Browse files
authored
fix: ignore name field for global ignores (#131)
1 parent 22b5487 commit 286f489

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/config-array.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const MINIMATCH_OPTIONS = {
3131

3232
const CONFIG_TYPES = new Set(['array', 'function']);
3333

34+
/**
35+
* Fields that are considered metadata and not part of the config object.
36+
*/
37+
const META_FIELDS = new Set(['name']);
38+
3439
const FILES_AND_IGNORES_SCHEMA = new ObjectSchema(filesAndIgnoresSchema);
3540

3641
/**
@@ -597,7 +602,7 @@ export class ConfigArray extends Array {
597602
* In this case, it acts list a globally ignored pattern. If there
598603
* are additional keys, then ignores act like exclusions.
599604
*/
600-
if (config.ignores && Object.keys(config).length === 1) {
605+
if (config.ignores && Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1) {
601606
result.push(...config.ignores);
602607
}
603608
}

tests/config-array.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,22 @@ describe('ConfigArray', () => {
21162116
expect(ignores).to.deep.equal(expectedIgnores);
21172117

21182118
});
2119+
2120+
it('should ignore name field for when considering global ignores', () => {
2121+
configs = new ConfigArray([
2122+
{
2123+
name: 'foo',
2124+
ignores: ['ignoreme']
2125+
},
2126+
], {
2127+
basePath
2128+
});
2129+
2130+
configs.normalizeSync();
2131+
2132+
expect(configs.isFileIgnored(path.join(basePath, 'ignoreme/foo.js'))).to.be.true;
2133+
expect(configs.ignores).to.eql(['ignoreme']);
2134+
});
21192135
});
21202136

21212137
describe('push()', () => {

0 commit comments

Comments
 (0)