sinonjs / commons Goto Github PK
View Code? Open in Web Editor NEWSimple functions shared among the sinon end user libraries
License: BSD 3-Clause "New" or "Revised" License
Simple functions shared among the sinon end user libraries
License: BSD 3-Clause "New" or "Revised" License
The recent change you've made cace9e6
is breaking all of our unit tests that use @sinonjs/commons with the following error:
/srv/node_modules/collections/_map.js:162
return this.size;
^
TypeError: Method get Map.prototype.size called on incompatible receiver #<Map>
at Map.get size [as size] (<anonymous>)
at Map.get [as length] (/srv/node_modules/collections/_map.js:162:25)
at /srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:14:29
at Array.reduce (<anonymous>)
at copyPrototypeMethods (/srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:7:50)
at Object.<anonymous> (/srv/node_modules/@sinonjs/commons/lib/prototypes/map.js:5:18)
Is it possible to revert this change? It's being included by other dependencies and full impact is not known at this point.
As suggested by @mroderick here, we can extract the get-class-name
function from @sinonjs/samsam
to use it in this package.
As per https://eslint.org/docs/user-guide/configuring#specifying-processor, overrides should be a list. This results in this error when using eslint 6.*:
Error: ESLint configuration in node_modules/@sinonjs/commons/.eslintrc.yaml is invalid:
- Property "overrides" is the wrong type (expected array but got `{"files":"*.test.*","plugins":["mocha"],"env":{"mocha":true},"rules":{"max-nested-callbacks":["warn",6],"mocha/handle-done-callback":"error","mocha/no-exclusive-tests":"error","mocha/no-global-tests":"error","mocha/no-hooks-for-single-case":"off","mocha/no-identical-title":"error","mocha/no-mocha-arrows":"error","mocha/no-nested-tests":"error","mocha/no-return-and-callback":"error","mocha/no-sibling-hooks":"error","mocha/no-skipped-tests":"error","mocha/no-top-level-hooks":"error","local-rules/no-prototype-methods":"off"}}`).
Hi,
when using node --disable-proto=throw
, @sinonjs/common is unusable. Here is a simple patch to fix this:
--- a/lib/prototypes/copy-prototype.js
+++ b/lib/prototypes/copy-prototype.js
@@ -11,6 +11,7 @@
name !== "caller" &&
name !== "callee" &&
name !== "arguments" &&
+ name !== "__proto__" &&
typeof prototype[name] === "function"
) {
result[name] = call.bind(prototype[name]);
Cheers,
Yadd
Got this error while using @google-cloud/[email protected]
which depends on sinonjs/[email protected]
.
Doing some research about this kind of error, realized something like "When this error is thrown, a function (on a given object), is called with a this not corresponding to the type expected by the function"
Detailed stack trace: TypeError: Method get Map.prototype.size called on incompatible receiver #<Map>
at Map.get size [as size] (<anonymous>)
at Map.get [as length] (/srv/node_modules/collections/_map.js:162:25)
at /srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:14:29
at Array.reduce (<anonymous>)
at copyPrototypeMethods (/srv/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype.js:7:50)
at Object.<anonymous> (/srv/node_modules/@sinonjs/commons/lib/prototypes/map.js:5:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/node_modules/@sinonjs/commons/lib/prototypes/index.js:6:10)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
Just curious why or if there are benefits to this way or downsides to the other? That is all.
Currently, deprecations are only printed to stdout. But this can make the warnings hard to process. For example, failing a build when a deprecation is detected would require grepping stdout.
To solve this, many libraries, include Nodejs itself, emit some kind of deprecation event. This could take the form of process.emitWarning
or util.deprecate
.
Some resources:
https://www.npmjs.com/package/depd
https://nodejs.org/api/deprecations.html
Related to sinonjs/formatio#14
with a line like this in .npmrc:
_auth="test"
I get this:
$ npm install @sinonjs/[email protected]
npm ERR! code E404
npm ERR! 404 Not Found: @sinonjs/[email protected]
This works though, even with the _auth line in .npmrc
$ npm install @sinonjs/[email protected]
+ @sinonjs/[email protected]
updated 1 package and audited 5 packages in 0.627s
found 0 vulnerabilities
$ npm --version
6.4.0
The most recent release of @sinonjs/commons (version 1.8.4) breaks ES5 compatibility with older versions of Sinon (version 9 or lower).
node_modules/sinon/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js:27
if (disallowedProperties.includes(name)) {
^
TypeError: disallowedProperties.includes is not a function
This observed failure is related to the Array.prototype.includes function in the copy-prototype-methods file:
https://github.com/sinonjs/commons/blob/main/lib/prototypes/copy-prototype-methods.js#L27
Older versions of Sinon automatically update to this version of sinonjs/commons and begin failing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.