Skip to content

Commit

Permalink
Fix crash in no-nonstandard-*-properties rules (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Nov 21, 2024
1 parent 92f5f75 commit 95dc006
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/util/get-property-key-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ function getPropertyKeyValue(node, initialScope) {
*/
function getStaticKeyValue(node, initialScope) {
const value = getStaticValue(node, initialScope)
return value && typeof value.value === "symbol"
? value.value
: String(value.value)
return (
value &&
(typeof value.value === "symbol" ? value.value : String(value.value))
)
}

module.exports = { getPropertyKeyValue }
2 changes: 2 additions & 0 deletions tests/lib/rules/no-nonstandard-array-prototype-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ new RuleTester().run(ruleId, rule, {
{ code: "['A'].unknown()", options: [{ allow: ["unknown"] }] },
// Test for https://github.com/eslint-community/eslint-plugin-es-x/issues/223
"for (const { x } of foo) {}",
// Test for https://github.com/eslint-community/eslint-plugin-es-x/issues/233
"['A'][unknown];",
],
invalid: [
{
Expand Down

0 comments on commit 95dc006

Please sign in to comment.