Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mark some known globals or their functions as impure (#4955)
* fix: mark Map is impure * test: tweak test * fix: mark some known globals or their functions as impure * chore<devDeps>: update lint-staged version * test: tweak test * test: add more test cases * test: tweak test
- Loading branch information
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'retain functions that accept a iterable that has side effects on iteration' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
let effects = 0; | ||
|
||
const iterable = { | ||
[Symbol.iterator]() { | ||
return { | ||
next() { | ||
effects++; | ||
return { done: true }; | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
new Map(iterable); | ||
new Set(iterable); | ||
new WeakMap(iterable); | ||
new WeakSet(iterable); | ||
Array.from(iterable); | ||
BigInt64Array.from(iterable); | ||
BigUint64Array.from(iterable); | ||
Float32Array.from(iterable); | ||
Float64Array.from(iterable); | ||
Int16Array.from(iterable); | ||
Int32Array.from(iterable); | ||
Int8Array.from(iterable); | ||
Uint16Array.from(iterable); | ||
Uint32Array.from(iterable); | ||
Uint8Array.from(iterable); | ||
Uint8ClampedArray.from(iterable); | ||
Object.fromEntries(iterable); | ||
|
||
assert.equal(effects, 17); |