From 2789694e7c229be9521b0d9b11ba25688f5ea7aa Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Mon, 12 Apr 2021 12:56:49 +0000 Subject: [PATCH 1/4] fix(util): Replace micromatch with picomatch to fix issues with negated globs --- package.json | 2 +- packages/jest-util/package.json | 5 +-- .../src/__tests__/globsToMatcher.test.ts | 26 +++++++++++++++ packages/jest-util/src/globsToMatcher.ts | 18 +++++----- yarn.lock | 33 ++++++++++++++++--- 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 2ce3d6be52db..6ad7df4a3a37 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "jest-watch-typeahead": "^0.6.0", "jquery": "^3.2.1", "lerna": "^4.0.0", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "mlh-tsd": "^0.14.1", "mock-fs": "^4.4.1", "node-notifier": "^9.0.0", diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index f066cee9867f..e1be9992689b 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -19,12 +19,13 @@ "chalk": "^4.0.0", "graceful-fs": "^4.2.4", "is-ci": "^3.0.0", - "micromatch": "^4.0.2" + "picomatch": "^2.2.3" }, "devDependencies": { "@types/graceful-fs": "^4.1.2", "@types/is-ci": "^2.0.0", - "@types/micromatch": "^4.0.0" + "@types/micromatch": "^4.0.1", + "@types/picomatch": "^2.2.1" }, "engines": { "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" diff --git a/packages/jest-util/src/__tests__/globsToMatcher.test.ts b/packages/jest-util/src/__tests__/globsToMatcher.test.ts index f676d7ae0360..272996da2d31 100644 --- a/packages/jest-util/src/__tests__/globsToMatcher.test.ts +++ b/packages/jest-util/src/__tests__/globsToMatcher.test.ts @@ -70,3 +70,29 @@ it('works like micromatch with empty globs', () => { micromatch(['some-module.test.js'], globs).length > 0, ); }); + +it('works like micromatch with pure negated extglobs', () => { + const globs = ['**/*.js', '!(some-module.test.js)']; + const matcher = globsToMatcher(globs); + + expect(matcher('some-module.js')).toBe( + micromatch(['some-module.js'], globs).length > 0, + ); + + expect(matcher('some-module.test.js')).toBe( + micromatch(['some-module.test.js'], globs).length > 0, + ); +}); + +it('works like micromatch with negated extglobs', () => { + const globs = ['**/*.js', '!(tests|coverage)/*.js']; + const matcher = globsToMatcher(globs); + + expect(matcher('some-module.js')).toBe( + micromatch(['some-module.js'], globs).length > 0, + ); + + expect(matcher('tests/some-module.test.js')).toBe( + micromatch(['tests/some-module.test.js'], globs).length > 0, + ); +}); diff --git a/packages/jest-util/src/globsToMatcher.ts b/packages/jest-util/src/globsToMatcher.ts index ad4285825efe..cd34158a4d12 100644 --- a/packages/jest-util/src/globsToMatcher.ts +++ b/packages/jest-util/src/globsToMatcher.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import micromatch = require('micromatch'); +import picomatch = require('picomatch'); import type {Config} from '@jest/types'; import replacePathSepForGlob from './replacePathSepForGlob'; @@ -16,15 +16,15 @@ const globsToMatchersMap = new Map< {isMatch: Matcher; negated: boolean} >(); -const micromatchOptions = {dot: true}; +const picomatchOptions = {dot: true}; /** * Converts a list of globs into a function that matches a path against the * globs. * - * Every time micromatch is called, it will parse the glob strings and turn + * Every time picomatch is called, it will parse the glob strings and turn * them into regexp instances. Instead of calling micromatch repeatedly with - * the same globs, we can use this function which will build the micromatch + * the same globs, we can use this function which will build the picomatch * matchers ahead of time and then have an optimized path for determining * whether an individual path matches. * @@ -44,13 +44,13 @@ export default function globsToMatcher(globs: Array): Matcher { const matchers = globs.map(glob => { if (!globsToMatchersMap.has(glob)) { - // Matchers that are negated have different behavior than matchers that - // are not negated, so we need to store this information ahead of time. - const {negated} = micromatch.scan(glob, micromatchOptions); + const isMatch = picomatch(glob, picomatchOptions, true); const matcher = { - isMatch: micromatch.matcher(glob, micromatchOptions), - negated, + isMatch, + // Matchers that are negated have different behavior than matchers that + // are not negated, so we need to store this information ahead of time. + negated: isMatch.state.negated || !!isMatch.state.negatedExtglob, }; globsToMatchersMap.set(glob, matcher); diff --git a/yarn.lock b/yarn.lock index 7a76949be55b..b9c23ab528b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2581,7 +2581,7 @@ __metadata: jest-watch-typeahead: ^0.6.0 jquery: ^3.2.1 lerna: ^4.0.0 - micromatch: ^4.0.2 + micromatch: ^4.0.4 mlh-tsd: ^0.14.1 mock-fs: ^4.4.1 node-notifier: ^9.0.0 @@ -4690,7 +4690,7 @@ __metadata: languageName: node linkType: hard -"@types/micromatch@npm:^4.0.0": +"@types/micromatch@npm:^4.0.0, @types/micromatch@npm:^4.0.1": version: 4.0.1 resolution: "@types/micromatch@npm:4.0.1" dependencies: @@ -4780,6 +4780,13 @@ __metadata: languageName: node linkType: hard +"@types/picomatch@npm:^2.2.1": + version: 2.2.1 + resolution: "@types/picomatch@npm:2.2.1" + checksum: 6da30597711a4f8688a04d07cfa462324c4e62d96d9b6075d5da580c1512b818af3c574cde3a60f36dd5d4d6c8186cb6d42ad85e8d8fa204176246dda641251d + languageName: node + linkType: hard + "@types/prettier@npm:*, @types/prettier@npm:^2.0.0, @types/prettier@npm:^2.1.5": version: 2.2.2 resolution: "@types/prettier@npm:2.2.2" @@ -14008,12 +14015,13 @@ fsevents@^1.2.7: "@jest/types": ^27.0.0-next.7 "@types/graceful-fs": ^4.1.2 "@types/is-ci": ^2.0.0 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 "@types/node": "*" + "@types/picomatch": ^2.2.1 chalk: ^4.0.0 graceful-fs: ^4.2.4 is-ci: ^3.0.0 - micromatch: ^4.0.2 + picomatch: ^2.2.3 languageName: unknown linkType: soft @@ -15872,6 +15880,16 @@ fsevents@^1.2.7: languageName: node linkType: hard +"micromatch@npm:^4.0.4": + version: 4.0.4 + resolution: "micromatch@npm:4.0.4" + dependencies: + braces: ^3.0.1 + picomatch: ^2.2.3 + checksum: bc522ad93c086aa176f50fea2dc8060a8f7d7a621c811cf9ba02a1912577cc100190508166d721231465f10a575a40ec8a1bffc23bbc2c0108fcbf02e4be04ed + languageName: node + linkType: hard + "miller-rabin@npm:^4.0.0": version: 4.0.1 resolution: "miller-rabin@npm:4.0.1" @@ -17866,6 +17884,13 @@ fsevents@^1.2.7: languageName: node linkType: hard +"picomatch@npm:^2.2.3": + version: 2.2.3 + resolution: "picomatch@npm:2.2.3" + checksum: f8c9323bc3b21ff448e81dd32277135d781abae5d53a1415d69a4ce6317a2c11404d449c550110b8fa402c07d5e80ff0e2657f263a312517cc809e9010d25791 + languageName: node + linkType: hard + "pify@npm:^2.0.0, pify@npm:^2.3.0": version: 2.3.0 resolution: "pify@npm:2.3.0" From 6c9c3ee5685869e66886f733a3302d4a62f273d0 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Mon, 12 Apr 2021 16:46:23 +0200 Subject: [PATCH 2/4] Update packages/jest-util/src/globsToMatcher.ts Co-authored-by: Simen Bekkhus --- packages/jest-util/src/globsToMatcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-util/src/globsToMatcher.ts b/packages/jest-util/src/globsToMatcher.ts index cd34158a4d12..ceb8d62c3f07 100644 --- a/packages/jest-util/src/globsToMatcher.ts +++ b/packages/jest-util/src/globsToMatcher.ts @@ -23,7 +23,7 @@ const picomatchOptions = {dot: true}; * globs. * * Every time picomatch is called, it will parse the glob strings and turn - * them into regexp instances. Instead of calling micromatch repeatedly with + * them into regexp instances. Instead of calling picomatch repeatedly with * the same globs, we can use this function which will build the picomatch * matchers ahead of time and then have an optimized path for determining * whether an individual path matches. From 2edce182aa0283e2e5af0135b99ed40d914a5cc7 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Mon, 12 Apr 2021 16:47:32 +0000 Subject: [PATCH 3/4] Deduplicate, allign versions, patch for type --- package.json | 1 + packages/jest-config/package.json | 4 +- packages/jest-core/package.json | 4 +- packages/jest-haste-map/package.json | 4 +- packages/jest-message-util/package.json | 4 +- packages/jest-transform/package.json | 4 +- patches/@types__picomatch.patch | 58 +++++++++++++++++++++++++ yarn.lock | 52 +++++++++------------- 8 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 patches/@types__picomatch.patch diff --git a/package.json b/package.json index 6ad7df4a3a37..cf65833cffd9 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,7 @@ "babel-jest": "workspace:*", "jest": "workspace:*", "jest-environment-node": "workspace:*", + "@types/picomatch": "patch:@types/picomatch@2.2.1#./patches/@types__picomatch.patch", "react-native": "patch:react-native@0.64.0#./patches/react-native.patch" } } diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 052609eb9dde..e6a957989452 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -39,14 +39,14 @@ "jest-resolve": "^27.0.0-next.7", "jest-util": "^27.0.0-next.7", "jest-validate": "^27.0.0-next.7", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "pretty-format": "^27.0.0-next.7" }, "devDependencies": { "@types/babel__core": "^7.0.4", "@types/glob": "^7.1.1", "@types/graceful-fs": "^4.1.3", - "@types/micromatch": "^4.0.0", + "@types/micromatch": "^4.0.1", "jest-snapshot-serializer-raw": "^1.1.0", "strip-ansi": "^6.0.0", "ts-node": "^9.0.0", diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 02c5f481e282..49ce1c4e124b 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -33,7 +33,7 @@ "jest-util": "^27.0.0-next.7", "jest-validate": "^27.0.0-next.7", "jest-watcher": "^27.0.0-next.7", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "p-each-series": "^2.1.0", "rimraf": "^3.0.0", "slash": "^3.0.0", @@ -44,7 +44,7 @@ "@jest/test-utils": "^27.0.0-next.7", "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", - "@types/micromatch": "^4.0.0", + "@types/micromatch": "^4.0.1", "@types/rimraf": "^3.0.0", "jest-snapshot-serializer-raw": "^1.1.0" }, diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index e49b9007df11..51fe809fcbef 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -24,14 +24,14 @@ "jest-serializer": "^27.0.0-next.0", "jest-util": "^27.0.0-next.7", "jest-worker": "^27.0.0-next.7", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "walker": "^1.0.7" }, "devDependencies": { "@jest/test-utils": "^27.0.0-next.7", "@types/anymatch": "^1.3.1", "@types/fb-watchman": "^2.0.0", - "@types/micromatch": "^4.0.0", + "@types/micromatch": "^4.0.1", "jest-snapshot-serializer-raw": "^1.1.0", "slash": "^3.0.0" }, diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index c63990882e3a..c6cfff81b59a 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -22,7 +22,7 @@ "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "pretty-format": "^27.0.0-next.7", "slash": "^3.0.0", "stack-utils": "^2.0.3" @@ -30,7 +30,7 @@ "devDependencies": { "@types/babel__code-frame": "^7.0.0", "@types/graceful-fs": "^4.1.3", - "@types/micromatch": "^4.0.0" + "@types/micromatch": "^4.0.1" }, "publishConfig": { "access": "public" diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index 91812127fd10..85788e4ab580 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -24,7 +24,7 @@ "jest-haste-map": "^27.0.0-next.7", "jest-regex-util": "^27.0.0-next.0", "jest-util": "^27.0.0-next.7", - "micromatch": "^4.0.2", + "micromatch": "^4.0.4", "pirates": "^4.0.1", "slash": "^3.0.0", "source-map": "^0.6.1", @@ -36,7 +36,7 @@ "@types/convert-source-map": "^1.5.1", "@types/fast-json-stable-stringify": "^2.0.0", "@types/graceful-fs": "^4.1.2", - "@types/micromatch": "^4.0.0", + "@types/micromatch": "^4.0.1", "@types/write-file-atomic": "^3.0.0", "dedent": "^0.7.0", "jest-snapshot-serializer-raw": "^1.1.0" diff --git a/patches/@types__picomatch.patch b/patches/@types__picomatch.patch new file mode 100644 index 000000000000..c972fa47b255 --- /dev/null +++ b/patches/@types__picomatch.patch @@ -0,0 +1,58 @@ +diff --git a/index.d.ts b/index.d.ts +index 96e0ba2d81973..6efe4cebfcff2 100644 +--- a/index.d.ts ++++ b/index.d.ts +@@ -1,6 +1,7 @@ + // Type definitions for picomatch 2.2 + // Project: https://github.com/micromatch/picomatch +-// Definitions by: Patrick ++// Definitions by: Patrick ++// Daniel Tschinder + // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + // Minimum TypeScript Version: 3.0 + +@@ -18,8 +19,31 @@ interface PicomatchOptions { + format?: (input: string) => string; + } + ++interface ParseState { ++ input: string; ++ index: number; ++ start: number; ++ dot: boolean; ++ consumed: string; ++ output: string; ++ prefix: string; ++ backtrack: boolean; ++ negated: boolean; ++ negatedExtglob?: boolean; ++ brackets: number; ++ braces: number; ++ parens: number; ++ quotes: number; ++ globstar: boolean; ++ tokens: Array>; ++} ++ + type Matcher = (test: string) => boolean; + ++interface MatcherWithState extends Matcher { ++ state: ParseState; ++} ++ + interface Result { + glob: string; + state: any; +@@ -51,7 +75,11 @@ interface Picomatch { + * @return Returns a matcher function. + * @api public + */ +- (glob: string | string[], options?: PicomatchOptions, returnState?: boolean): Matcher; ++ ( ++ glob: string | string[], ++ options?: PicomatchOptions, ++ returnState?: T ++ ): T extends true ? MatcherWithState : Matcher; + + test( + input: string, \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b9c23ab528b7..41586cd7b843 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2439,7 +2439,7 @@ __metadata: "@jest/types": ^27.0.0-next.7 "@types/exit": ^0.1.30 "@types/graceful-fs": ^4.1.2 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 "@types/node": "*" "@types/rimraf": ^3.0.0 ansi-escapes: ^4.2.1 @@ -2461,7 +2461,7 @@ __metadata: jest-util: ^27.0.0-next.7 jest-validate: ^27.0.0-next.7 jest-watcher: ^27.0.0-next.7 - micromatch: ^4.0.2 + micromatch: ^4.0.4 p-each-series: ^2.1.0 rimraf: ^3.0.0 slash: ^3.0.0 @@ -2727,7 +2727,7 @@ __metadata: "@types/convert-source-map": ^1.5.1 "@types/fast-json-stable-stringify": ^2.0.0 "@types/graceful-fs": ^4.1.2 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 "@types/write-file-atomic": ^3.0.0 babel-plugin-istanbul: ^6.0.0 chalk: ^4.0.0 @@ -2739,7 +2739,7 @@ __metadata: jest-regex-util: ^27.0.0-next.0 jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^27.0.0-next.7 - micromatch: ^4.0.2 + micromatch: ^4.0.4 pirates: ^4.0.1 slash: ^3.0.0 source-map: ^0.6.1 @@ -4690,7 +4690,7 @@ __metadata: languageName: node linkType: hard -"@types/micromatch@npm:^4.0.0, @types/micromatch@npm:^4.0.1": +"@types/micromatch@npm:^4.0.1": version: 4.0.1 resolution: "@types/micromatch@npm:4.0.1" dependencies: @@ -4780,13 +4780,20 @@ __metadata: languageName: node linkType: hard -"@types/picomatch@npm:^2.2.1": +"@types/picomatch@2.2.1": version: 2.2.1 resolution: "@types/picomatch@npm:2.2.1" checksum: 6da30597711a4f8688a04d07cfa462324c4e62d96d9b6075d5da580c1512b818af3c574cde3a60f36dd5d4d6c8186cb6d42ad85e8d8fa204176246dda641251d languageName: node linkType: hard +"@types/picomatch@patch:@types/picomatch@2.2.1#./patches/@types__picomatch.patch::locator=%40jest%2Fmonorepo%40workspace%3A.": + version: 2.2.1 + resolution: "@types/picomatch@patch:@types/picomatch@npm%3A2.2.1#./patches/@types__picomatch.patch::version=2.2.1&hash=cf34c6&locator=%40jest%2Fmonorepo%40workspace%3A." + checksum: 4481f311dcdb469cd5bbed5c6f653cb9f60654af2f5fcf63b9a58801a41912335eb254252e6f2b18ab28edcd6f8aee54b5453aea15775705c78f5bc10b7fff76 + languageName: node + linkType: hard + "@types/prettier@npm:*, @types/prettier@npm:^2.0.0, @types/prettier@npm:^2.1.5": version: 2.2.2 resolution: "@types/prettier@npm:2.2.2" @@ -13457,7 +13464,7 @@ fsevents@^1.2.7: "@types/babel__core": ^7.0.4 "@types/glob": ^7.1.1 "@types/graceful-fs": ^4.1.3 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 babel-jest: ^27.0.0-next.7 chalk: ^4.0.0 deepmerge: ^4.2.2 @@ -13473,7 +13480,7 @@ fsevents@^1.2.7: jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^27.0.0-next.7 jest-validate: ^27.0.0-next.7 - micromatch: ^4.0.2 + micromatch: ^4.0.4 pretty-format: ^27.0.0-next.7 strip-ansi: ^6.0.0 ts-node: ^9.0.0 @@ -13600,7 +13607,7 @@ fsevents@^1.2.7: "@types/anymatch": ^1.3.1 "@types/fb-watchman": ^2.0.0 "@types/graceful-fs": ^4.1.2 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 "@types/node": "*" anymatch: ^3.0.3 fb-watchman: ^2.0.0 @@ -13611,7 +13618,7 @@ fsevents@^1.2.7: jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^27.0.0-next.7 jest-worker: ^27.0.0-next.7 - micromatch: ^4.0.2 + micromatch: ^4.0.4 slash: ^3.0.0 walker: ^1.0.7 dependenciesMeta: @@ -13716,11 +13723,11 @@ fsevents@^1.2.7: "@jest/types": ^27.0.0-next.7 "@types/babel__code-frame": ^7.0.0 "@types/graceful-fs": ^4.1.3 - "@types/micromatch": ^4.0.0 + "@types/micromatch": ^4.0.1 "@types/stack-utils": ^2.0.0 chalk: ^4.0.0 graceful-fs: ^4.2.4 - micromatch: ^4.0.2 + micromatch: ^4.0.4 pretty-format: ^27.0.0-next.7 slash: ^3.0.0 stack-utils: ^2.0.3 @@ -15870,17 +15877,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"micromatch@npm:^4.0.2": - version: 4.0.2 - resolution: "micromatch@npm:4.0.2" - dependencies: - braces: ^3.0.1 - picomatch: ^2.0.5 - checksum: 0cb0e11d647cbb65e398a0a8a1340a7fb751ae2722346219c435704cfac8b3275a94a6464236fe867f52ad46a24046d3bc4ac11b3d21ddb73bc44e27cf1e4904 - languageName: node - linkType: hard - -"micromatch@npm:^4.0.4": +"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4": version: 4.0.4 resolution: "micromatch@npm:4.0.4" dependencies: @@ -17877,14 +17874,7 @@ fsevents@^1.2.7: languageName: node linkType: hard -"picomatch@npm:^2.0.4, picomatch@npm:^2.0.5, picomatch@npm:^2.2.1, picomatch@npm:^2.2.2": - version: 2.2.2 - resolution: "picomatch@npm:2.2.2" - checksum: 20fa75e0a58b39d83425b3db68744d5f6f361fd4fd66ec7745d884036d502abba0d553a637703af79939b844164b13e60eea339ccb043d7fbd74c3da2592b864 - languageName: node - linkType: hard - -"picomatch@npm:^2.2.3": +"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.2, picomatch@npm:^2.2.3": version: 2.2.3 resolution: "picomatch@npm:2.2.3" checksum: f8c9323bc3b21ff448e81dd32277135d781abae5d53a1415d69a4ce6317a2c11404d449c550110b8fa402c07d5e80ff0e2657f263a312517cc809e9010d25791 From 9f7a26b94cfa9bf6923c7b46d1cc5fc58c502e03 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Mon, 12 Apr 2021 20:43:17 +0000 Subject: [PATCH 4/4] Use update picomatch types --- package.json | 1 - packages/jest-util/package.json | 2 +- patches/@types__picomatch.patch | 58 --------------------------------- yarn.lock | 17 +++------- 4 files changed, 6 insertions(+), 72 deletions(-) delete mode 100644 patches/@types__picomatch.patch diff --git a/package.json b/package.json index cf65833cffd9..6ad7df4a3a37 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,6 @@ "babel-jest": "workspace:*", "jest": "workspace:*", "jest-environment-node": "workspace:*", - "@types/picomatch": "patch:@types/picomatch@2.2.1#./patches/@types__picomatch.patch", "react-native": "patch:react-native@0.64.0#./patches/react-native.patch" } } diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index e1be9992689b..3ce1a490e733 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -25,7 +25,7 @@ "@types/graceful-fs": "^4.1.2", "@types/is-ci": "^2.0.0", "@types/micromatch": "^4.0.1", - "@types/picomatch": "^2.2.1" + "@types/picomatch": "^2.2.2" }, "engines": { "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" diff --git a/patches/@types__picomatch.patch b/patches/@types__picomatch.patch deleted file mode 100644 index c972fa47b255..000000000000 --- a/patches/@types__picomatch.patch +++ /dev/null @@ -1,58 +0,0 @@ -diff --git a/index.d.ts b/index.d.ts -index 96e0ba2d81973..6efe4cebfcff2 100644 ---- a/index.d.ts -+++ b/index.d.ts -@@ -1,6 +1,7 @@ - // Type definitions for picomatch 2.2 - // Project: https://github.com/micromatch/picomatch --// Definitions by: Patrick -+// Definitions by: Patrick -+// Daniel Tschinder - // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - // Minimum TypeScript Version: 3.0 - -@@ -18,8 +19,31 @@ interface PicomatchOptions { - format?: (input: string) => string; - } - -+interface ParseState { -+ input: string; -+ index: number; -+ start: number; -+ dot: boolean; -+ consumed: string; -+ output: string; -+ prefix: string; -+ backtrack: boolean; -+ negated: boolean; -+ negatedExtglob?: boolean; -+ brackets: number; -+ braces: number; -+ parens: number; -+ quotes: number; -+ globstar: boolean; -+ tokens: Array>; -+} -+ - type Matcher = (test: string) => boolean; - -+interface MatcherWithState extends Matcher { -+ state: ParseState; -+} -+ - interface Result { - glob: string; - state: any; -@@ -51,7 +75,11 @@ interface Picomatch { - * @return Returns a matcher function. - * @api public - */ -- (glob: string | string[], options?: PicomatchOptions, returnState?: boolean): Matcher; -+ ( -+ glob: string | string[], -+ options?: PicomatchOptions, -+ returnState?: T -+ ): T extends true ? MatcherWithState : Matcher; - - test( - input: string, \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 41586cd7b843..0938f5bdd6f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4780,17 +4780,10 @@ __metadata: languageName: node linkType: hard -"@types/picomatch@2.2.1": - version: 2.2.1 - resolution: "@types/picomatch@npm:2.2.1" - checksum: 6da30597711a4f8688a04d07cfa462324c4e62d96d9b6075d5da580c1512b818af3c574cde3a60f36dd5d4d6c8186cb6d42ad85e8d8fa204176246dda641251d - languageName: node - linkType: hard - -"@types/picomatch@patch:@types/picomatch@2.2.1#./patches/@types__picomatch.patch::locator=%40jest%2Fmonorepo%40workspace%3A.": - version: 2.2.1 - resolution: "@types/picomatch@patch:@types/picomatch@npm%3A2.2.1#./patches/@types__picomatch.patch::version=2.2.1&hash=cf34c6&locator=%40jest%2Fmonorepo%40workspace%3A." - checksum: 4481f311dcdb469cd5bbed5c6f653cb9f60654af2f5fcf63b9a58801a41912335eb254252e6f2b18ab28edcd6f8aee54b5453aea15775705c78f5bc10b7fff76 +"@types/picomatch@npm:^2.2.2": + version: 2.2.2 + resolution: "@types/picomatch@npm:2.2.2" + checksum: f55b30a9c532bd701f502132127c905739acd53cd5c0e5b3ef4b6bdbe7387c028f44cd3e8dd5b6df584ff57d0ca0dea22c2433b2fe137265a87c4893aefa8a61 languageName: node linkType: hard @@ -14024,7 +14017,7 @@ fsevents@^1.2.7: "@types/is-ci": ^2.0.0 "@types/micromatch": ^4.0.1 "@types/node": "*" - "@types/picomatch": ^2.2.1 + "@types/picomatch": ^2.2.2 chalk: ^4.0.0 graceful-fs: ^4.2.4 is-ci: ^3.0.0