From 286f48970f2b2c35c3fae14c5081d29ac23d11cc Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 2 Apr 2024 19:50:15 +0200 Subject: [PATCH 1/2] fix: ignore `name` field for global `ignores` (#131) --- src/config-array.js | 7 ++++++- tests/config-array.test.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/config-array.js b/src/config-array.js index 60af345..0722a18 100644 --- a/src/config-array.js +++ b/src/config-array.js @@ -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); /** @@ -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); } } diff --git a/tests/config-array.test.js b/tests/config-array.test.js index 6bcfeee..a1363ee 100644 --- a/tests/config-array.test.js +++ b/tests/config-array.test.js @@ -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()', () => { From 1a73c27ab510f5680411fc64bdfcafe98a0f4988 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:51:17 -0700 Subject: [PATCH 2/2] chore(main): release 0.12.2 (#132) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ee70d..a1ae5c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.12.2](https://github.com/humanwhocodes/config-array/compare/v0.12.1...v0.12.2) (2024-04-02) + + +### Bug Fixes + +* ignore `name` field for global `ignores` ([#131](https://github.com/humanwhocodes/config-array/issues/131)) ([286f489](https://github.com/humanwhocodes/config-array/commit/286f48970f2b2c35c3fae14c5081d29ac23d11cc)) + ## [0.12.1](https://github.com/humanwhocodes/config-array/compare/v0.12.0...v0.12.1) (2024-04-01) diff --git a/package-lock.json b/package-lock.json index 28a7985..5aef5a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@humanwhocodes/config-array", - "version": "0.12.1", + "version": "0.12.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@humanwhocodes/config-array", - "version": "0.12.1", + "version": "0.12.2", "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^2.0.3", diff --git a/package.json b/package.json index b43a03e..ae76b90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@humanwhocodes/config-array", - "version": "0.12.1", + "version": "0.12.2", "description": "Glob-based configuration matching.", "author": "Nicholas C. Zakas", "main": "api.js",