From fdb05e811cec483c24b3211990d37d1ee78c72ac Mon Sep 17 00:00:00 2001 From: Rajat Date: Sun, 14 Nov 2021 23:14:29 +0530 Subject: [PATCH 1/4] replaced substr --- packages/jest-config/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-config/src/utils.ts b/packages/jest-config/src/utils.ts index 869e60897d7e..9958f6b6bcaf 100644 --- a/packages/jest-config/src/utils.ts +++ b/packages/jest-config/src/utils.ts @@ -65,7 +65,7 @@ export const replaceRootDirInPath = ( return path.resolve( rootDir, - path.normalize('./' + filePath.substr(''.length)), + path.normalize('./' + filePath.substring(''.length)), ); }; From b5a69e26a29fc4b148adcae3ad2c7abd50283aee Mon Sep 17 00:00:00 2001 From: Rajat Date: Sun, 14 Nov 2021 23:15:18 +0530 Subject: [PATCH 2/4] replaced substr --- packages/jest-haste-map/src/lib/fast_path.ts | 2 +- packages/jest-haste-map/src/worker.ts | 2 +- packages/jest-snapshot/src/index.ts | 2 +- packages/jest-transform/src/ScriptTransformer.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/jest-haste-map/src/lib/fast_path.ts b/packages/jest-haste-map/src/lib/fast_path.ts index 39e3e1812387..ea1d0c11ef8d 100644 --- a/packages/jest-haste-map/src/lib/fast_path.ts +++ b/packages/jest-haste-map/src/lib/fast_path.ts @@ -10,7 +10,7 @@ import * as path from 'path'; // rootDir and filename must be absolute paths (resolved) export function relative(rootDir: string, filename: string): string { return filename.indexOf(rootDir + path.sep) === 0 - ? filename.substr(rootDir.length + 1) + ? filename.substring(rootDir.length + 1) : path.relative(rootDir, filename); } diff --git a/packages/jest-haste-map/src/worker.ts b/packages/jest-haste-map/src/worker.ts index 7422bb5643fc..4a53879e6ae4 100644 --- a/packages/jest-haste-map/src/worker.ts +++ b/packages/jest-haste-map/src/worker.ts @@ -63,7 +63,7 @@ export async function worker(data: WorkerMessage): Promise { } catch (err: any) { throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`); } - } else if (!blacklist.has(filePath.substr(filePath.lastIndexOf('.')))) { + } else if (!blacklist.has(filePath.substring(filePath.lastIndexOf('.')))) { // Process a random file that is returned as a MODULE. if (hasteImpl) { id = hasteImpl.getHasteName(filePath); diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index d9c7fed4dc38..58bae0a9d0b8 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -99,7 +99,7 @@ function stripAddedIndentation(inlineSnapshot: string) { return inlineSnapshot; } - lines[i] = lines[i].substr(indentation.length); + lines[i] = lines[i].substring(indentation.length); } } diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index b643eaf91857..7e17f65822e5 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -876,9 +876,9 @@ function readCodeCacheFile(cachePath: Config.Path): string | null { if (content == null) { return null; } - const code = content.substr(33); + const code = content.substring(33); const checksum = createHash('md5').update(code).digest('hex'); - if (checksum === content.substr(0, 32)) { + if (checksum === content.substring(0, 32)) { return code; } return null; From 62e8179f697302fd0c588d9f2444219ce203e8ac Mon Sep 17 00:00:00 2001 From: Rajat Date: Thu, 18 Nov 2021 20:03:52 +0530 Subject: [PATCH 3/4] update changelog.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ac4d97d3e95..45275a5fe3aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999)) - `[jest-environment-jsdom]` Do not reset the global.document too early on teardown ([#11871](https://github.com/facebook/jest/pull/11871)) - `[jest-transform]` Improve error and warning messages ([#11998](https://github.com/facebook/jest/pull/11998)) +- `[jest-config, jest-haste-map, jest-snapshot, jest-transform]` replaced string substr(deprecated) method with substring ([#12066](https://github.com/facebook/jest/pull/12066)) + ### Chore & Maintenance From bb4b24dc660411b0f406be4ad4b0c36d6f22fb81 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 18 Nov 2021 16:12:29 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45275a5fe3aa..388e3585043e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,11 @@ - `[jest-environment-jsdom]` Add `@types/jsdom` dependency ([#11999](https://github.com/facebook/jest/pull/11999)) - `[jest-environment-jsdom]` Do not reset the global.document too early on teardown ([#11871](https://github.com/facebook/jest/pull/11871)) - `[jest-transform]` Improve error and warning messages ([#11998](https://github.com/facebook/jest/pull/11998)) -- `[jest-config, jest-haste-map, jest-snapshot, jest-transform]` replaced string substr(deprecated) method with substring ([#12066](https://github.com/facebook/jest/pull/12066)) - ### Chore & Maintenance +- `[*]` Replaced `substr` method with `substring` ([#12066](https://github.com/facebook/jest/pull/12066)) + ### Performance ## 27.3.1