diff --git a/@types/lib/metadataTypes/Automation.d.ts b/@types/lib/metadataTypes/Automation.d.ts index 99faab377..2d473376b 100644 --- a/@types/lib/metadataTypes/Automation.d.ts +++ b/@types/lib/metadataTypes/Automation.d.ts @@ -864,6 +864,12 @@ declare namespace Automation { template: boolean; }; 'steps[].annotation': { + /** + * manages post retrieve steps + * + * @param {AutomationItem} metadata a single automation + * @returns {AutomationItem | void} parsed item + */ isCreateable: boolean; isUpdateable: boolean; retrieving: boolean; diff --git a/@types/lib/metadataTypes/Automation.d.ts.map b/@types/lib/metadataTypes/Automation.d.ts.map index 3c94b44b3..93691bce5 100644 --- a/@types/lib/metadataTypes/Automation.d.ts.map +++ b/@types/lib/metadataTypes/Automation.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"Automation.d.ts","sourceRoot":"","sources":["../../../lib/metadataTypes/Automation.js"],"names":[],"mappings":";uBAUa,OAAO,wBAAwB,EAAE,QAAQ;0BACzC,OAAO,wBAAwB,EAAE,WAAW;8BAC5C,OAAO,wBAAwB,EAAE,eAAe;+BAChD,OAAO,wBAAwB,EAAE,gBAAgB;mCACjD,OAAO,wBAAwB,EAAE,oBAAoB;kCACrD,OAAO,wBAAwB,EAAE,mBAAmB;8BACpD,OAAO,wBAAwB,EAAE,eAAe;iCAChD,OAAO,wBAAwB,EAAE,kBAAkB;uBACnD,OAAO,wBAAwB,EAAE,QAAQ;gCACzC,OAAO,wBAAwB,EAAE,iBAAiB;0BAClD,OAAO,wBAAwB,EAAE,WAAW;6BAG5C,OAAO,wBAAwB,EAAE,cAAc;gCAC/C,OAAO,wBAAwB,EAAE,iBAAiB;4BAClD,OAAO,wBAAwB,EAAE,aAAa;+BAC9C,OAAO,wBAAwB,EAAE,gBAAgB;iCACjD,OAAO,wBAAwB,EAAE,kBAAkB;qCACnD,OAAO,wBAAwB,EAAE,sBAAsB;AAnBpE;;;;;;;;;;;;GAYG;AACH;;;;;;;GAOG;AAEH;;;;GAIG;AACH;IACI,+BAAgC;IAChC,0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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAyNpC,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA8BhC;;;;;;;mBAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAqFH;;;;;mBAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAnZkB,mBAAmB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 12284c28a..a620e4da3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -699,7 +699,7 @@ class Mcdev { File.removeSync(filename); } - const regex = new RegExp('(\\w+-){4}\\w+'); + const regex = new RegExp(String.raw`(\w+-){4}\w+`); await File.ensureDir(retrieveDir); const metadata = Deployer.readBUMetadata(retrieveDir, null, true); let output = '# List of Metadata with Name-Key mismatches\n'; diff --git a/lib/metadataTypes/Asset.js b/lib/metadataTypes/Asset.js index 7964023f0..c9c73a453 100644 --- a/lib/metadataTypes/Asset.js +++ b/lib/metadataTypes/Asset.js @@ -889,7 +889,7 @@ class Asset extends MetadataType { mode ) { // * because asset's _mergeCode() is overwriting 'metadata', clone it to ensure the main file is not modified by what we do in here - metadata = JSON.parse(JSON.stringify(metadata)); + metadata = structuredClone(metadata); // #1 text extracts // define asset's subtype diff --git a/lib/metadataTypes/Automation.js b/lib/metadataTypes/Automation.js index 403787040..bbfdef44a 100644 --- a/lib/metadataTypes/Automation.js +++ b/lib/metadataTypes/Automation.js @@ -351,7 +351,7 @@ class Automation extends MetadataType { ); } } catch { - val = JSON.parse(JSON.stringify(details)); + val = structuredClone(details); } if (val === null) { throw new Error( @@ -508,7 +508,7 @@ class Automation extends MetadataType { } } } - return JSON.parse(JSON.stringify(metadata)); + return structuredClone(metadata); } catch (ex) { Util.logger.warn( ` - ${this.definition.typeName} '${metadata[this.definition.nameField]}': ${ diff --git a/lib/metadataTypes/DataExtension.js b/lib/metadataTypes/DataExtension.js index 98d81e1cc..de4098494 100644 --- a/lib/metadataTypes/DataExtension.js +++ b/lib/metadataTypes/DataExtension.js @@ -1486,8 +1486,8 @@ class DataExtension extends MetadataType { metadata[key].Fields.sort((a, b) => a.Ordinal - b.Ordinal); const originalKey = key; - const metadataCleaned = JSON.parse( - JSON.stringify(await this.postRetrieveTasks(metadata[key])) + const metadataCleaned = structuredClone( + await this.postRetrieveTasks(metadata[key]) ); this.keepTemplateFields(metadataCleaned); diff --git a/lib/metadataTypes/DataExtensionField.js b/lib/metadataTypes/DataExtensionField.js index b5ca637b7..efef3e5b5 100644 --- a/lib/metadataTypes/DataExtensionField.js +++ b/lib/metadataTypes/DataExtensionField.js @@ -190,7 +190,7 @@ class DataExtensionField extends MetadataType { } } // share fields with fixShared logic - this.fixShared_fields[deKey][item.Name] = JSON.parse(JSON.stringify(item)); + this.fixShared_fields[deKey][item.Name] = structuredClone(item); this.fixShared_fields[deKey][item.Name].FieldType = itemOld.FieldType; if (!changeFound) { @@ -227,7 +227,7 @@ class DataExtensionField extends MetadataType { // Field doesn't exist in target, therefore Remove ObjectID if present delete item.ObjectID; - this.fixShared_fields[deKey][item.Name] = JSON.parse(JSON.stringify(item)); + this.fixShared_fields[deKey][item.Name] = structuredClone(item); } if (Util.isTrue(item.IsPrimaryKey) && Util.isFalse(item.IsRequired)) { // applicable: with or without data diff --git a/lib/metadataTypes/DataExtract.js b/lib/metadataTypes/DataExtract.js index 9dba7db36..6284d7cec 100644 --- a/lib/metadataTypes/DataExtract.js +++ b/lib/metadataTypes/DataExtract.js @@ -157,7 +157,7 @@ class DataExtract extends MetadataType { ` - ${this.definition.type} ${metadata[this.definition.keyField]}: ${ex.message}` ); } - return JSON.parse(JSON.stringify(metadata)); + return structuredClone(metadata); } /** * helper to allow us to select single metadata entries via REST diff --git a/lib/metadataTypes/Folder.js b/lib/metadataTypes/Folder.js index 0a81a6993..aa9e2d889 100644 --- a/lib/metadataTypes/Folder.js +++ b/lib/metadataTypes/Folder.js @@ -179,7 +179,7 @@ class Folder extends MetadataType { * @returns {Promise.} Promise of saved metadata */ static async upsert(metadata) { - const orignalMetadata = JSON.parse(JSON.stringify(metadata)); + const orignalMetadata = structuredClone(metadata); let updateCount = 0; let updateFailedCount = 0; let createCount = 0; @@ -265,7 +265,7 @@ class Folder extends MetadataType { let result; // since deployableMetadata will be modified for deploy, make a copy for reference - const beforeMetadata = JSON.parse(JSON.stringify(deployableMetadata)); + const beforeMetadata = structuredClone(deployableMetadata); if (existingId) { // if an existing folder exists with the same name/path then use that deployableMetadata.ID = existingId; @@ -590,7 +590,7 @@ class Folder extends MetadataType { * @returns {MetadataTypeItem} cloned metadata */ static postRetrieveTasks(metadata) { - return JSON.parse(JSON.stringify(metadata)); + return structuredClone(metadata); } /** * Helper for writing Metadata to disk, used for Retrieve and deploy diff --git a/lib/metadataTypes/MetadataType.js b/lib/metadataTypes/MetadataType.js index c7e41916e..2913b7c15 100644 --- a/lib/metadataTypes/MetadataType.js +++ b/lib/metadataTypes/MetadataType.js @@ -209,7 +209,7 @@ class MetadataType { * @returns {MetadataTypeItem} cloned metadata */ static postRetrieveTasks(metadata, targetDir, isTemplating) { - return JSON.parse(JSON.stringify(metadata)); + return structuredClone(metadata); } /** * generic script that retrieves the folder path from cache and updates the given metadata with it after retrieve @@ -529,7 +529,7 @@ class MetadataType { return true; } // we do need the full set in other places and hence need to work with a clone here - const clonedMetada = JSON.parse(JSON.stringify(metadata)); + const clonedMetada = structuredClone(metadata); this.removeNotUpdateableFields(clonedMetada); // iterate over what we want to upload rather than what we cached to avoid false positives for (const prop in clonedMetada) { @@ -577,7 +577,7 @@ class MetadataType { * @returns {Promise.} keyField => metadata map */ static async upsert(metadataMap, deployDir) { - const orignalMetadataMap = JSON.parse(JSON.stringify(metadataMap)); + const orignalMetadataMap = structuredClone(metadataMap); const metadataToUpdate = []; const metadataToCreate = []; let filteredByPreDeploy = 0; @@ -893,7 +893,7 @@ class MetadataType { * @returns {Promise. | null} Promise of API response or null in case of an error */ static async createREST(metadataEntry, uri, handleOutside) { - const metadataClone = JSON.parse(JSON.stringify(metadataEntry)); + const metadataClone = structuredClone(metadataEntry); this.removeNotCreateableFields(metadataEntry); try { // set to empty object in case API returned nothing to be able to update it in helper classes @@ -1787,7 +1787,7 @@ class MetadataType { // we dont store Id on local disk, but we need it for caching logic, // so its in retrieve but not in save. Here we put into the clone so that the original // object used for caching doesnt have the Id removed. - const saveClone = JSON.parse(JSON.stringify(results[originalKey])); + const saveClone = structuredClone(results[originalKey]); if ( !this.definition.keepId && this.definition.idField !== this.definition.keyField diff --git a/lib/util/auth.js b/lib/util/auth.js index 8931d3c9c..d05cb9f5f 100644 --- a/lib/util/auth.js +++ b/lib/util/auth.js @@ -140,7 +140,7 @@ function setupSDK(sessionKey, authObject) { Util.logger.errorStack(ex); }, logRequest: (req) => { - const msg = JSON.parse(JSON.stringify(req)); + const msg = structuredClone(req); if (msg.url === '/Service.asmx') { msg.data = msg.data.replaceAll( //gim, diff --git a/lib/util/util.js b/lib/util/util.js index 71b891306..b56e0d955 100644 --- a/lib/util/util.js +++ b/lib/util/util.js @@ -480,7 +480,7 @@ export const Util = { sortable.sort((a, b) => b[1].length - a[1].length); for (const pair of sortable) { - const escVal = pair[1].toString().replaceAll(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); + const escVal = pair[1].toString().replaceAll(/[-/\\^$*+?.()|[\]{}]/g, String.raw`\$&`); const regString = new RegExp(escVal, 'g'); str = str.replace(regString, '{{{' + pair[0] + '}}}'); } @@ -875,8 +875,8 @@ export const Util = { } // Remove special chars search = search.replaceAll( - new RegExp('([\\.\\\\\\+\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\\-])', 'g'), - '\\$1' + new RegExp(String.raw`([\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:\-])`, 'g'), + String.raw`\$1` ); // Replace % and _ with equivalent regex search = search.replaceAll('%', '.*').replaceAll('_', '.'); diff --git a/package-lock.json b/package-lock.json index aaf1beb0e..c3a896d2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "eslint-plugin-jsdoc": "48.2.6", "eslint-plugin-mocha": "10.4.3", "eslint-plugin-prettier": "5.1.2", - "eslint-plugin-unicorn": "52.0.0", + "eslint-plugin-unicorn": "53.0.0", "fast-xml-parser": "4.4.0", "husky": "9.0.11", "lint-staged": "15.2.5", @@ -162,9 +162,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.24.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.6.tgz", + "integrity": "sha512-4yA7s865JHaqUdRbnaxarZREuPTHrjpDT+pXoAZ1yhyo6uFnIEpS8VMu16siFOHDpZNKYv5BObhsB//ycbICyw==", "dev": true, "engines": { "node": ">=6.9.0" @@ -757,9 +757,9 @@ "dev": true }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -1200,9 +1200,9 @@ "dev": true }, "node_modules/browserslist": { - "version": "4.22.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", - "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", + "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", "dev": true, "funding": [ { @@ -1219,8 +1219,8 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001565", - "electron-to-chromium": "^1.4.601", + "caniuse-lite": "^1.0.30001587", + "electron-to-chromium": "^1.4.668", "node-releases": "^2.0.14", "update-browserslist-db": "^1.0.13" }, @@ -1334,9 +1334,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001576", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001576.tgz", - "integrity": "sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg==", + "version": "1.0.30001624", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001624.tgz", + "integrity": "sha512-0dWnQG87UevOCPYaOR49CBcLBwoZLpws+k6W37nLjWUhumP1Isusj0p2u+3KhjNloRWK9OKMgjBBzPujQHw4nA==", "dev": true, "funding": [ { @@ -1800,12 +1800,12 @@ "dev": true }, "node_modules/core-js-compat": { - "version": "3.35.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.35.0.tgz", - "integrity": "sha512-5blwFAddknKeNgsjBzilkdQ0+YK8L1PfqPYq40NOYMYFSS38qj+hpTcLLWwpIwA2A5bje/x5jmVn2tzUMg9IVw==", + "version": "3.37.1", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.1.tgz", + "integrity": "sha512-9TNiImhKvQqSUkOvk/mMRZzOANTiEVC7WaBNhHcKM7x+/5E1l5NvsysR19zuDQScE8k+kfQXWRN3AtS/eOSHpg==", "dev": true, "dependencies": { - "browserslist": "^4.22.2" + "browserslist": "^4.23.0" }, "funding": { "type": "opencollective", @@ -2071,9 +2071,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.626", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.626.tgz", - "integrity": "sha512-f7/be56VjRRQk+Ric6PmIrEtPcIqsn3tElyAu9Sh6egha2VLJ82qwkcOdcnT06W+Pb6RUulV1ckzrGbKzVcTHg==", + "version": "1.4.783", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.783.tgz", + "integrity": "sha512-bT0jEz/Xz1fahQpbZ1D7LgmPYZ3iHVY39NcWWro1+hA2IvjiPeaXtfSqrQ+nXjApMvQRE2ASt1itSLRrebHMRQ==", "dev": true }, "node_modules/emoji-regex": { @@ -2177,9 +2177,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "engines": { "node": ">=6" } @@ -2381,17 +2381,17 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "52.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-52.0.0.tgz", - "integrity": "sha512-1Yzm7/m+0R4djH0tjDjfVei/ju2w3AzUGjG6q8JnuNIL5xIwsflyCooW5sfBvQp2pMYQFSWWCFONsjCax1EHng==", + "version": "53.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-53.0.0.tgz", + "integrity": "sha512-kuTcNo9IwwUCfyHGwQFOK/HjJAYzbODHN3wP0PgqbW+jbXqpNWxNVpVhj2tO9SixBwuAdmal8rVcWKBxwFnGuw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.22.20", + "@babel/helper-validator-identifier": "^7.24.5", "@eslint-community/eslint-utils": "^4.4.0", - "@eslint/eslintrc": "^2.1.4", + "@eslint/eslintrc": "^3.0.2", "ci-info": "^4.0.0", "clean-regexp": "^1.0.0", - "core-js-compat": "^3.34.0", + "core-js-compat": "^3.37.0", "esquery": "^1.5.0", "indent-string": "^4.0.0", "is-builtin-module": "^3.2.1", @@ -2400,11 +2400,11 @@ "read-pkg-up": "^7.0.1", "regexp-tree": "^0.1.27", "regjsparser": "^0.10.0", - "semver": "^7.5.4", + "semver": "^7.6.1", "strip-indent": "^3.0.0" }, "engines": { - "node": ">=16" + "node": ">=18.18" }, "funding": { "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" @@ -2413,6 +2413,86 @@ "eslint": ">=8.56.0" } }, + "node_modules/eslint-plugin-unicorn/node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/espree": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", + "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint-plugin-unicorn/node_modules/jsesc": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", @@ -2425,6 +2505,24 @@ "node": ">=6" } }, + "node_modules/eslint-plugin-unicorn/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/eslint-plugin-unicorn/node_modules/semver": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -5727,9 +5825,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", "dev": true }, "node_modules/picomatch": { @@ -6981,9 +7079,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.13", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", - "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", + "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "dev": true, "funding": [ { @@ -7000,8 +7098,8 @@ } ], "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.1.2", + "picocolors": "^1.0.1" }, "bin": { "update-browserslist-db": "cli.js" diff --git a/package.json b/package.json index 5ae0f772d..712587a07 100644 --- a/package.json +++ b/package.json @@ -52,12 +52,9 @@ "mcdev": "node lib/cli.js", "build": "run-s lint:fix docs test", "debug": "node --nolazy --inspect-brk=9229 lib/cli.js", - "lint:fix": "eslint --fix lib/**/*.js && eslint --fix types/*.js && eslint --fix test/**/*.js", - "lint": "run-p -c lint-type lint-lib lint-test", + "lint:fix": "eslint --fix lib/**/*.js types/*.js test/**/*.js", + "lint": "eslint lib/**/*.js types/*.js test/**/*.js", "lint-ts": "tsc -p jsconfig.json --maxNodeModuleJsDepth 1 --noEmit", - "lint-lib": "eslint lib/**/*.js", - "lint-type": "eslint types/*.js", - "lint-test": "eslint test/**/*.js", "prepare": "husky || true", "lint-and-test": "run-s lint test", "test": "mocha --reporter-option maxDiffSize=25000", @@ -102,7 +99,7 @@ "eslint-plugin-jsdoc": "48.2.6", "eslint-plugin-mocha": "10.4.3", "eslint-plugin-prettier": "5.1.2", - "eslint-plugin-unicorn": "52.0.0", + "eslint-plugin-unicorn": "53.0.0", "fast-xml-parser": "4.4.0", "husky": "9.0.11", "lint-staged": "15.2.5", diff --git a/test/utils.js b/test/utils.js index cdbe0529c..4050ac479 100644 --- a/test/utils.js +++ b/test/utils.js @@ -294,5 +294,5 @@ export function logAPIHistoryDebug() { * @returns {string} escaped string */ function escapeRegExp(str) { - return str.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`); // $& means the whole matched string }