From faf7b4d4852bd7ed8e89c1018c01f090fafb579b Mon Sep 17 00:00:00 2001 From: taki Date: Fri, 31 Jul 2020 23:36:13 +0900 Subject: [PATCH 1/7] chore(jest-haste-map): remove support for ignorePattern as function --- packages/jest-haste-map/src/index.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index f0e4aa25e605..5c33889fa115 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -255,23 +255,11 @@ class HasteMap extends EventEmitter { }; this._console = options.console || global.console; - if (options.ignorePattern) { - if (options.ignorePattern instanceof RegExp) { - this._options.ignorePattern = new RegExp( - options.ignorePattern.source.concat('|' + VCS_DIRECTORIES), - options.ignorePattern.flags, - ); - } else { - const ignorePattern = options.ignorePattern; - const vcsIgnoreRegExp = new RegExp(VCS_DIRECTORIES); - this._options.ignorePattern = (filePath: string) => - vcsIgnoreRegExp.test(filePath) || ignorePattern(filePath); - - this._console.warn( - 'jest-haste-map: the `ignorePattern` options as a function is being ' + - 'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.', - ); - } + if (options.ignorePattern && options.ignorePattern instanceof RegExp) { + this._options.ignorePattern = new RegExp( + options.ignorePattern.source.concat('|' + VCS_DIRECTORIES), + options.ignorePattern.flags, + ); } else { this._options.ignorePattern = new RegExp(VCS_DIRECTORIES); } From eb7847fd63d5bcddcce773fa0d868743364223e3 Mon Sep 17 00:00:00 2001 From: taki Date: Sat, 1 Aug 2020 13:32:04 +0900 Subject: [PATCH 2/7] update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99689b1d4169..d1f8a2acf392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### Chore & Maintenance +- `[jest-haste-map]` Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348)) + ### Performance ## 26.4.2 From f47e566d3146ff30f8241da7f76c8214b7b81a02 Mon Sep 17 00:00:00 2001 From: Taki Komiyama <39375566+komtaki@users.noreply.github.com> Date: Sat, 1 Aug 2020 17:05:27 +0900 Subject: [PATCH 3/7] Add Breaking change tag CHANGELOG.md Co-authored-by: Simen Bekkhus --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1f8a2acf392..9573bef82f51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ ### Chore & Maintenance -- `[jest-haste-map]` Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348)) +- `[jest-haste-map]` [**BREAKING**] Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348)) ### Performance From a42ca97d2ace0b1b69942a3c7b5ca410f304d55c Mon Sep 17 00:00:00 2001 From: Taki Komiyama <39375566+komtaki@users.noreply.github.com> Date: Sat, 1 Aug 2020 17:10:52 +0900 Subject: [PATCH 4/7] Add ignorePattern option wrong error. Co-authored-by: Simen Bekkhus --- packages/jest-haste-map/src/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index 5c33889fa115..375b780ad2d9 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -255,11 +255,17 @@ class HasteMap extends EventEmitter { }; this._console = options.console || global.console; - if (options.ignorePattern && options.ignorePattern instanceof RegExp) { - this._options.ignorePattern = new RegExp( - options.ignorePattern.source.concat('|' + VCS_DIRECTORIES), - options.ignorePattern.flags, - ); + if (options.ignorePattern) { + if (options.ignorePattern instanceof RegExp) { + this._options.ignorePattern = new RegExp( + options.ignorePattern.source.concat('|' + VCS_DIRECTORIES), + options.ignorePattern.flags, + ); + } else { + throw new Error( + 'jest-haste-map: the `ignorePattern` option must be a RegExp', + ); + } } else { this._options.ignorePattern = new RegExp(VCS_DIRECTORIES); } From 62107825e49ca6415a545520c9c9e61a47cf5010 Mon Sep 17 00:00:00 2001 From: komtaki Date: Thu, 1 Oct 2020 08:56:18 +0900 Subject: [PATCH 5/7] Add test --- .../jest-haste-map/src/__tests__/index.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index 0ddddf58895b..533b684d55e7 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -345,6 +345,21 @@ describe('HasteMap', () => { }); }); + it('warn on ignore pattern except for regex', () => { + const config = {ignorePattern: 'Kiwi', ...defaultConfig}; + mockFs['/project/fruits/Kiwi.js'] = ` + // Kiwi! + `; + + try { + new HasteMap(config).build(); + } catch (err) { + expect(err.message).toBe( + 'jest-haste-map: the `ignorePattern` option must be a RegExp', + ); + } + }); + it('builds a haste map on a fresh cache', () => { // Include these files in the map mockFs[ From fd452e8ee6d9a3aef887c359639a5479d2df688b Mon Sep 17 00:00:00 2001 From: komtaki Date: Thu, 1 Oct 2020 10:19:39 +0900 Subject: [PATCH 6/7] Remove old test of ignorePattern function --- .../jest-haste-map/src/__tests__/index.test.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index 533b684d55e7..328d274dafe8 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -330,21 +330,6 @@ describe('HasteMap', () => { }); }); - it('ignores vcs directories with ignore pattern function', () => { - const config = {...defaultConfig, ignorePattern: f => /Kiwi/.test(f)}; - mockFs[path.join('/', 'project', 'fruits', 'Kiwi.js')] = ` - // Kiwi! - `; - - mockFs[path.join('/', 'project', 'fruits', '.git', 'fruit-history.js')] = ` - // test - `; - return new HasteMap(config).build().then(({hasteFS}) => { - expect(hasteFS.matchFiles(/Kiwi/)).toEqual([]); - expect(hasteFS.matchFiles('.git')).toEqual([]); - }); - }); - it('warn on ignore pattern except for regex', () => { const config = {ignorePattern: 'Kiwi', ...defaultConfig}; mockFs['/project/fruits/Kiwi.js'] = ` From 90e024c6214ccbda32f9207025dd3c4d11c2b268 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 5 Dec 2020 16:27:39 +0100 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 980498d53b72..1f4c8f4ce01a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,7 +170,8 @@ - `[jest-globals]` Fix lifecycle hook function types ([#10480](https://github.com/facebook/jest/pull/10480)) - `[jest-runtime]` Remove usage of `vm.compileFunction` due to a performance issue ([#10586](https://github.com/facebook/jest/pull/10586)) -### Performance +### Chore & Maintenance + - `[jest-resolve]` Replace read-pkg-up with escalade package ([10558](https://github.com/facebook/jest/pull/10558)) - `[jest-environment-jsdom]` Update jsdom to 16.4.0 ([10578](https://github.com/facebook/jest/pull/10578))