Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

chore: replace vulnerable underscore with a util (#70784)

Uladzimir Havenchyk5489604670d0
diff --git a/release/bun.lock b/release/bun.lock
index b1627f89ae7..8428c8f91db 100644
--- a/release/bun.lock
+++ b/release/bun.lock
@@ -15,7 +15,6 @@
"ts-pattern": "^5.2.0",
"tsx": "^3.12.7",
"typescript": "^5.1.6",
- "underscore": "^1.13.6",
"zx": "^8.8.5",
},
"devDependencies": {
@@ -24,7 +23,6 @@
"@babel/preset-typescript": "^7.24.7",
"@types/jest": "^29.5.5",
"@types/semver": "^7.5.8",
- "@types/underscore": "^1.11.15",
"jest": "^29.7.0",
"prettier": "^3.0.2",
},
@@ -425,8 +423,6 @@
"@types/stack-utils": ["@types/[email protected]", "", {}, "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw=="],
- "@types/underscore": ["@types/[email protected]", "", {}, "sha512-HP38xE+GuWGlbSRq9WrZkousaQ7dragtZCruBVMi0oX1migFZavZ3OROKHSkNp/9ouq82zrWtZpg18jFnVN96g=="],
-
"@types/yargs": ["@types/[email protected]", "", { "dependencies": { "@types/yargs-parser": "*" } }, "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw=="],
"@types/yargs-parser": ["@types/[email protected]", "", {}, "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="],
@@ -897,8 +893,6 @@
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA=="],
- "underscore": ["[email protected]", "", {}, "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="],
-
"undici-types": ["[email protected]", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
"unicode-canonical-property-names-ecmascript": ["[email protected]", "", {}, "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ=="],
diff --git a/release/package.json b/release/package.json
index 7be4fd46214..52805118af3 100644
--- a/release/package.json
+++ b/release/package.json
@@ -29,7 +29,6 @@
"ts-pattern": "^5.2.0",
"tsx": "^3.12.7",
"typescript": "^5.1.6",
- "underscore": "^1.13.6",
"zx": "^8.8.5"
},
"devDependencies": {
@@ -38,7 +37,6 @@
"@babel/preset-typescript": "^7.24.7",
"@types/jest": "^29.5.5",
"@types/semver": "^7.5.8",
- "@types/underscore": "^1.11.15",
"jest": "^29.7.0",
"prettier": "^3.0.2"
},
diff --git a/release/src/milestones.ts b/release/src/milestones.ts
index bda1f93d3c4..d857a19a98d 100644
--- a/release/src/milestones.ts
+++ b/release/src/milestones.ts
@@ -1,7 +1,6 @@
import fs from "fs";
import { graphql } from "@octokit/graphql";
-import _ from "underscore";
import { hiddenLabels, nonUserFacingLabels } from "./constants";
import {
@@ -248,7 +247,7 @@ export async function setMilestoneForCommits({
console.log('Next milestone:', nextMilestone.title);
// figure out issue or PR
- const PRsToCheck = _.uniq(
+ const PRsToCheck = uniq(
commitMessages
.flatMap(getPRsFromCommitMessage)
.filter(isNotNull)
@@ -270,7 +269,7 @@ export async function setMilestoneForCommits({
})));
}
- const uniqueIssuesToTag = _.uniq(issuesToTag);
+ const uniqueIssuesToTag = uniq(issuesToTag);
console.log(`Tagging ${uniqueIssuesToTag.length} issues with milestone ${nextMilestone.title}`)
@@ -359,7 +358,7 @@ export async function checkMilestoneForRelease({
})));
}
- const uniqueIssues = _.uniq(issueNumbers.filter(isNotNull));
+ const uniqueIssues = uniq(issueNumbers.filter(isNotNull));
commitIssueMap[commit.sha] = uniqueIssues;
uniqueIssues.forEach(issueNumber => {
@@ -604,3 +603,7 @@ async function addIssueToProject({
{ projectV2Item { id } }
}`);
}
+
+function uniq<T>(array: T[]) {
+ return Array.from<T>(new Set(array));
+}
diff --git a/release/src/slack.ts b/release/src/slack.ts
index c3d704aea3e..aeafc37d71e 100644
--- a/release/src/slack.ts
+++ b/release/src/slack.ts
@@ -5,7 +5,7 @@ import { WebClient } from '@slack/web-api';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import fetch from 'node-fetch';
-import _ from 'underscore';
+
dayjs.extend(relativeTime);
import _githubSlackMap from "../github-slack-map.json";
@@ -79,7 +79,7 @@ export async function sendBackportReminder({
const lines = text.split("\n");
const chunkSize = Math.floor(lines.length / chunks);
- const chunkedLines = _.chunk(lines, chunkSize);
+ const chunkedLines = chunk(lines, chunkSize);
const attachments = [{
"color": "#F9841A",
@@ -545,3 +545,12 @@ export async function sendMilestoneCheckMessage({
message: fileMessage,
});
}
+
+function chunk<T>(array: T[], count: number): T[][] {
+ const result: T[][] = [];
+ let i = 0;
+ while (i < array.length) {
+ result.push(array.slice(i, (i += count)));
+ }
+ return result;
+}