From dbe1c3696f332750c515bc20b0864c789d1b52e7 Mon Sep 17 00:00:00 2001 From: Viachaslau Date: Wed, 11 Sep 2024 15:38:13 +0400 Subject: [PATCH] refactor: use `@xmldom/xmldom` 0.9.2 instead of legacy `xmldom` 0.6.0 (#404) --- client/package-lock.json | 22 +++++++++---------- client/package.json | 4 ++-- .../pages/marketplace/Partners/Partners.tsx | 5 +++-- package-lock.json | 19 ++++++++-------- package.json | 2 +- src/partners/partners.service.ts | 7 +++--- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index a7b7304f..1b3024e1 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -8,6 +8,7 @@ "name": "react-broken-crystals", "version": "0.1.0", "dependencies": { + "@xmldom/xmldom": "^0.9.2", "axios": "^1.7.7", "buffer": "^6.0.3", "file-type": "^19.5.0", @@ -17,8 +18,7 @@ "react-datepicker": "^7.3.0", "react-dom": "^18.3.1", "react-owl-carousel": "^2.3.3", - "react-router-dom": "^6.26.2", - "xmldom": "^0.6.0" + "react-router-dom": "^6.26.2" }, "devDependencies": { "@eslint/js": "^9.10.0", @@ -1591,6 +1591,15 @@ "vite": "^4 || ^5" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.2.tgz", + "integrity": "sha512-afP3lpLtalPxgNGU4bxlsru4wSDsZwdSFKnHs6PR0q3KIEWWcAlBqAdx4aWlVtP1gV1FBWlJ3d0MgaRRdj/ucA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -5673,15 +5682,6 @@ "dev": true, "license": "ISC" }, - "node_modules/xmldom": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz", - "integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg==", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", diff --git a/client/package.json b/client/package.json index 58fd8f22..6695797f 100644 --- a/client/package.json +++ b/client/package.json @@ -16,6 +16,7 @@ "lint": "eslint . --report-unused-disable-directives --max-warnings 0" }, "dependencies": { + "@xmldom/xmldom": "^0.9.2", "axios": "^1.7.7", "buffer": "^6.0.3", "file-type": "^19.5.0", @@ -25,8 +26,7 @@ "react-datepicker": "^7.3.0", "react-dom": "^18.3.1", "react-owl-carousel": "^2.3.3", - "react-router-dom": "^6.26.2", - "xmldom": "^0.6.0" + "react-router-dom": "^6.26.2" }, "devDependencies": { "@eslint/js": "^9.10.0", diff --git a/client/src/pages/marketplace/Partners/Partners.tsx b/client/src/pages/marketplace/Partners/Partners.tsx index 34a12502..6f7e63ad 100644 --- a/client/src/pages/marketplace/Partners/Partners.tsx +++ b/client/src/pages/marketplace/Partners/Partners.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import { useEffect, useState } from 'react'; -import { DOMParser } from 'xmldom'; +import { DOMParser } from '@xmldom/xmldom'; import OwlCarousel from 'react-owl-carousel'; import 'owl.carousel/dist/assets/owl.carousel.css'; @@ -31,7 +31,8 @@ export const Partners: FC = () => { const partnerNameTags = xmlDoc.getElementsByTagName('name'); for (const nameTag of Array.from(partnerNameTags)) { - const name = nameTag.textContent || 'Error in loading name'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const name = (nameTag as any)?.textContent || 'Error in loading name'; const photoUrl = `assets/img/partners/${name .toLowerCase() .replace(' ', '-')}.jpg`; diff --git a/package-lock.json b/package-lock.json index 50418232..826d5f98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@sectester/reporter": "^0.33.1", "@sectester/runner": "^0.33.1", "@sectester/scan": "^0.33.1", + "@xmldom/xmldom": "^0.9.2", "axios": "^1.7.7", "bcrypt": "^5.1.1", "class-transformer": "^0.5.1", @@ -48,7 +49,6 @@ "raw-body": "^3.0.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", - "xmldom": "^0.6.0", "xpath": "0.0.34" }, "devDependencies": { @@ -5359,6 +5359,15 @@ "@xtuc/long": "4.2.2" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.2.tgz", + "integrity": "sha512-afP3lpLtalPxgNGU4bxlsru4wSDsZwdSFKnHs6PR0q3KIEWWcAlBqAdx4aWlVtP1gV1FBWlJ3d0MgaRRdj/ucA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -16317,14 +16326,6 @@ } } }, - "node_modules/xmldom": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.6.0.tgz", - "integrity": "sha512-iAcin401y58LckRZ0TkI4k0VSM1Qg0KGSc3i8rU+xrxe19A/BN1zHyVSJY7uoutVlaTSzYyk/v5AmkewAP7jtg==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/xmlhttprequest-ssl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz", diff --git a/package.json b/package.json index f649920e..ef512933 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@sectester/reporter": "^0.33.1", "@sectester/runner": "^0.33.1", "@sectester/scan": "^0.33.1", + "@xmldom/xmldom": "^0.9.2", "axios": "^1.7.7", "bcrypt": "^5.1.1", "class-transformer": "^0.5.1", @@ -62,7 +63,6 @@ "raw-body": "^3.0.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", - "xmldom": "^0.6.0", "xpath": "0.0.34" }, "devDependencies": { diff --git a/src/partners/partners.service.ts b/src/partners/partners.service.ts index 461a74b8..58d13f96 100644 --- a/src/partners/partners.service.ts +++ b/src/partners/partners.service.ts @@ -1,5 +1,5 @@ import { Injectable, Logger } from '@nestjs/common'; -import { DOMParser } from 'xmldom'; +import { DOMParser } from '@xmldom/xmldom'; import xpath, { SelectReturnType } from 'xpath'; @Injectable() @@ -7,8 +7,7 @@ export class PartnersService { private readonly logger = new Logger(PartnersService.name); private readonly XML_HEADER = ''; - private readonly XML_AUTHORS_STR: string = ` - ${this.XML_HEADER} + private readonly XML_AUTHORS_STR: string = `${this.XML_HEADER} Walter White @@ -57,7 +56,7 @@ export class PartnersService { this.XML_AUTHORS_STR, 'text/xml' ); - return partnersXMLObj; + return partnersXMLObj as unknown as Node; } private selectPartnerPropertiesByXPATH(