Skip to content

Commit 95dc006

Browse files
authored
Fix crash in no-nonstandard-*-properties rules (#234)
1 parent 92f5f75 commit 95dc006

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/util/get-property-key-value.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ function getPropertyKeyValue(node, initialScope) {
5555
*/
5656
function getStaticKeyValue(node, initialScope) {
5757
const value = getStaticValue(node, initialScope)
58-
return value && typeof value.value === "symbol"
59-
? value.value
60-
: String(value.value)
58+
return (
59+
value &&
60+
(typeof value.value === "symbol" ? value.value : String(value.value))
61+
)
6162
}
6263

6364
module.exports = { getPropertyKeyValue }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ new RuleTester().run(ruleId, rule, {
2222
{ code: "['A'].unknown()", options: [{ allow: ["unknown"] }] },
2323
// Test for https://github.com/eslint-community/eslint-plugin-es-x/issues/223
2424
"for (const { x } of foo) {}",
25+
// Test for https://github.com/eslint-community/eslint-plugin-es-x/issues/233
26+
"['A'][unknown];",
2527
],
2628
invalid: [
2729
{

0 commit comments

Comments
 (0)