Skip to content

Commit

Permalink
Fix false positive in `es-x/no-nonstandard-iterator-prototype-propert…
Browse files Browse the repository at this point in the history
…ies` rule (#230)
  • Loading branch information
ota-meshi authored Nov 20, 2024
1 parent 3d5be2d commit c3e36e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/util/well-known-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,18 @@ const iteratorProperties = new Set([
const iteratorPrototypeProperties = new Set([
...objectPrototypeProperties,

// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#table-iterator-interface-required-properties
"next",

// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#table-iterator-interface-optional-properties
"return",
"throw",

// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iteratorhelperprototype%-object
"next",
"return",
// [ %Symbol.toStringTag% ]

// https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iterator.prototype%-object
"constructor",
"drop",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ new RuleTester().run(ruleId, rule, {
"foo",
"foo.toString",
"foo.foo",
"[].keys().next()",
"[].keys().return()",
"[].keys().throw()",
...[...iteratorPrototypeProperties].map(
(p) => `Iterator.from({}).${p}`,
),
Expand Down

0 comments on commit c3e36e2

Please sign in to comment.