Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/config-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const MINIMATCH_OPTIONS = {

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

/**
* Fields that are considered metadata and not part of the config object.
*/
const META_FIELDS = new Set(['name']);

const FILES_AND_IGNORES_SCHEMA = new ObjectSchema(filesAndIgnoresSchema);

/**
Expand Down Expand Up @@ -597,7 +602,7 @@ export class ConfigArray extends Array {
* In this case, it acts list a globally ignored pattern. If there
* are additional keys, then ignores act like exclusions.
*/
if (config.ignores && Object.keys(config).length === 1) {
if (config.ignores && Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1) {
result.push(...config.ignores);
}
}
Expand Down
16 changes: 16 additions & 0 deletions tests/config-array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,22 @@ describe('ConfigArray', () => {
expect(ignores).to.deep.equal(expectedIgnores);

});

it('should ignore name field for when considering global ignores', () => {
configs = new ConfigArray([
{
name: 'foo',
ignores: ['ignoreme']
},
], {
basePath
});

configs.normalizeSync();

expect(configs.isFileIgnored(path.join(basePath, 'ignoreme/foo.js'))).to.be.true;
expect(configs.ignores).to.eql(['ignoreme']);
});
});

describe('push()', () => {
Expand Down