diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 09aa85d36..f064fb741 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -4,13 +4,16 @@ This file is the canonical resource for compatibility goals for the libraries th ## ES2017 -The source is as [ES2017][es2017] and requires no transpiler or polyfills in supporting runtimes. +Sinon has historically been written as [ES5][es5], but starting from Sinon 10 we made the breaking change to allow more modern ECMAScript versions, starting with ECMAScript [2017][es2017]. +The source version is [ES2017][es2017] and requires no transpiler or polyfills in supporting runtimes. -For legacy runtimes, a transpiler can be used by dependent projects. +For legacy runtimes, a transpiler can be used by dependent projects., but use of newer APIs might break. If you need to support older browsers, have a look at Sinon 9. ## Runtimes -Sinon.JS aims at supporting the following runtimes: +Sinon.JS aims at supporting the following runtimes (from our shared [eslint-config][shared-config]). + + ``` > 0.5% @@ -22,6 +25,8 @@ not op_mini all maintained node versions ``` + + The compatibility is enforced using [`eslint-plugin-compat`](https://www.npmjs.com/package/eslint-plugin-compat). To see what that means in practice, you can use https://browserslist.dev @@ -30,4 +35,6 @@ To see what that means in practice, you can use https://browserslist.dev Sauce Test Status

+[es5]: http://www.ecma-international.org/ecma-262/5.1/ [es2017]: https://262.ecma-international.org/8.0/ +[shared-config]: https://github.com/sinonjs/eslint-config diff --git a/docs/release-source/release.md b/docs/release-source/release.md index 902f8eb68..e1de08b5b 100644 --- a/docs/release-source/release.md +++ b/docs/release-source/release.md @@ -25,28 +25,14 @@ This page contains the entire Sinon.JS API documentation along with brief introd {% include docs/migration-guides.md %} -### Compatibility +## Compatibility and supported runtimes -### ES5.1 +As of Sinon 10 we stopped maintaining compatibility with legacy browsers. Instead, we focus on compatibility with evergreen browsers, [Node.js LTS versions](https://github.com/nodejs/Release) and recent Safari versions. +The most up-to-date reference on which runtimes and browsers we support can be found by looking at our [compatibility docs][compat-doc]. -Sinon `{{page.release_id}}` is written as [ES5.1][es5] and requires no transpiler or polyfills to run in the runtimes listed below. - -### Supported runtimes - -`{{page.release_id}}` has been verified in these runtimes: - -- Firefox 45 -- Chrome 48 -- Internet Explorer 11 -- Edge 14 -- Safari 9 -- [Node.js LTS versions](https://github.com/nodejs/Release) - -There should not be any issues with using Sinon `{{page.release_id}}` in newer versions of the same runtimes. - -If you need to support very old runtimes that have incomplete support for [ES5.1][es5] you might get away with using loading [`es5-shim`][es5-shim] in your test environment. +If you need to support old runtimes you can try [Sinon 9][compat-doc-v9]. {% include docs/contribute.md %} -[es5]: http://www.ecma-international.org/ecma-262/5.1/ -[es5-shim]: https://github.com/es-shims/es5-shim +[compat-doc]: https://github.com/sinonjs/sinon/COMPATIBILITY.md +[compat-doc-v9]: https://github.com/sinonjs/sinon/blob/v9.2.4/COMPATIBILITY.md diff --git a/package-lock.json b/package-lock.json index 1b278ed3a..6494ecb1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -192,9 +192,9 @@ } }, "@babel/helper-validator-identifier": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz", - "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz", + "integrity": "sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A==", "dev": true }, "@babel/helpers": { @@ -382,9 +382,9 @@ } }, "@eslint/eslintrc": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.0.tgz", - "integrity": "sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.1.tgz", + "integrity": "sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -528,9 +528,9 @@ } }, "@sinonjs/eslint-config": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/eslint-config/-/eslint-config-4.0.0.tgz", - "integrity": "sha512-Pn5RYbBd21kDcbxRdS70WElNG/h6t9J+mHCl25/m0l3B2r0TPw58cJ19rkAu8MN6TKJP/5QHuTIKhvFGWV8V5Q==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/eslint-config/-/eslint-config-4.0.2.tgz", + "integrity": "sha512-r7niZxl1vi6AyRjfSKZv1RrLDhfi3jAo8syCtDkY3RjRzweeu+r2Vgx8StLoBTCeKWLjKy6lYwWO4Y/OhHTVbw==", "dev": true, "requires": { "eslint": "^7.20.0", @@ -540,9 +540,9 @@ } }, "@sinonjs/eslint-plugin-no-prototype-methods": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@sinonjs/eslint-plugin-no-prototype-methods/-/eslint-plugin-no-prototype-methods-0.1.0.tgz", - "integrity": "sha512-xmku+RITfEh9jDgjWl6mrVIdrxkBYSYwblQUVKpie5g8HrVyEGx1+uy5jtE35zZZOJo8ayVLQKb0WZ/Iff+ZaA==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@sinonjs/eslint-plugin-no-prototype-methods/-/eslint-plugin-no-prototype-methods-0.1.1.tgz", + "integrity": "sha512-i1Sdx81ns8QNJav+SKdveBRmW5CQR5Fo7sgjSqER1lfqSilKNgMuqHfgemUELDymilpjzZzFwPqoLf2NjGn0Nw==", "dev": true, "requires": { "requireindex": "~1.1.0" @@ -1354,16 +1354,16 @@ } }, "browserslist": { - "version": "4.16.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.3.tgz", - "integrity": "sha512-vIyhWmIkULaq04Gt93txdh+j02yX/JzlyhLYbV3YQCn/zvES3JnY7TifHHvvr1w5hTDluNKMkV05cs4vy8Q7sw==", + "version": "4.16.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz", + "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001181", - "colorette": "^1.2.1", - "electron-to-chromium": "^1.3.649", + "caniuse-lite": "^1.0.30001219", + "colorette": "^1.2.2", + "electron-to-chromium": "^1.3.723", "escalade": "^3.1.1", - "node-releases": "^1.1.70" + "node-releases": "^1.1.71" } }, "buffer": { @@ -1458,9 +1458,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001199", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001199.tgz", - "integrity": "sha512-ifbK2eChUCFUwGhlEzIoVwzFt1+iriSjyKKFYNfv6hN34483wyWpLLavYQXhnR036LhkdUYaSDpHg1El++VgHQ==", + "version": "1.0.30001228", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz", + "integrity": "sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A==", "dev": true }, "chalk": { @@ -1816,9 +1816,9 @@ "dev": true }, "comment-parser": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.1.2.tgz", - "integrity": "sha512-AOdq0i8ghZudnYv8RUnHrhTgafUGs61Rdz9jemU5x2lnZwAWyOq7vySo626K59e1fVKH1xSRorJwPVRLSWOoAQ==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.1.5.tgz", + "integrity": "sha512-RePCE4leIhBlmrqiYTvaqEeGYg7qpSl4etaIabKtdOQVi+mSTIBBklGUwIr79GXYnl3LpMwmDw4KeR2stNc6FA==", "dev": true }, "commondir": { @@ -1904,9 +1904,9 @@ "dev": true }, "core-js": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.9.1.tgz", - "integrity": "sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg==", + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.12.1.tgz", + "integrity": "sha512-Ne9DKPHTObRuB09Dru5AjwKjY4cJHVGu+y5f7coGn1E9Grkc3p2iBwE9AI/nJzsE29mQF7oq+mhYYRqOMFN1Bw==", "dev": true }, "core-util-is": { @@ -2099,12 +2099,12 @@ "dev": true }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "decamelize": { @@ -2326,9 +2326,9 @@ } }, "electron-to-chromium": { - "version": "1.3.687", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.687.tgz", - "integrity": "sha512-IpzksdQNl3wdgkzf7dnA7/v10w0Utf1dF2L+B4+gKrloBrxCut+au+kky3PYvle3RMdSxZP+UiCZtLbcYRxSNQ==", + "version": "1.3.727", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.727.tgz", + "integrity": "sha512-Mfz4FIB4FSvEwBpDfdipRIrwd6uo8gUDoRDF4QEYb4h4tSuI3ov594OrjU6on042UlFHouIJpClDODGkPcBSbg==", "dev": true }, "elegant-spinner": { @@ -2508,13 +2508,13 @@ } }, "eslint": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.21.0.tgz", - "integrity": "sha512-W2aJbXpMNofUp0ztQaF40fveSsJBjlSCSWpy//gzfTvwC+USs/nceBrKmlJOiM8r1bLwP2EuYkCqArn/6QTIgg==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.26.0.tgz", + "integrity": "sha512-4R1ieRf52/izcZE7AlLy56uIHHDLT74Yzz2Iv2l6kDaYvEu9x+wMB5dZArVL8SYGXSYV2YAg70FcW5Y5nGGNIg==", "dev": true, "requires": { "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.0", + "@eslint/eslintrc": "^0.4.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -2530,7 +2530,7 @@ "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", - "globals": "^12.1.0", + "globals": "^13.6.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", @@ -2538,7 +2538,7 @@ "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", @@ -2562,12 +2562,12 @@ } }, "@babel/highlight": { - "version": "7.13.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.13.10.tgz", - "integrity": "sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==", + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.0.tgz", + "integrity": "sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.12.11", + "@babel/helper-validator-identifier": "^7.14.0", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -2586,9 +2586,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -2637,12 +2637,12 @@ "dev": true }, "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "version": "13.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.8.0.tgz", + "integrity": "sha512-rHtdA6+PDBIjeEvA91rpqzEvk/k3/i7EeNQiryiWuJH0Hw9cpyJMAt2jtbAwUaRdhD+573X4vWw6IcjKPasi9Q==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.20.2" } }, "has-flag": { @@ -2688,9 +2688,9 @@ "dev": true }, "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -2722,6 +2722,12 @@ "requires": { "prelude-ls": "^1.2.1" } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true } } }, @@ -2790,33 +2796,24 @@ } }, "eslint-plugin-jsdoc": { - "version": "32.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.2.0.tgz", - "integrity": "sha512-ikeVeF3JVmzjcmGd04OZK0rXjgiw46TWtNX+OhyF2jQlw3w1CAU1vyAyLv8PZcIjp7WxP4N20Vg1CI9bp/52dw==", + "version": "32.3.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.4.tgz", + "integrity": "sha512-xSWfsYvffXnN0OkwLnB7MoDDDDjqcp46W7YlY1j7JyfAQBQ+WnGCfLov3gVNZjUGtK9Otj8mEhTZTqJu4QtIGA==", "dev": true, "requires": { - "comment-parser": "1.1.2", + "comment-parser": "1.1.5", "debug": "^4.3.1", "jsdoctypeparser": "^9.0.0", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "regextras": "^0.7.1", - "semver": "^7.3.4", + "semver": "^7.3.5", "spdx-expression-parse": "^3.0.1" }, "dependencies": { - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -2842,14 +2839,6 @@ "requires": { "eslint-utils": "^2.1.0", "ramda": "^0.27.1" - }, - "dependencies": { - "ramda": { - "version": "0.27.1", - "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz", - "integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==", - "dev": true - } } }, "eslint-scope": { @@ -2880,9 +2869,9 @@ } }, "eslint-visitor-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", - "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true }, "esm": { @@ -4128,6 +4117,12 @@ "xtend": "^4.0.0" } }, + "interpret": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", + "dev": true + }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -4878,6 +4873,12 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", @@ -4907,6 +4908,12 @@ "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, + "lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, "log-symbols": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", @@ -6627,6 +6634,12 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, + "ramda": { + "version": "0.27.1", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz", + "integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==", + "dev": true + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -6845,6 +6858,15 @@ } } }, + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "dev": true, + "requires": { + "resolve": "^1.1.6" + } + }, "regenerator-runtime": { "version": "0.13.3", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", @@ -7146,6 +7168,17 @@ "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", "dev": true }, + "shelljs": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz", + "integrity": "sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==", + "dev": true, + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -7684,21 +7717,23 @@ } }, "table": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz", - "integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.0.tgz", + "integrity": "sha512-SAM+5p6V99gYiiy2gT5ArdzgM1dLDed0nkrWmG6Fry/bUS/m9x83BwpJUOf1Qj/x2qJd+thL6IkIx7qPGRxqBw==", "dev": true, "requires": { - "ajv": "^7.0.2", - "lodash": "^4.17.20", + "ajv": "^8.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", - "string-width": "^4.2.0" + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0" }, "dependencies": { "ajv": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.2.1.tgz", - "integrity": "sha512-+nu0HDv7kNSOua9apAVc979qd932rrZeb3WOvoiD31A/p1mIE5/9bN2027pE2rOPYEdS3UHzsvof4hY+lM9/WQ==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.3.0.tgz", + "integrity": "sha512-RYE7B5An83d7eWnDR8kbdaIFqmKCNsP16ay1hDbJEU+sa0e3H9SebskCt0Uufem6cfAVu7Col6ubcn/W+Sm8/Q==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -7712,6 +7747,15 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } } } }, diff --git a/package.json b/package.json index 249dea64f..557fdbf78 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "pretest-webworker": "npm run build", "prebuild": "rimraf pkg && npm run check-dependencies", "postbuild": "npm run test-esm-bundle", + "prebuild-docs": "./scripts/update-compatibility.js", "prepublishOnly": "npm run build", "prettier:check": "prettier --check '**/*.{js,css,md}'", "prettier:write": "prettier --write '**/*.{js,css,md}'", @@ -79,12 +80,13 @@ }, "devDependencies": { "@babel/core": "^7.8.3", - "@sinonjs/eslint-config": "^4.0.0", - "@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.0", + "@sinonjs/eslint-config": "^4.0.2", + "@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1", "@sinonjs/referee": "^6.1.0", "babel-plugin-istanbul": "^6.0.0", "babelify": "^10.0.0", "browserify": "^16.5.0", + "debug": "^4.3.1", "dependency-check": "^4.1.0", "esm": "^3.2.25", "husky": "^4.2.1", @@ -97,7 +99,8 @@ "proxyquire-universal": "^2.1.0", "proxyquireify": "^3.2.1", "puppeteer": "^2.1.0", - "rimraf": "^3.0.0" + "rimraf": "^3.0.0", + "shelljs": "^0.8.4" }, "files": [ "lib", diff --git a/scripts/update-compatibility.js b/scripts/update-compatibility.js new file mode 100755 index 000000000..571d257de --- /dev/null +++ b/scripts/update-compatibility.js @@ -0,0 +1,81 @@ +#!/usr/bin/env nodejs +/* + * Purpose: update/align our docs and our .browserlistrc file + * so that we do not spread out-of-date information + * Background: https://github.com/sinonjs/sinon/pull/2366 + */ + +"use strict"; + +const shell = require("shelljs"); +const readline = require("readline"); +const fs = require("fs"); +const root = `${__dirname}/..`; +const sourceFile = `${root}/node_modules/@sinonjs/eslint-config/.browserslistrc`; +const compatibilityPath = `${root}/COMPATIBILITY.md`; +const debug = require("debug")("update-compatibility"); + +debug( + "Copy browserslistrc file to root for running our own linting using compat/compat" +); +shell.cp(sourceFile, root); + +debug( + `Inline browserslistrc file into ${compatibilityPath} to keep contents in-sync` +); +const rl = readline.createInterface({ + input: fs.createReadStream(compatibilityPath), +}); + +let changeLogData = ""; + +/* eslint-disable jsdoc/require-jsdoc, @sinonjs/no-prototype-methods/no-prototype-methods */ +function getKeyByValue(object, value) { + return Object.keys(object).find((key) => object[key] === value); +} + +const NOOP = {}; +const processLine = (() => { + let state; + const STATES = { + BEFORE: (line) => { + if (line.search("browserslist start") > -1) { + state = STATES.IN; + } + + return line; + }, + IN: (line) => { + if (line.search("browserslist end") > -1) { + state = STATES.AFTER; + // newlines following Prettier's formatting + return `\n\`\`\`\n${fs.readFileSync( + sourceFile + )}\`\`\`\n\n${line}`; + } + return NOOP; + }, + AFTER: (line) => line, + }; + state = STATES.BEFORE; + return (line) => { + debug(`current state: ${getKeyByValue(STATES, state)}`); + debug(`current line input: '${line}'`); + const val = state(line); + debug(`current line output: '${val}'`); + return val; + }; +})(); + +rl.on("line", (line) => { + const output = processLine(line); + changeLogData += output === NOOP ? "" : `${output}\n`; +}); + +rl.on("close", function () { + debug(`Updated file content:\n${changeLogData}`); + if (process.env.DRY_RUN) { + return; + } + fs.writeFileSync(compatibilityPath, changeLogData); +});