From 9fd02eee7123ed58c942b411243bbc8167ccdb34 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Tue, 17 Sep 2024 15:37:57 -0400 Subject: [PATCH] chore(ui): Upgrade TypeScript 5.6.2 plus types devDependencies in ui (#12709) --- ui/apps/platform/package-lock.json | 63 ++++++------------- ui/apps/platform/package.json | 13 ++-- .../src/Containers/Collections/errorUtils.ts | 4 -- .../WorkloadCves/Tables/table.utils.ts | 9 +-- ui/apps/platform/tsconfig.json | 2 +- 5 files changed, 33 insertions(+), 58 deletions(-) diff --git a/ui/apps/platform/package-lock.json b/ui/apps/platform/package-lock.json index 142b6a0002263..39d9921c97335 100644 --- a/ui/apps/platform/package-lock.json +++ b/ui/apps/platform/package-lock.json @@ -106,11 +106,11 @@ "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", - "@types/jest": "^29.5.12", - "@types/lodash": "^4.17.4", + "@types/jest": "^29.5.13", + "@types/lodash": "^4.17.7", "@types/pluralize": "^0.0.33", - "@types/qs": "^6.9.15", - "@types/react": "^18.3.3", + "@types/qs": "^6.9.16", + "@types/react": "^18.3.6", "@types/react-dom": "^18.3.0", "@types/react-redux": "^7.1.33", "@types/segment-analytics": "^0.0.38", @@ -147,7 +147,7 @@ "redux-saga-test-plan": "^3.7.0", "tailwindcss": "^2.0.3", "ts-jest": "^29.2.5", - "typescript": "^5.5.4" + "typescript": "^5.6.2" }, "engines": { "node": ">=18.0.0" @@ -4911,9 +4911,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.12", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", - "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", + "version": "29.5.13", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.13.tgz", + "integrity": "sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -4943,9 +4943,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-AwO2SVjuBwBZ46cYQEilUVn+ILc= sha512-wYCP26ZLxaT3R39kiN2+HcJ4kTd3U1waI/cY7ivWYqFP6pW3ZNpvi6Wd6PHZx7T/t8z0vlkXMg3QYLa7DZ/IJQ==", + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", "dev": true }, "node_modules/@types/mime": { @@ -4991,9 +4991,9 @@ "dev": true }, "node_modules/@types/qs": { - "version": "6.9.15", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", - "integrity": "sha1-rd6KBg7JwwWoLeG6vBBW5zvWTc4= sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", + "version": "6.9.16", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.16.tgz", + "integrity": "sha512-7i+zxXdPD0T4cKDuxCUXJ4wHcsJLwENa6Z3dCu8cfCK743OGy5Nu1RmAGqDPsoTDINVEcdXKRvR/zre+P2Ku1A==", "dev": true }, "node_modules/@types/raf": { @@ -5009,9 +5009,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.3.3", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", - "integrity": "sha1-lnkCCJUxiwkV16OrAE2S0zN1xF8= sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", + "version": "18.3.6", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.6.tgz", + "integrity": "sha512-CnGaRYNu2iZlkGXGrOYtdg5mLK8neySj0woZ4e2wF/eli2E6Sazmq5X+Nrj6OBrrFVQfJWTUFeqAzoRhWQXYvg==", "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -19882,18 +19882,6 @@ "strip-ansi": "^6.0.1" } }, - "node_modules/renderkid/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha1-nibGPTD1NEPpSJSVshBdN7Z6hdk= sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/request-progress": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-3.0.0.tgz", @@ -21062,17 +21050,6 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc= sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, - "node_modules/string-width/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha1-nibGPTD1NEPpSJSVshBdN7Z6hdk= sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/string.prototype.matchall": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz", @@ -22240,9 +22217,9 @@ } }, "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/ui/apps/platform/package.json b/ui/apps/platform/package.json index f001d5d771546..a37a45089307b 100644 --- a/ui/apps/platform/package.json +++ b/ui/apps/platform/package.json @@ -102,6 +102,7 @@ "test-watch": "react-app-rewired test", "lint": "eslint --quiet .", "lint:fix": "eslint --fix --quiet .", + "tsc": "tsc", "cypress-open": "./scripts/cypress.sh open --config defaultCommandTimeout=8000", "cypress-spec": "./scripts/cypress.sh run --spec", "cypress-component": "./scripts/cypress-component.sh open --component", @@ -128,11 +129,11 @@ "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^14.5.2", - "@types/jest": "^29.5.12", - "@types/lodash": "^4.17.4", + "@types/jest": "^29.5.13", + "@types/lodash": "^4.17.7", "@types/pluralize": "^0.0.33", - "@types/qs": "^6.9.15", - "@types/react": "^18.3.3", + "@types/qs": "^6.9.16", + "@types/react": "^18.3.6", "@types/react-dom": "^18.3.0", "@types/react-redux": "^7.1.33", "@types/segment-analytics": "^0.0.38", @@ -169,7 +170,7 @@ "redux-saga-test-plan": "^3.7.0", "tailwindcss": "^2.0.3", "ts-jest": "^29.2.5", - "typescript": "^5.5.4" + "typescript": "^5.6.2" }, "resolutions": { "@jest/types": "^29.6.3", @@ -222,7 +223,7 @@ "react-dom": "^18.0.0" }, "react-scripts": { - "typescript": "5.5.4" + "typescript": "5.6.2" }, "react-select": { "react": "^18.0.0", diff --git a/ui/apps/platform/src/Containers/Collections/errorUtils.ts b/ui/apps/platform/src/Containers/Collections/errorUtils.ts index 8f160070934e7..b274ef29098e3 100644 --- a/ui/apps/platform/src/Containers/Collections/errorUtils.ts +++ b/ui/apps/platform/src/Containers/Collections/errorUtils.ts @@ -33,10 +33,6 @@ export function parseConfigError(err: Error): CollectionConfigError { const rawMessage = getAxiosErrorMessage(err); if (/create a loop/.test(rawMessage)) { - // Work around error in TypeScript 5.5.4 upgrade because build does not use target in tsconfig.json file. - // error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const errorRegex = /^edge between '[0-9a-fA-F-]*' and '(?[0-9a-fA-F-]*)'/; const matches = errorRegex.exec(rawMessage); const loopId = matches?.groups?.loopId; diff --git a/ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Tables/table.utils.ts b/ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Tables/table.utils.ts index 2499067208b05..5cf98c5c2140d 100644 --- a/ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Tables/table.utils.ts +++ b/ui/apps/platform/src/Containers/Vulnerabilities/WorkloadCves/Tables/table.utils.ts @@ -1,6 +1,7 @@ import { gql } from '@apollo/client'; import { min } from 'date-fns'; import sortBy from 'lodash/sortBy'; +import uniq from 'lodash/uniq'; import { VulnerabilitySeverity, isVulnerabilitySeverity } from 'types/cve.proto'; import { SourceType } from 'types/image.proto'; import { ApiSortOption } from 'types/search'; @@ -265,11 +266,11 @@ export function formatVulnerabilityData( .filter((d): d is string => d !== null); const oldestDiscoveredVulnDate = min(...allDiscoveredDates); // TODO This logic is used in many places, could extract to a util - const uniqueComponents = new Set(allVulnerableComponents.map((c) => c.name)); + const uniqueComponents = uniq(allVulnerableComponents.map((c) => c.name)); const affectedComponentsText = - uniqueComponents.size === 1 - ? uniqueComponents.values().next().value - : `${uniqueComponents.size} components`; + uniqueComponents.length === 1 + ? uniqueComponents[0] + : `${uniqueComponents.length} components`; const vulnerabilityImages = images .map((img) => ({ diff --git a/ui/apps/platform/tsconfig.json b/ui/apps/platform/tsconfig.json index db6ba08c9d924..c3c1ec399b000 100644 --- a/ui/apps/platform/tsconfig.json +++ b/ui/apps/platform/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es2020", "lib": [ "dom", "dom.iterable",