Skip to content

Commit c3e36e2

Browse files
authored
Fix false positive in es-x/no-nonstandard-iterator-prototype-properties rule (#230)
1 parent 3d5be2d commit c3e36e2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/util/well-known-properties.js

+12
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,18 @@ const iteratorProperties = new Set([
851851
const iteratorPrototypeProperties = new Set([
852852
...objectPrototypeProperties,
853853

854+
// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#table-iterator-interface-required-properties
855+
"next",
856+
857+
// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#table-iterator-interface-optional-properties
858+
"return",
859+
"throw",
860+
861+
// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iteratorhelperprototype%-object
862+
"next",
863+
"return",
864+
// [ %Symbol.toStringTag% ]
865+
854866
// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iterator.prototype%-object
855867
"constructor",
856868
"drop",

tests/lib/rules/no-nonstandard-iterator-prototype-properties.js

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ new RuleTester().run(ruleId, rule, {
1313
"foo",
1414
"foo.toString",
1515
"foo.foo",
16+
"[].keys().next()",
17+
"[].keys().return()",
18+
"[].keys().throw()",
1619
...[...iteratorPrototypeProperties].map(
1720
(p) => `Iterator.from({}).${p}`,
1821
),

0 commit comments

Comments
 (0)