From dbf537609ff714033d5f066521fdcf018f6cdc5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Thu, 5 Oct 2023 16:58:04 +0200 Subject: [PATCH 1/2] add unicorn/prefer-string-slice rule --- .eslintrc.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 73d00271b6..a7677fc95d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -52,6 +52,7 @@ module.exports = { 'unicorn/prefer-dom-node-append': 'error', 'unicorn/prefer-dom-node-dataset': 'error', 'unicorn/prefer-dom-node-remove': 'error', + 'unicorn/prefer-string-slice': 'error', 'unicorn/no-negated-condition': 'error', 'unicorn/no-array-callback-reference': 'error', 'unicorn/no-array-method-this-argument': 'error', From 192a6a6ac1a199fd114438495bac32e92f1bf371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Thu, 5 Oct 2023 17:01:52 +0200 Subject: [PATCH 2/2] lint --- test/config/jest.image.ts | 2 +- test/performance/bpmn.load.performance.test.ts | 2 +- test/performance/bpmn.navigation.performance.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/config/jest.image.ts b/test/config/jest.image.ts index a4dfa464e7..d31e8e32fb 100644 --- a/test/config/jest.image.ts +++ b/test/config/jest.image.ts @@ -32,7 +32,7 @@ const toMatchImageSnapshotWithRealSignature = toMatchImageSnapshot as (received: function computeRelativePathFromReportToSnapshots(path: string): string { path = path.replace(/\\/g, '/'); const searchedPart = 'build/test-report/e2e/'; // hard coded here, must be kept in sync with the e2e/jest.config.js - return './' + path.substring(path.indexOf(searchedPart) + searchedPart.length); + return './' + path.slice(Math.max(0, path.indexOf(searchedPart) + searchedPart.length)); } // the processing is inspired from jest-image-snapshot, but the management using a class is specific to this implementation diff --git a/test/performance/bpmn.load.performance.test.ts b/test/performance/bpmn.load.performance.test.ts index ca661a5c20..19e3948f42 100644 --- a/test/performance/bpmn.load.performance.test.ts +++ b/test/performance/bpmn.load.performance.test.ts @@ -51,7 +51,7 @@ afterAll(async () => { await metricsCollector.destroy().then(() => { try { const oldDataString = fs.readFileSync(performanceDataFilePath, 'utf8'); - const oldData = JSON.parse(oldDataString.substring('const data = '.length, oldDataString.length)) as ChartData; + const oldData = JSON.parse(oldDataString.slice('const data = '.length, oldDataString.length)) as ChartData; const data = { zoom: oldData.zoom, load: [...oldData.load, ...metricsArray], diff --git a/test/performance/bpmn.navigation.performance.test.ts b/test/performance/bpmn.navigation.performance.test.ts index 2f273d8c37..cbe6573cb3 100644 --- a/test/performance/bpmn.navigation.performance.test.ts +++ b/test/performance/bpmn.navigation.performance.test.ts @@ -76,7 +76,7 @@ afterAll(async () => { await metricsCollector.destroy().then(() => { try { const oldDataString = fs.readFileSync(performanceDataFilePath, 'utf8'); - const oldData = JSON.parse(oldDataString.substring('const data = '.length, oldDataString.length)) as ChartData; + const oldData = JSON.parse(oldDataString.slice('const data = '.length, oldDataString.length)) as ChartData; const data = { zoom: [...oldData.zoom, ...metricsArray], load: oldData.load,