diff --git a/config/eslint.js b/config/eslint.js index e4fd9a938..e4cddd52d 100644 --- a/config/eslint.js +++ b/config/eslint.js @@ -6,6 +6,7 @@ import jsdoc from "eslint-plugin-jsdoc"; import json from "@eslint/json"; import regexp from "eslint-plugin-regexp"; import top from "@ericcornelissen/eslint-plugin-top"; +import unicorn from "eslint-plugin-unicorn"; import yml from "eslint-plugin-yml"; export default [ @@ -17,6 +18,15 @@ export default [ sourceType: "module", }, }, + { + name: "Dependencies", + files: ["**/*.js"], + plugins: { depend }, + rules: { + // https://github.com/es-tooling/eslint-plugin-depend#readme + "depend/ban-dependencies": ["error"], + }, + }, { name: "JSDoc", files: ["**/*.js"], @@ -323,21 +333,10 @@ export default [ }, }, { - name: "Source", - files: ["src/**/*.js"], - plugins: { depend, jsdoc, regexp, top }, + name: "Regular Expressions", + files: ["**/*.js"], + plugins: { regexp }, rules: { - // https://github.com/es-tooling/eslint-plugin-depend#readme - "depend/ban-dependencies": ["error"], - - // https://github.com/gajus/eslint-plugin-jsdoc#readme - "jsdoc/check-values": [ - "error", - { - allowedLicenses: ["MPL-2.0"], - }, - ], - // https://github.com/ota-meshi/eslint-plugin-regexp#readme "regexp/confusing-quantifier": ["error"], "regexp/control-character-escape": ["error"], @@ -530,6 +529,151 @@ export default [ }, ], "regexp/use-ignore-case": ["error"], + }, + }, + { + name: "Style", + files: ["**/*.js"], + plugins: { unicorn }, + rules: { + // https://github.com/sindresorhus/eslint-plugin-unicorn#readme + "unicorn/better-regex": ["error"], + "unicorn/catch-error-name": ["error"], + "unicorn/consistent-destructuring": ["off"], + "unicorn/consistent-empty-array-spread": ["error"], + "unicorn/consistent-existence-index-check": ["error"], + "unicorn/consistent-function-scoping": ["error"], + "unicorn/custom-error-definition": ["error"], + "unicorn/empty-brace-spaces": ["error"], + "unicorn/error-message": ["error"], + "unicorn/escape-case": ["error"], + "unicorn/expiring-todo-comments": ["error"], + "unicorn/explicit-length-check": ["error"], + "unicorn/filename-case": ["error"], + "unicorn/import-style": ["off"], + "unicorn/new-for-builtins": ["error"], + "unicorn/no-abusive-eslint-disable": ["error"], + "unicorn/no-anonymous-default-export": ["error"], + "unicorn/no-array-callback-reference": ["error"], + "unicorn/no-array-for-each": ["error"], + "unicorn/no-array-method-this-argument": ["error"], + "unicorn/no-array-push-push": ["error"], + "unicorn/no-array-reduce": ["error"], + "unicorn/no-await-expression-member": ["error"], + "unicorn/no-await-in-promise-methods": ["error"], + "unicorn/no-console-spaces": ["error"], + "unicorn/no-document-cookie": ["error"], + "unicorn/no-empty-file": ["error"], + "unicorn/no-for-loop": ["error"], + "unicorn/no-hex-escape": ["error"], + "unicorn/no-instanceof-array": ["error"], + "unicorn/no-invalid-fetch-options": ["error"], + "unicorn/no-invalid-remove-event-listener": ["error"], + "unicorn/no-keyword-prefix": ["error"], + "unicorn/no-length-as-slice-end": ["error"], + "unicorn/no-lonely-if": ["error"], + "unicorn/no-magic-array-flat-depth": ["error"], + "unicorn/no-negated-condition": ["error"], + "unicorn/no-negation-in-equality-check": ["error"], + "unicorn/no-nested-ternary": ["off"], + "unicorn/no-new-array": ["error"], + "unicorn/no-new-buffer": ["error"], + "unicorn/no-null": ["off"], + "unicorn/no-object-as-default-parameter": ["error"], + "unicorn/no-process-exit": ["error"], + "unicorn/no-single-promise-in-promise-methods": ["error"], + "unicorn/no-static-only-class": ["error"], + "unicorn/no-thenable": ["error"], + "unicorn/no-this-assignment": ["error"], + "unicorn/no-typeof-undefined": ["error"], + "unicorn/no-unnecessary-await": ["error"], + "unicorn/no-unnecessary-polyfills": ["error"], + "unicorn/no-unreadable-array-destructuring": ["error"], + "unicorn/no-unreadable-iife": ["error"], + "unicorn/no-unused-properties": ["error"], + "unicorn/no-useless-fallback-in-spread": ["error"], + "unicorn/no-useless-length-check": ["error"], + "unicorn/no-useless-promise-resolve-reject": ["error"], + "unicorn/no-useless-spread": ["error"], + "unicorn/no-useless-switch-case": ["error"], + "unicorn/no-useless-undefined": ["error"], + "unicorn/no-zero-fractions": ["error"], + "unicorn/number-literal-case": ["off"], + "unicorn/numeric-separators-style": ["error"], + "unicorn/prefer-add-event-listener": ["error"], + "unicorn/prefer-array-find": ["error"], + "unicorn/prefer-array-flat-map": ["error"], + "unicorn/prefer-array-flat": ["error"], + "unicorn/prefer-array-index-of": ["error"], + "unicorn/prefer-array-some": ["error"], + "unicorn/prefer-at": ["error"], + "unicorn/prefer-blob-reading-methods": ["error"], + "unicorn/prefer-code-point": ["error"], + "unicorn/prefer-date-now": ["error"], + "unicorn/prefer-default-parameters": ["error"], + "unicorn/prefer-dom-node-append": ["error"], + "unicorn/prefer-dom-node-dataset": ["error"], + "unicorn/prefer-dom-node-remove": ["error"], + "unicorn/prefer-dom-node-text-content": ["error"], + "unicorn/prefer-event-target": ["error"], + "unicorn/prefer-export-from": ["error"], + "unicorn/prefer-global-this": ["error"], + "unicorn/prefer-includes": ["error"], + "unicorn/prefer-json-parse-buffer": ["error"], + "unicorn/prefer-keyboard-event-key": ["error"], + "unicorn/prefer-logical-operator-over-ternary": ["error"], + "unicorn/prefer-math-min-max": ["error"], + "unicorn/prefer-math-trunc": ["error"], + "unicorn/prefer-modern-dom-apis": ["error"], + "unicorn/prefer-modern-math-apis": ["error"], + "unicorn/prefer-module": ["error"], + "unicorn/prefer-native-coercion-functions": ["error"], + "unicorn/prefer-negative-index": ["error"], + "unicorn/prefer-node-protocol": ["error"], + "unicorn/prefer-number-properties": ["error"], + "unicorn/prefer-object-from-entries": ["error"], + "unicorn/prefer-optional-catch-binding": ["error"], + "unicorn/prefer-prototype-methods": ["error"], + "unicorn/prefer-query-selector": ["error"], + "unicorn/prefer-reflect-apply": ["error"], + "unicorn/prefer-regexp-test": ["error"], + "unicorn/prefer-set-has": ["error"], + "unicorn/prefer-set-size": ["error"], + "unicorn/prefer-spread": ["off"], + "unicorn/prefer-string-raw": ["off"], + "unicorn/prefer-string-replace-all": ["off"], + "unicorn/prefer-string-slice": ["error"], + "unicorn/prefer-string-starts-ends-with": ["error"], + "unicorn/prefer-string-trim-start-end": ["error"], + "unicorn/prefer-structured-clone": ["error"], + "unicorn/prefer-switch": ["error"], + "unicorn/prefer-ternary": ["off"], + "unicorn/prefer-top-level-await": ["error"], + "unicorn/prefer-type-error": ["error"], + "unicorn/prevent-abbreviations": ["off"], + "unicorn/relative-url-style": ["error"], + "unicorn/require-array-join-separator": ["error"], + "unicorn/require-number-to-fixed-digits-argument": ["error"], + "unicorn/require-post-message-target-origin": ["error"], + "unicorn/string-content": ["error"], + "unicorn/switch-case-braces": ["error"], + "unicorn/template-indent": ["error"], + "unicorn/text-encoding-identifier-case": ["error"], + "unicorn/throw-new-error": ["error"], + }, + }, + { + name: "Source", + files: ["src/**/*.js"], + plugins: { jsdoc, top }, + rules: { + // https://github.com/gajus/eslint-plugin-jsdoc#readme + "jsdoc/check-values": [ + "error", + { + allowedLicenses: ["MPL-2.0"], + }, + ], // https://github.com/ericcornelissen/eslint-plugin-top#readme "top/no-top-level-side-effects": [ @@ -553,11 +697,8 @@ export default [ { name: "Tests", files: ["test/**/*.js"], - plugins: { ava, depend, jsdoc }, + plugins: { ava, jsdoc }, rules: { - // https://github.com/es-tooling/eslint-plugin-depend#readme - "depend/ban-dependencies": ["error"], - // https://github.com/gajus/eslint-plugin-jsdoc#readme "jsdoc/check-values": [ "error", @@ -600,16 +741,16 @@ export default [ "ava/use-t-well": ["error"], "ava/use-test": ["error"], "ava/use-true-false": ["error"], + + // https://github.com/sindresorhus/eslint-plugin-unicorn#readme + "unicorn/no-useless-undefined": ["off"], }, }, { name: "Scripts", files: [".github/**/*.js", "script/**/*.js"], - plugins: { depend, jsdoc }, + plugins: { jsdoc, unicorn }, rules: { - // https://github.com/es-tooling/eslint-plugin-depend#readme - "depend/ban-dependencies": ["error"], - // https://github.com/gajus/eslint-plugin-jsdoc#readme "jsdoc/check-values": [ "error", @@ -618,6 +759,9 @@ export default [ }, ], "jsdoc/require-jsdoc": ["off"], + + // https://github.com/sindresorhus/eslint-plugin-unicorn#readme + "unicorn/no-process-exit": ["off"], }, }, { diff --git a/config/stryker/integration.js b/config/stryker/integration.js index c03e072fc..43bdd76aa 100644 --- a/config/stryker/integration.js +++ b/config/stryker/integration.js @@ -16,7 +16,7 @@ export default { }, incremental: true, incrementalFile: ".cache/stryker-incremental-integration.json", - timeoutMS: 10000, + timeoutMS: 10_000, reporters: ["clear-text", "html", "progress"], htmlReporter: { fileName: "_reports/mutation/integration.html", diff --git a/config/stryker/unit.js b/config/stryker/unit.js index c8341c036..1d4338ec7 100644 --- a/config/stryker/unit.js +++ b/config/stryker/unit.js @@ -16,7 +16,7 @@ export default { }, incremental: true, incrementalFile: ".cache/stryker-incremental-unit.json", - timeoutMS: 10000, + timeoutMS: 10_000, reporters: ["clear-text", "html", "progress"], htmlReporter: { fileName: "_reports/mutation/unit.html", diff --git a/package-lock.json b/package-lock.json index c8c7b1a71..dfb5272cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "eslint-plugin-depend": "0.12.0", "eslint-plugin-jsdoc": "50.4.1", "eslint-plugin-regexp": "2.6.0", + "eslint-plugin-unicorn": "56.0.1", "eslint-plugin-yml": "1.14.0", "fast-check": "3.22.0", "husky": "9.1.1", @@ -3720,6 +3721,19 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/c8": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", @@ -4054,6 +4068,29 @@ "dev": true, "license": "MIT" }, + "node_modules/clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/clean-regexp/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -4579,6 +4616,20 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, + "node_modules/core-js-compat": { + "version": "3.39.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.39.0.tgz", + "integrity": "sha512-VgEUx3VwlExr5no0tXlBt+silBvhTryPwCXRI2Id1PN8WTKu7MreethvddqOubrYxkFdv/RnYrqlv1sFNAUelw==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.24.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -5581,6 +5632,203 @@ "eslint": ">=8.44.0" } }, + "node_modules/eslint-plugin-unicorn": { + "version": "56.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-56.0.1.tgz", + "integrity": "sha512-FwVV0Uwf8XPfVnKSGpMg7NtlZh0G0gBarCaFcMUOoqPxXryxdYxTRRv4kH6B9TFCVIrjRXG+emcxIk2ayZilog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.24.7", + "@eslint-community/eslint-utils": "^4.4.0", + "ci-info": "^4.0.0", + "clean-regexp": "^1.0.0", + "core-js-compat": "^3.38.1", + "esquery": "^1.6.0", + "globals": "^15.9.0", + "indent-string": "^4.0.0", + "is-builtin-module": "^3.2.1", + "jsesc": "^3.0.2", + "pluralize": "^8.0.0", + "read-pkg-up": "^7.0.1", + "regexp-tree": "^0.1.27", + "regjsparser": "^0.10.0", + "semver": "^7.6.3", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=18.18" + }, + "funding": { + "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" + }, + "peerDependencies": { + "eslint": ">=8.56.0" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/globals": { + "version": "15.13.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.13.0.tgz", + "integrity": "sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true, + "license": "ISC" + }, + "node_modules/eslint-plugin-unicorn/node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/normalize-package-data/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/read-pkg/node_modules/type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=8" + } + }, "node_modules/eslint-plugin-yml": { "version": "1.14.0", "resolved": "https://registry.npmjs.org/eslint-plugin-yml/-/eslint-plugin-yml-1.14.0.tgz", @@ -8321,6 +8569,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -8353,9 +8617,9 @@ } }, "node_modules/is-core-module": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", - "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.0.tgz", + "integrity": "sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g==", "dev": true, "license": "MIT", "dependencies": { @@ -10951,6 +11215,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -12164,6 +12438,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/package-config": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/package-config/-/package-config-5.0.0.tgz", @@ -12391,6 +12675,13 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, "node_modules/path-scurry": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", @@ -12491,6 +12782,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", @@ -13359,6 +13660,16 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", @@ -13407,6 +13718,28 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/regjsparser": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.10.0.tgz", + "integrity": "sha512-qx+xQGZVsy55CH0a1hiVwHmqjLryfh7wQyF5HO07XJ9f7dQMY/gPQHhlyDkIzJKC+x2fUCpCcUODUUUFrm7SHA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~0.5.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -13427,6 +13760,24 @@ "node": ">=0.10.0" } }, + "node_modules/resolve": { + "version": "1.22.9", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.9.tgz", + "integrity": "sha512-QxrmX1DzraFIi9PxdG5VkRfRwIgjwyud+z/iBwfRRrVmHc+P9Q7u2lSSpQ6bjr2gy5lrqIiU9vb6iAeGf2400A==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/resolve-alpn": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", @@ -14430,6 +14781,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -14562,6 +14926,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/synckit": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", diff --git a/package.json b/package.json index 76b39bf60..e0644b467 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "eslint-plugin-depend": "0.12.0", "eslint-plugin-jsdoc": "50.4.1", "eslint-plugin-regexp": "2.6.0", + "eslint-plugin-unicorn": "56.0.1", "eslint-plugin-yml": "1.14.0", "fast-check": "3.22.0", "husky": "9.1.1", diff --git a/script/_.js b/script/_.js index 911fb59b8..98e0642a8 100644 --- a/script/_.js +++ b/script/_.js @@ -3,7 +3,5 @@ * @license MIT-0 */ -import * as fuzz from "../test/fuzz/_common.js"; -import * as common from "./_common.js"; - -export { common, fuzz }; +export * as fuzz from "../test/fuzz/_common.js"; +export * as common from "./_common.js"; diff --git a/script/_common.js b/script/_common.js index 5e31cf146..b9e90509e 100644 --- a/script/_common.js +++ b/script/_common.js @@ -33,7 +33,7 @@ export function npm(argv) { export function npmSync(argv) { return cp.spawnSync(npmCmd, argv, { cwd: projectRoot, - encoding: "utf-8", + encoding: "utf8", shell: true, }); } diff --git a/script/check-runtime-deps.js b/script/check-runtime-deps.js index bfeaf1c99..7d7acf77a 100644 --- a/script/check-runtime-deps.js +++ b/script/check-runtime-deps.js @@ -24,11 +24,11 @@ const violations = Object.entries(runtimeDeps) .filter(({ installed, supported }) => !supported.endsWith(installed)); if (violations.length > 0) { - violations.forEach(({ dependency, installed, supported }) => { + for (const { dependency, installed, supported } of violations) { console.log("Dependency:", dependency); console.log(" supported:", supported); console.log(" installed:", installed); - }); + } console.log(""); console.log( diff --git a/script/fuzz.js b/script/fuzz.js index e7d8ae3c4..dda96a981 100644 --- a/script/fuzz.js +++ b/script/fuzz.js @@ -29,7 +29,7 @@ if (!fs.existsSync(path.resolve(fuzzTargetsDir, `${fuzzTarget}.test.js`))) { process.exit(2); } -if (isNaN(fuzzIterations)) { +if (Number.isNaN(fuzzIterations)) { console.log("The FUZZ_ITERATIONS should be a numeric value"); console.log(`Got '${process.env.FUZZ_ITERATIONS}' instead`); process.exit(2); @@ -44,7 +44,7 @@ start(fuzzTarget); function logDetails(shell, target, iterations) { console.log( "Will fuzz", - isFinite(iterations) ? `for ${iterations} iterations(s)` : "forever", + Number.isFinite(iterations) ? `for ${iterations} iterations(s)` : "forever", "using", shell === false ? "no shell" diff --git a/script/release/bump-changelog.js b/script/release/bump-changelog.js index 8a52c9418..33fbd1c0a 100644 --- a/script/release/bump-changelog.js +++ b/script/release/bump-changelog.js @@ -40,10 +40,10 @@ const month = _month < 10 ? `0${_month}` : _month; const _day = date.getDate(); const day = _day < 10 ? `0${_day}` : _day; -const newChangelog = +const updatedChangelog = changelog.slice(0, unreleasedTitleIndex + STR_UNRELEASED.length) + `\n\n${STR_NO_CHANGES}` + `\n\n## [${version}] - ${year}-${month}-${day}` + changelog.slice(unreleasedTitleIndex + STR_UNRELEASED.length); -fs.writeFileSync(changelogFile, newChangelog); +fs.writeFileSync(changelogFile, updatedChangelog); diff --git a/script/release/bump-jsdoc.js b/script/release/bump-jsdoc.js index 8f8a7b55b..5f015e46f 100644 --- a/script/release/bump-jsdoc.js +++ b/script/release/bump-jsdoc.js @@ -17,9 +17,9 @@ const manifest = JSON.parse(manifestRaw); const version = manifest.version; const index = fs.readFileSync(indexFile).toString(); -const newIndex = index.replace( +const updatedIndex = index.replace( / \* @version \d+\.\d+\.\d+/u, ` * @version ${version}`, ); -fs.writeFileSync(indexFile, newIndex); +fs.writeFileSync(indexFile, updatedIndex); diff --git a/script/release/get-release-notes.js b/script/release/get-release-notes.js index 0e5b205c3..83fe39f60 100644 --- a/script/release/get-release-notes.js +++ b/script/release/get-release-notes.js @@ -24,8 +24,8 @@ if (!changelog.includes(versionHeader)) { } const startIndex = changelog.indexOf(versionHeader) + versionHeader.length + 13; -const endIndex = startIndex + changelog.substring(startIndex).indexOf("## ["); +const endIndex = startIndex + changelog.slice(startIndex).indexOf("## ["); -const releaseNotes = changelog.substring(startIndex, endIndex); +const releaseNotes = changelog.slice(startIndex, endIndex); process.stdout.write(releaseNotes); process.stdout.write("\n"); diff --git a/src/internal/executables.js b/src/internal/executables.js index f8fcbd900..a0391d2aa 100644 --- a/src/internal/executables.js +++ b/src/internal/executables.js @@ -45,7 +45,7 @@ export function resolveExecutable( ? env.Path : undefined; resolved = which(resolved, { path }); - } catch (_) { + } catch { throw new Error(notFoundError(executable)); } @@ -55,7 +55,7 @@ export function resolveExecutable( try { resolved = readlink(resolved); - } catch (_) { + } catch { // An error will be thrown if the executable is not a (sym)link, this is not // a problem so the error is ignored } diff --git a/src/internal/unix.js b/src/internal/unix.js index 3403172ef..e8ef7268e 100644 --- a/src/internal/unix.js +++ b/src/internal/unix.js @@ -67,16 +67,21 @@ export function getDefaultShell() { */ export function getEscapeFunction(shellName) { switch (shellName) { - case noShell: + case noShell: { return nosh.getEscapeFunction(); - case binBash: + } + case binBash: { return bash.getEscapeFunction(); - case binCsh: + } + case binCsh: { return csh.getEscapeFunction(); - case binDash: + } + case binDash: { return dash.getEscapeFunction(); - case binZsh: + } + case binZsh: { return zsh.getEscapeFunction(); + } } } @@ -89,16 +94,21 @@ export function getEscapeFunction(shellName) { */ export function getQuoteFunction(shellName) { switch (shellName) { - case noShell: + case noShell: { return nosh.getQuoteFunction(); - case binBash: + } + case binBash: { return bash.getQuoteFunction(); - case binCsh: + } + case binCsh: { return csh.getQuoteFunction(); - case binDash: + } + case binDash: { return dash.getQuoteFunction(); - case binZsh: + } + case binZsh: { return zsh.getQuoteFunction(); + } } } @@ -110,16 +120,21 @@ export function getQuoteFunction(shellName) { */ export function getFlagProtectionFunction(shellName) { switch (shellName) { - case noShell: + case noShell: { return nosh.getFlagProtectionFunction(); - case binBash: + } + case binBash: { return bash.getFlagProtectionFunction(); - case binCsh: + } + case binCsh: { return csh.getFlagProtectionFunction(); - case binDash: + } + case binDash: { return dash.getFlagProtectionFunction(); - case binZsh: + } + case binZsh: { return zsh.getFlagProtectionFunction(); + } } } diff --git a/src/internal/win.js b/src/internal/win.js index 88d41d63b..28625bee0 100644 --- a/src/internal/win.js +++ b/src/internal/win.js @@ -61,10 +61,12 @@ export function getEscapeFunction(shellName) { } switch (shellName.toLowerCase()) { - case binCmd: + case binCmd: { return cmd.getEscapeFunction(); - case binPowerShell: + } + case binPowerShell: { return powershell.getEscapeFunction(); + } } } @@ -81,10 +83,12 @@ export function getQuoteFunction(shellName) { } switch (shellName.toLowerCase()) { - case binCmd: + case binCmd: { return cmd.getQuoteFunction(); - case binPowerShell: + } + case binPowerShell: { return powershell.getQuoteFunction(); + } } } @@ -100,10 +104,12 @@ export function getFlagProtectionFunction(shellName) { } switch (shellName.toLowerCase()) { - case binCmd: + case binCmd: { return cmd.getFlagProtectionFunction(); - case binPowerShell: + } + case binPowerShell: { return powershell.getFlagProtectionFunction(); + } } } diff --git a/src/modules/testing.js b/src/modules/testing.js index f2a04df5a..6947464c0 100644 --- a/src/modules/testing.js +++ b/src/modules/testing.js @@ -16,7 +16,7 @@ import { checkedToString } from "../internal/reflection.js"; * } */ export const injectionStrings = [ - "\x00world", + "\u0000world", "&& ls", "'; ls #", '"; ls #', @@ -77,7 +77,7 @@ export class Stubscape { quote(arg) { if (this.shell === false) { - throw new Error(); + throw new Error("Shell may not be false"); } return this.escape(arg); diff --git a/test/_arbitraries.js b/test/_arbitraries.js index 0438a694c..85849cbbb 100644 --- a/test/_arbitraries.js +++ b/test/_arbitraries.js @@ -17,8 +17,11 @@ import * as constants from "./_constants.js"; * @param {string[]} [args.keys] Keys that should appear in the environment. * @returns {object} Arbitrary `process.env`s. */ -export const env = ({ keys } = { keys: [] }) => - fc.dictionary(fc.oneof(fc.string(), ...keys.map(fc.constant)), fc.string()); +export const env = ({ keys } = {}) => + fc.dictionary( + fc.oneof(fc.string(), ...(keys || []).map((key) => fc.constant(key))), + fc.string(), + ); /** * The osType arbitrary generates known OS types. diff --git a/test/_runners.js b/test/_runners.js index e8a41dd28..98ae5d300 100644 --- a/test/_runners.js +++ b/test/_runners.js @@ -31,7 +31,7 @@ function isShellCmd(shell) { * @returns {boolean} `true` if `shell` is csh, `false` otherwise. */ function isShellCsh(shell) { - return /csh$/u.test(shell); + return typeof shell === "string" && shell.endsWith("csh"); } /** @@ -118,8 +118,8 @@ export function execQuote({ arg, shell }) { try { assert.strictEqual(result, expected); resolve(); - } catch (e) { - reject(e); + } catch (error) { + reject(error); } } }, @@ -194,8 +194,8 @@ export function execEscape({ arg, shell }) { try { assert.strictEqual(result, expected); resolve(); - } catch (e) { - reject(e); + } catch (error) { + reject(error); } } }, @@ -274,8 +274,8 @@ export function execFile({ arg, shell }) { try { assert.strictEqual(result, expected); resolve(); - } catch (e) { - reject(e); + } catch (error) { + reject(error); } } }, @@ -352,8 +352,8 @@ export function fork(arg) { try { assert.strictEqual(result, expected); resolve(); - } catch (e) { - reject(e); + } catch (error) { + reject(error); } }); }); @@ -398,8 +398,8 @@ export function spawn({ arg, shell }) { try { assert.strictEqual(result, expected); resolve(); - } catch (e) { - reject(e); + } catch (error) { + reject(error); } }); }); diff --git a/test/breakage/_.js b/test/breakage/_.js index 9c14ed685..d96f6cbb5 100644 --- a/test/breakage/_.js +++ b/test/breakage/_.js @@ -3,6 +3,4 @@ * @license MIT */ -import * as arbitrary from "../_arbitraries.js"; - -export { arbitrary }; +export * as arbitrary from "../_arbitraries.js"; diff --git a/test/breakage/index.test.js b/test/breakage/index.test.js index 22847538c..6e333c4b5 100644 --- a/test/breakage/index.test.js +++ b/test/breakage/index.test.js @@ -20,13 +20,13 @@ testProp( try { shescape = new Shescape(options); - } catch (_) { + } catch { errored = true; } try { previouscape = new Previouscape(options); - } catch (_) { + } catch { previousErrored = true; } @@ -45,14 +45,14 @@ testProp( try { shescape = new Shescape(options); result = shescape.escape(arg); - } catch (_) { + } catch { errored = true; } try { previouscape = new Previouscape(options); previousResult = previouscape.escape(arg); - } catch (_) { + } catch { previousErrored = true; } @@ -75,14 +75,14 @@ testProp( try { shescape = new Shescape(options); result = shescape.escapeAll(args); - } catch (_) { + } catch { errored = true; } try { previouscape = new Previouscape(options); previousResult = previouscape.escapeAll(args); - } catch (_) { + } catch { previousErrored = true; } @@ -102,14 +102,14 @@ testProp( try { shescape = new Shescape(options); result = shescape.quote(arg); - } catch (_) { + } catch { errored = true; } try { previouscape = new Previouscape(options); previousResult = previouscape.quote(arg); - } catch (_) { + } catch { previousErrored = true; } @@ -132,14 +132,14 @@ testProp( try { shescape = new Shescape(options); result = shescape.quoteAll(args); - } catch (_) { + } catch { errored = true; } try { previouscape = new Previouscape(options); previousResult = previouscape.quoteAll(args); - } catch (_) { + } catch { previousErrored = true; } diff --git a/test/breakage/stateless.test.js b/test/breakage/stateless.test.js index 8a9584914..348ffc728 100644 --- a/test/breakage/stateless.test.js +++ b/test/breakage/stateless.test.js @@ -20,13 +20,13 @@ testProp( try { result = shescape.escape(arg, options); - } catch (_) { + } catch { errored = true; } try { previousResult = previouscape.escape(arg, options); - } catch (_) { + } catch { previousErrored = true; } @@ -47,13 +47,13 @@ testProp( try { result = shescape.escapeAll(args, options); - } catch (_) { + } catch { errored = true; } try { previousResult = previouscape.escapeAll(args, options); - } catch (_) { + } catch { previousErrored = true; } @@ -71,13 +71,13 @@ testProp( try { result = shescape.quote(arg, options); - } catch (_) { + } catch { errored = true; } try { previousResult = previouscape.quote(arg, options); - } catch (_) { + } catch { previousErrored = true; } @@ -98,13 +98,13 @@ testProp( try { result = shescape.quoteAll(args, options); - } catch (_) { + } catch { errored = true; } try { previousResult = previouscape.quoteAll(args, options); - } catch (_) { + } catch { previousErrored = true; } diff --git a/test/breakage/testing.test.js b/test/breakage/testing.test.js index 1e31b96a8..76ec9ea08 100644 --- a/test/breakage/testing.test.js +++ b/test/breakage/testing.test.js @@ -23,13 +23,13 @@ testProp( try { stubscape = new Stubscape(options); - } catch (_) { + } catch { errored = true; } try { previoustub = new Previoustub(options); - } catch (_) { + } catch { previousErrored = true; } @@ -48,14 +48,14 @@ testProp( try { stubscape = new Stubscape(options); result = stubscape.escape(arg); - } catch (_) { + } catch { errored = true; } try { previoustub = new Previoustub(options); previousResult = previoustub.escape(arg); - } catch (_) { + } catch { previousErrored = true; } @@ -78,14 +78,14 @@ testProp( try { stubscape = new Stubscape(options); result = stubscape.escapeAll(args); - } catch (_) { + } catch { errored = true; } try { previoustub = new Previoustub(options); previousResult = previoustub.escapeAll(args); - } catch (_) { + } catch { previousErrored = true; } @@ -105,14 +105,14 @@ testProp( try { stubscape = new Stubscape(options); result = stubscape.quote(arg); - } catch (_) { + } catch { errored = true; } try { previoustub = new Previoustub(options); previousResult = previoustub.quote(arg); - } catch (_) { + } catch { previousErrored = true; } @@ -135,14 +135,14 @@ testProp( try { stubscape = new Stubscape(options); result = stubscape.quoteAll(args); - } catch (_) { + } catch { errored = true; } try { previoustub = new Previoustub(options); previousResult = previoustub.quoteAll(args); - } catch (_) { + } catch { previousErrored = true; } @@ -160,13 +160,13 @@ testProp( try { throwscape = new Throwscape(options); - } catch (_) { + } catch { errored = true; } try { previousthrow = new Previousthrow(options); - } catch (_) { + } catch { previousErrored = true; } diff --git a/test/compat/_.js b/test/compat/_.js index 9c14ed685..d96f6cbb5 100644 --- a/test/compat/_.js +++ b/test/compat/_.js @@ -3,6 +3,4 @@ * @license MIT */ -import * as arbitrary from "../_arbitraries.js"; - -export { arbitrary }; +export * as arbitrary from "../_arbitraries.js"; diff --git a/test/compat/testing.test.js b/test/compat/testing.test.js index e15a30765..7086f1185 100644 --- a/test/compat/testing.test.js +++ b/test/compat/testing.test.js @@ -75,7 +75,7 @@ export function testStubscapeQuote() { try { stubscape.quote(arg); } catch (error) { - const knownErrors = [""]; + const knownErrors = ["Shell may not be false"]; if (!knownErrors.includes(error.message)) { throw new Error(`Unexpected error:\n${error}`); @@ -103,7 +103,7 @@ export function testStubscapeQuoteAll() { try { stubscape.quoteAll(args); } catch (error) { - const knownErrors = [""]; + const knownErrors = ["Shell may not be false"]; if (!knownErrors.includes(error.message)) { throw new Error(`Unexpected error:\n${error}`); diff --git a/test/e2e/_.js b/test/e2e/_.js index 310b21b4a..0be15ab62 100644 --- a/test/e2e/_.js +++ b/test/e2e/_.js @@ -3,8 +3,6 @@ * @license MIT */ -import * as constants from "../_constants.js"; -import * as common from "./_common.js"; -import * as macros from "./_macros.js"; - -export { common, constants, macros }; +export * as constants from "../_constants.js"; +export * as common from "./_common.js"; +export * as macros from "./_macros.js"; diff --git a/test/e2e/_common.js b/test/e2e/_common.js index e0509419d..e1be8a8e8 100644 --- a/test/e2e/_common.js +++ b/test/e2e/_common.js @@ -34,7 +34,7 @@ export function getTestFn(shell) { } return test; - } catch (_) { + } catch { return test.skip; } } diff --git a/test/fixtures/unix.js b/test/fixtures/unix.js index 5aaab0590..3d6858804 100644 --- a/test/fixtures/unix.js +++ b/test/fixtures/unix.js @@ -15,19 +15,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -1227,19 +1227,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -2439,19 +2439,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -3567,19 +3567,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -4665,19 +4665,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -6201,19 +6201,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "'ab'", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "'abc'", }, { - input: "a\x00", + input: "a\u0000", expected: "'a'", }, { - input: "\x00a", + input: "\u0000a", expected: "'a'", }, ], @@ -6389,19 +6389,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "'ab'", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "'abc'", }, { - input: "a\x00", + input: "a\u0000", expected: "'a'", }, { - input: "\x00a", + input: "\u0000a", expected: "'a'", }, ], @@ -6595,19 +6595,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "'ab'", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "'abc'", }, { - input: "a\x00", + input: "a\u0000", expected: "'a'", }, { - input: "\x00a", + input: "\u0000a", expected: "'a'", }, ], @@ -6783,19 +6783,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "'ab'", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "'abc'", }, { - input: "a\x00", + input: "a\u0000", expected: "'a'", }, { - input: "\x00a", + input: "\u0000a", expected: "'a'", }, ], diff --git a/test/fixtures/win.js b/test/fixtures/win.js index c650972be..5dfd8eaa9 100644 --- a/test/fixtures/win.js +++ b/test/fixtures/win.js @@ -15,19 +15,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -1193,19 +1193,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -2371,19 +2371,19 @@ export const escape = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -4271,19 +4271,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "ab", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "abc", }, { - input: "a\x00", + input: "a\u0000", expected: "a", }, { - input: "\x00a", + input: "\u0000a", expected: "a", }, ], @@ -4933,19 +4933,19 @@ export const quote = { ], " (\\0)": [ { - input: "a\x00b", + input: "a\u0000b", expected: "'ab'", }, { - input: "a\x00b\x00c", + input: "a\u0000b\u0000c", expected: "'abc'", }, { - input: "a\x00", + input: "a\u0000", expected: "'a'", }, { - input: "\x00a", + input: "\u0000a", expected: "'a'", }, ], diff --git a/test/fuzz/_.js b/test/fuzz/_.js index 93fed1caf..303ef3977 100644 --- a/test/fuzz/_.js +++ b/test/fuzz/_.js @@ -3,7 +3,5 @@ * @license MIT */ -import * as runners from "../_runners.js"; -import * as common from "./_common.js"; - -export { common, runners }; +export * as runners from "../_runners.js"; +export * as common from "./_common.js"; diff --git a/test/fuzz/_common.js b/test/fuzz/_common.js index cedcafee0..17f53a707 100644 --- a/test/fuzz/_common.js +++ b/test/fuzz/_common.js @@ -23,7 +23,7 @@ export function corpus() { const corpus = []; for (const file of files) { const filepath = path.resolve(corpusDir, file); - const example = fs.readFileSync(filepath, { encoding: "utf-8" }); + const example = fs.readFileSync(filepath, { encoding: "utf8" }); corpus.push([example]); } @@ -40,12 +40,15 @@ export function getFuzzShell() { switch (shell) { case undefined: case "false": - case "": + case "": { return false; - case "true": + } + case "true": { return true; - default: + } + default: { return shell; + } } } @@ -60,6 +63,6 @@ export function getIterations() { return Infinity; } - const parsed = parseInt(iterations, 10); + const parsed = Number.parseInt(iterations, 10); return parsed; } diff --git a/test/integration/_.js b/test/integration/_.js index 478c458d8..1c9f3a1cf 100644 --- a/test/integration/_.js +++ b/test/integration/_.js @@ -3,10 +3,8 @@ * @license MIT */ -import * as arbitrary from "../_arbitraries.js"; -import * as constants from "../_constants.js"; -import * as macros from "../_macros.js"; -import * as common from "./_common.js"; -import * as generate from "./_generators.js"; - -export { arbitrary, common, constants, generate, macros }; +export * as arbitrary from "../_arbitraries.js"; +export * as constants from "../_constants.js"; +export * as macros from "../_macros.js"; +export * as common from "./_common.js"; +export * as generate from "./_generators.js"; diff --git a/test/integration/_common.js b/test/integration/_common.js index 65eb933e5..ddb5cfea1 100644 --- a/test/integration/_common.js +++ b/test/integration/_common.js @@ -34,7 +34,7 @@ export function getTestFn(shell) { } return test; - } catch (_) { + } catch { return test.skip; } } diff --git a/test/integration/constructor/_.js b/test/integration/constructor/_.js index 8f57a9db7..86d50a305 100644 --- a/test/integration/constructor/_.js +++ b/test/integration/constructor/_.js @@ -3,6 +3,4 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; - -export { arbitrary }; +export * as arbitrary from "../../_arbitraries.js"; diff --git a/test/integration/constructor/constructor.test.js b/test/integration/constructor/constructor.test.js index 81f4e627a..86ce4e517 100644 --- a/test/integration/constructor/constructor.test.js +++ b/test/integration/constructor/constructor.test.js @@ -29,12 +29,12 @@ testProp( arbitrary .shescapeOptions() .filter((options) => options !== undefined) - .map(ppTestKit.wrap), + .map((options) => ppTestKit.wrap(options)), ], (t, options) => { try { new Shescape(options); - } catch (_) {} + } catch {} ppTestKit.check(options); t.pass(); diff --git a/test/integration/escape-all/invalid.test.js b/test/integration/escape-all/invalid.test.js index b429c59d9..a77384978 100644 --- a/test/integration/escape-all/invalid.test.js +++ b/test/integration/escape-all/invalid.test.js @@ -13,7 +13,7 @@ testProp("invalid arguments", [arbitrary.shescapeOptions()], (t, options) => { let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/escape-all/valid.test.js b/test/integration/escape-all/valid.test.js index 16ef04a1b..636d43977 100644 --- a/test/integration/escape-all/valid.test.js +++ b/test/integration/escape-all/valid.test.js @@ -17,7 +17,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -36,7 +36,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -56,7 +56,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -77,7 +77,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/escape/invalid.test.js b/test/integration/escape/invalid.test.js index 508d5ef7d..e2ebb06d8 100644 --- a/test/integration/escape/invalid.test.js +++ b/test/integration/escape/invalid.test.js @@ -13,7 +13,7 @@ testProp("invalid arguments", [arbitrary.shescapeOptions()], (t, options) => { let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/escape/valid.test.js b/test/integration/escape/valid.test.js index b118c4f05..3e99a3177 100644 --- a/test/integration/escape/valid.test.js +++ b/test/integration/escape/valid.test.js @@ -16,7 +16,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/quote-all/invalid.test.js b/test/integration/quote-all/invalid.test.js index 2deac010e..2d8a2a9df 100644 --- a/test/integration/quote-all/invalid.test.js +++ b/test/integration/quote-all/invalid.test.js @@ -29,7 +29,7 @@ testProp("invalid arguments", [arbitrary.shescapeOptions()], (t, options) => { let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/quote-all/valid.test.js b/test/integration/quote-all/valid.test.js index 3e331c40c..ce1519725 100644 --- a/test/integration/quote-all/valid.test.js +++ b/test/integration/quote-all/valid.test.js @@ -20,7 +20,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -42,7 +42,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -62,7 +62,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -86,7 +86,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/quote/invalid.test.js b/test/integration/quote/invalid.test.js index 4187204d4..d6f8c7440 100644 --- a/test/integration/quote/invalid.test.js +++ b/test/integration/quote/invalid.test.js @@ -25,7 +25,7 @@ testProp("invalid arguments", [arbitrary.shescapeOptions()], (t, options) => { let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/quote/valid.test.js b/test/integration/quote/valid.test.js index 597c7b351..ec3c47242 100644 --- a/test/integration/quote/valid.test.js +++ b/test/integration/quote/valid.test.js @@ -19,7 +19,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } diff --git a/test/integration/testing/commonjs.test.js b/test/integration/testing/commonjs.test.js index 948e8c9d2..c0f7739a5 100644 --- a/test/integration/testing/commonjs.test.js +++ b/test/integration/testing/commonjs.test.js @@ -43,13 +43,13 @@ testProp( let erroredEsm, erroredCjs; try { failscape.escape(arg); - } catch (_) { + } catch { erroredEsm = true; } try { failscapeCjs.escape(arg); - } catch (_) { + } catch { erroredCjs = true; } @@ -67,13 +67,13 @@ testProp( let erroredEsm, erroredCjs; try { failscape.escapeAll(args); - } catch (_) { + } catch { erroredEsm = true; } try { failscapeCjs.escapeAll(args); - } catch (_) { + } catch { erroredCjs = true; } @@ -91,13 +91,13 @@ testProp( let erroredEsm, erroredCjs; try { failscape.quote(arg); - } catch (_) { + } catch { erroredEsm = true; } try { failscapeCjs.quote(arg); - } catch (_) { + } catch { erroredCjs = true; } @@ -115,13 +115,13 @@ testProp( let erroredEsm, erroredCjs; try { failscape.quoteAll(args); - } catch (_) { + } catch { erroredEsm = true; } try { failscapeCjs.quoteAll(args); - } catch (_) { + } catch { erroredCjs = true; } @@ -166,13 +166,13 @@ testProp( try { resultEsm = stubscape.quote(arg); - } catch (_) { + } catch { erroredEsm = true; } try { resultCjs = stubscapeCjs.quote(arg); - } catch (_) { + } catch { erroredCjs = true; } @@ -192,13 +192,13 @@ testProp( try { resultEsm = stubscape.quoteAll(args); - } catch (_) { + } catch { erroredEsm = true; } try { resultCjs = stubscapeCjs.quoteAll(args); - } catch (_) { + } catch { erroredCjs = true; } @@ -215,13 +215,13 @@ testProp( try { new Throwscape(options); - } catch (_) { + } catch { erroredEsm = true; } try { new ThrowscapeCjs(options); - } catch (_) { + } catch { erroredCjs = true; } diff --git a/test/integration/testing/functional.test.js b/test/integration/testing/functional.test.js index 2d3775dfe..b35eac560 100644 --- a/test/integration/testing/functional.test.js +++ b/test/integration/testing/functional.test.js @@ -85,7 +85,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -93,13 +93,13 @@ testProp( try { result = shescape.escape(arg); - } catch (_) { + } catch { errored = true; } try { stubResult = stubscape.escape(arg); - } catch (_) { + } catch { stubErrored = true; } @@ -117,7 +117,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -125,13 +125,13 @@ testProp( try { result = shescape.escapeAll(args); - } catch (_) { + } catch { errored = true; } try { stubResult = stubscape.escapeAll(args); - } catch (_) { + } catch { stubErrored = true; } @@ -149,7 +149,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -157,13 +157,13 @@ testProp( try { result = shescape.quote(arg); - } catch (_) { + } catch { errored = true; } try { stubResult = stubscape.quote(arg); - } catch (_) { + } catch { stubErrored = true; } @@ -172,6 +172,18 @@ testProp( }, ); +test("stubscape#quote with shell set to false", (t) => { + const stubscape = new Stubscape({ shell: false }); + t.throws( + () => { + stubscape.quote("anything"); + }, + { + message: "Shell may not be false", + }, + ); +}); + testProp( "Stubscape#quoteAll, with shell (stubscape =~ shescape)", [fc.anything(), arbitrary.shescapeOptions()], @@ -181,7 +193,7 @@ testProp( let shescape; try { shescape = new Shescape(options); - } catch (_) { + } catch { return t.pass(); } @@ -189,13 +201,13 @@ testProp( try { result = shescape.quoteAll(args); - } catch (_) { + } catch { errored = true; } try { stubResult = stubscape.quoteAll(args); - } catch (_) { + } catch { stubErrored = true; } @@ -204,6 +216,18 @@ testProp( }, ); +test("stubscape#quoteAll with shell set to false", (t) => { + const stubscape = new Stubscape({ shell: false }); + t.throws( + () => { + stubscape.quoteAll(["any", "thing"]); + }, + { + message: "Shell may not be false", + }, + ); +}); + testProp( "Throwscape#constructor", [arbitrary.shescapeOptions()], diff --git a/test/unit/_macros.js b/test/unit/_macros.js index 6d68778be..7f83a9c43 100644 --- a/test/unit/_macros.js +++ b/test/unit/_macros.js @@ -116,7 +116,7 @@ export const duration = test.macro({ const startTime = performance.now(); try { fn(...args); - } catch (_) { + } catch { // not concerned about functional correctness } const endTime = performance.now(); diff --git a/test/unit/executables/_.js b/test/unit/executables/_.js index 8f57a9db7..86d50a305 100644 --- a/test/unit/executables/_.js +++ b/test/unit/executables/_.js @@ -3,6 +3,4 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; - -export { arbitrary }; +export * as arbitrary from "../../_arbitraries.js"; diff --git a/test/unit/options/_.js b/test/unit/options/_.js index 8f57a9db7..86d50a305 100644 --- a/test/unit/options/_.js +++ b/test/unit/options/_.js @@ -3,6 +3,4 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; - -export { arbitrary }; +export * as arbitrary from "../../_arbitraries.js"; diff --git a/test/unit/platforms/_.js b/test/unit/platforms/_.js index fecc2338c..81a14b4fe 100644 --- a/test/unit/platforms/_.js +++ b/test/unit/platforms/_.js @@ -3,7 +3,5 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; -import * as constants from "../../_constants.js"; - -export { arbitrary, constants }; +export * as arbitrary from "../../_arbitraries.js"; +export * as constants from "../../_constants.js"; diff --git a/test/unit/reflection/_.js b/test/unit/reflection/_.js index fecc2338c..81a14b4fe 100644 --- a/test/unit/reflection/_.js +++ b/test/unit/reflection/_.js @@ -3,7 +3,5 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; -import * as constants from "../../_constants.js"; - -export { arbitrary, constants }; +export * as arbitrary from "../../_arbitraries.js"; +export * as constants from "../../_constants.js"; diff --git a/test/unit/unix/_.js b/test/unit/unix/_.js index cab06a380..dc9176bc4 100644 --- a/test/unit/unix/_.js +++ b/test/unit/unix/_.js @@ -3,9 +3,7 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; -import * as constants from "../../_constants.js"; -import * as fixtures from "../../fixtures/unix.js"; -import * as macros from "../_macros.js"; - -export { arbitrary, constants, fixtures, macros }; +export * as arbitrary from "../../_arbitraries.js"; +export * as constants from "../../_constants.js"; +export * as fixtures from "../../fixtures/unix.js"; +export * as macros from "../_macros.js"; diff --git a/test/unit/unix/csh.test.js b/test/unit/unix/csh.test.js index c274ca177..367e9da35 100644 --- a/test/unit/unix/csh.test.js +++ b/test/unit/unix/csh.test.js @@ -11,7 +11,7 @@ import * as fc from "fast-check"; import * as csh from "../../../src/internal/unix/csh.js"; -const textDecoder = new TextDecoder("utf-8", { fatal: true }); +const textDecoder = new TextDecoder("utf8", { fatal: true }); testProp( "characters with 0xA0 when utf-8 encoded", @@ -28,7 +28,7 @@ testProp( ...uint8Array.slice(insertIndex), ]); return textDecoder.decode(utf8EncodedCharacter); - } catch (_) { + } catch { return null; } }) @@ -36,9 +36,9 @@ testProp( ], (t, [baseString, insertIndex], testCharacter) => { const testStr = - baseString.substring(0, insertIndex) + + baseString.slice(0, insertIndex) + testCharacter + - baseString.substring(insertIndex); + baseString.slice(insertIndex); const escapeFn = csh.getEscapeFunction(); const result = escapeFn(testStr); diff --git a/test/unit/unix/shells.test.js b/test/unit/unix/shells.test.js index 3128cbfc8..682af9fa3 100644 --- a/test/unit/unix/shells.test.js +++ b/test/unit/unix/shells.test.js @@ -29,14 +29,14 @@ for (const [shellName, shellExports] of Object.entries(shells)) { const quoteFixtures = Object.values(fixtures.quote[shellName]).flat(); const redosFixtures = fixtures.redos(); - escapeFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of escapeFixtures) { test(macros.escape, { expected, input, getEscapeFunction: shellExports.getEscapeFunction, shellName, }); - }); + } testProp(`escape function for ${shellName}`, [fc.string()], (t, arg) => { const escapeFn = shellExports.getEscapeFunction(); @@ -50,22 +50,23 @@ for (const [shellName, shellExports] of Object.entries(shells)) { setup: shellExports.getEscapeFunction, }); - redosFixtures.forEach((input, id) => { - test(`${shellName}, ReDoS #${id}`, (t) => { + for (const i in redosFixtures) { + const input = redosFixtures[i]; + test(`${shellName}, ReDoS #${i}`, (t) => { const escape = shellExports.getEscapeFunction(); escape(input); t.pass(); }); - }); + } - flagFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of flagFixtures) { test(macros.flag, { expected: expected.unquoted, input, getFlagProtectionFunction: shellExports.getFlagProtectionFunction, shellName, }); - }); + } testProp( `flag protection function for ${shellName}`, @@ -84,14 +85,14 @@ for (const [shellName, shellExports] of Object.entries(shells)) { }); if (shellExports !== nosh) { - quoteFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of quoteFixtures) { test(macros.quote, { expected, input, getQuoteFunction: shellExports.getQuoteFunction, shellName, }); - }); + } testProp(`quote function for ${shellName}`, [fc.string()], (t, arg) => { const [escapeFn, quoteFn] = shellExports.getQuoteFunction(); diff --git a/test/unit/win/_.js b/test/unit/win/_.js index 91a91fcd4..0265d9b6b 100644 --- a/test/unit/win/_.js +++ b/test/unit/win/_.js @@ -3,9 +3,7 @@ * @license MIT */ -import * as arbitrary from "../../_arbitraries.js"; -import * as constants from "../../_constants.js"; -import * as fixtures from "../../fixtures/win.js"; -import * as macros from "../_macros.js"; - -export { arbitrary, constants, fixtures, macros }; +export * as arbitrary from "../../_arbitraries.js"; +export * as constants from "../../_constants.js"; +export * as fixtures from "../../fixtures/win.js"; +export * as macros from "../_macros.js"; diff --git a/test/unit/win/shells.test.js b/test/unit/win/shells.test.js index 3505b194e..1ce84a64a 100644 --- a/test/unit/win/shells.test.js +++ b/test/unit/win/shells.test.js @@ -24,14 +24,14 @@ for (const [shellName, shellExports] of Object.entries(shells)) { const flagFixtures = Object.values(fixtures.flag[shellName]).flat(); const quoteFixtures = Object.values(fixtures.quote[shellName]).flat(); - escapeFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of escapeFixtures) { test(macros.escape, { expected, input, getEscapeFunction: shellExports.getEscapeFunction, shellName, }); - }); + } testProp(`escape function for ${shellName}`, [fc.string()], (t, arg) => { const escapeFn = shellExports.getEscapeFunction(); @@ -45,14 +45,14 @@ for (const [shellName, shellExports] of Object.entries(shells)) { setup: shellExports.getEscapeFunction, }); - flagFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of flagFixtures) { test(macros.flag, { expected: expected.unquoted, input, getFlagProtectionFunction: shellExports.getFlagProtectionFunction, shellName, }); - }); + } testProp( `flag protection function for ${shellName}`, @@ -71,14 +71,14 @@ for (const [shellName, shellExports] of Object.entries(shells)) { }); if (shellExports !== nosh) { - quoteFixtures.forEach(({ input, expected }) => { + for (const { input, expected } of quoteFixtures) { test(macros.quote, { expected, input, getQuoteFunction: shellExports.getQuoteFunction, shellName, }); - }); + } testProp(`quote function for ${shellName}`, [fc.string()], (t, arg) => { const [escapeFn, quoteFn] = shellExports.getQuoteFunction();