diff --git a/package-lock.json b/package-lock.json index 23e97a689..8c14875c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-unicorn": "^46.0.1", + "eslint-plugin-unicorn": "^48.0.1", "git-list-updated": "^1.2.1", "husky": "^8.0.3", "lint-staged": "^14.0.1", @@ -6059,36 +6059,35 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "46.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-46.0.1.tgz", - "integrity": "sha512-setGhMTiLAddg1asdwjZ3hekIN5zLznNa5zll7pBPwFOka6greCKDQydfqy4fqyUhndi74wpDzClSQMEcmOaew==", + "version": "48.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-48.0.1.tgz", + "integrity": "sha512-FW+4r20myG/DqFcCSzoumaddKBicIPeFnTrifon2mWIzlfyvzwyqZjqVP7m4Cqr/ZYisS2aiLghkUWaPg6vtCw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.19.1", - "@eslint-community/eslint-utils": "^4.1.2", - "ci-info": "^3.6.1", + "@babel/helper-validator-identifier": "^7.22.5", + "@eslint-community/eslint-utils": "^4.4.0", + "ci-info": "^3.8.0", "clean-regexp": "^1.0.0", - "esquery": "^1.4.0", + "esquery": "^1.5.0", "indent-string": "^4.0.0", - "is-builtin-module": "^3.2.0", + "is-builtin-module": "^3.2.1", "jsesc": "^3.0.2", "lodash": "^4.17.21", "pluralize": "^8.0.0", "read-pkg-up": "^7.0.1", - "regexp-tree": "^0.1.24", - "regjsparser": "^0.9.1", - "safe-regex": "^2.1.1", - "semver": "^7.3.8", + "regexp-tree": "^0.1.27", + "regjsparser": "^0.10.0", + "semver": "^7.5.4", "strip-indent": "^3.0.0" }, "engines": { - "node": ">=14.18" + "node": ">=16" }, "funding": { "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" }, "peerDependencies": { - "eslint": ">=8.28.0" + "eslint": ">=8.44.0" } }, "node_modules/eslint-plugin-unicorn/node_modules/jsesc": { @@ -11251,9 +11250,9 @@ } }, "node_modules/regjsparser": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz", - "integrity": "sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.10.0.tgz", + "integrity": "sha512-qx+xQGZVsy55CH0a1hiVwHmqjLryfh7wQyF5HO07XJ9f7dQMY/gPQHhlyDkIzJKC+x2fUCpCcUODUUUFrm7SHA==", "dev": true, "dependencies": { "jsesc": "~0.5.0" @@ -11631,15 +11630,6 @@ } ] }, - "node_modules/safe-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz", - "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", - "dev": true, - "dependencies": { - "regexp-tree": "~0.1.1" - } - }, "node_modules/safe-regex-test": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", diff --git a/package.json b/package.json index d854d9524..51927c14c 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-unicorn": "^46.0.1", + "eslint-plugin-unicorn": "^48.0.1", "git-list-updated": "^1.2.1", "husky": "^8.0.3", "lint-staged": "^14.0.1", diff --git a/src/ServerlessOffline.js b/src/ServerlessOffline.js index a46478269..59d97b28f 100644 --- a/src/ServerlessOffline.js +++ b/src/ServerlessOffline.js @@ -259,13 +259,13 @@ export default class ServerlessOffline { // Parse CORS options this.#options.corsAllowHeaders = this.#options.corsAllowHeaders - .replace(/\s/g, '') + .replaceAll(/\s/g, '') .split(',') this.#options.corsAllowOrigin = this.#options.corsAllowOrigin - .replace(/\s/g, '') + .replaceAll(/\s/g, '') .split(',') this.#options.corsExposedHeaders = this.#options.corsExposedHeaders - .replace(/\s/g, '') + .replaceAll(/\s/g, '') .split(',') this.#options.corsConfig = { diff --git a/src/events/authMatchPolicyResource.js b/src/events/authMatchPolicyResource.js index 38a7da6b2..5fd39313c 100644 --- a/src/events/authMatchPolicyResource.js +++ b/src/events/authMatchPolicyResource.js @@ -61,7 +61,7 @@ export default function authMatchPolicyResource(policyResource, resource) { // for the requested resource and the resource defined in the policy // Need to create a regex replacing ? with one character and * with any number of characters const regExp = new RegExp( - parsedPolicyResource.path.replace(/\*/g, '.*').replace(/\?/g, '.'), + parsedPolicyResource.path.replaceAll('*', '.*').replaceAll('?', '.'), ) return regExp.test(parsedResource.path) diff --git a/src/events/http/Endpoint.js b/src/events/http/Endpoint.js index 3b82bb576..0997c5d21 100644 --- a/src/events/http/Endpoint.js +++ b/src/events/http/Endpoint.js @@ -17,7 +17,7 @@ const defaultResponseTemplate = readFileSync( function getResponseContentType(fep) { if (fep.response && fep.response.headers['Content-Type']) { - return fep.response.headers['Content-Type'].replace(/'/gm, '') + return fep.response.headers['Content-Type'].replaceAll(/'/gm, '') } return 'application/json' diff --git a/src/events/http/javaHelpers.js b/src/events/http/javaHelpers.js index b5ce8fda2..c7c98e133 100644 --- a/src/events/http/javaHelpers.js +++ b/src/events/http/javaHelpers.js @@ -21,7 +21,7 @@ function javaMatches(value) { } function javaReplaceAll(oldValue, newValue) { - return this.replace(new RegExp(oldValue, 'gm'), newValue) + return this.replaceAll(new RegExp(oldValue, 'gm'), newValue) } function javaReplaceFirst(oldValue, newValue) { diff --git a/src/events/http/lambda-events/VelocityContext.js b/src/events/http/lambda-events/VelocityContext.js index 39a74d08a..f693239fc 100644 --- a/src/events/http/lambda-events/VelocityContext.js +++ b/src/events/http/lambda-events/VelocityContext.js @@ -14,7 +14,7 @@ const { assign, entries, fromEntries } = Object function escapeJavaScript(x) { if (typeof x === 'string') { - return jsEscapeString(x).replace(/\\n/g, '\n') // See #26, + return jsEscapeString(x).replaceAll('\\n', '\n') // See #26, } if (isPlainObject(x)) { @@ -136,7 +136,7 @@ export default class VelocityContext { Buffer.from(x.toString(), 'binary').toString('base64'), escapeJavaScript, parseJson: parse, - urlDecode: (x) => decodeURIComponent(x.replace(/\+/g, ' ')), + urlDecode: (x) => decodeURIComponent(x.replaceAll('+', ' ')), urlEncode: encodeURI, }, } diff --git a/src/events/schedule/ScheduleEvent.js b/src/events/schedule/ScheduleEvent.js index 21d42c61e..82cd90756 100644 --- a/src/events/schedule/ScheduleEvent.js +++ b/src/events/schedule/ScheduleEvent.js @@ -16,7 +16,7 @@ export default class ScheduleEvent { source = 'aws.events' // format of aws displaying the time, e.g.: 2020-02-09T14:13:57Z - time = new Date().toISOString().replace(/\.(.*)(?=Z)/g, '') + time = new Date().toISOString().replaceAll(/\.(.*)(?=Z)/g, '') version = '0' diff --git a/src/utils/generateHapiPath.js b/src/utils/generateHapiPath.js index dec1a5883..df20d4030 100644 --- a/src/utils/generateHapiPath.js +++ b/src/utils/generateHapiPath.js @@ -15,7 +15,7 @@ export default function generateHapiPath(path, options, serverless) { hapiPath = hapiPath.slice(0, -1) } - hapiPath = hapiPath.replace(/\+}/g, '*}') + hapiPath = hapiPath.replaceAll('+}', '*}') return hapiPath }