Skip to content

Commit

Permalink
feat(getStaticValue): allow Map/Set getters (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Mar 24, 2023
1 parent fd21933 commit 22ad79f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/get-static-value.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const callPassThrough = new Set([

/** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
const getterAllowed = [
[Map, new Set(["size"])],
[
RegExp,
new Set([
Expand All @@ -186,6 +187,7 @@ const getterAllowed = [
"unicode",
]),
],
[Set, new Set(["size"])],
]

/**
Expand Down
2 changes: 2 additions & 0 deletions test/get-static-value.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ const aMap = Object.freeze({
code: "new Set([1,2]).has(2)",
expected: { value: true },
},
{ code: "new Set([1,2]).size", expected: { value: 2 } },
{
code: "new Map([[1,2], [4,6]])",
expected: {
Expand All @@ -341,6 +342,7 @@ const aMap = Object.freeze({
code: "const m = new Map([[1,2], [4,6]]); m.has(2)",
expected: { value: false },
},
{ code: "new Map([[1,2], [4,6]]).size", expected: { value: 2 } },
...(semver.gte(eslint.Linter.version, "8.0.0")
? [
{
Expand Down

0 comments on commit 22ad79f

Please sign in to comment.