Skip to content

Commit

Permalink
Fix: no-useless-computed-key false positive with __proto__ (#7934)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark authored and gyandeeps committed Jan 19, 2017
1 parent c835e19 commit 8ac3518
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-useless-computed-key.js
Expand Up @@ -34,7 +34,7 @@ module.exports = {
const key = node.key,
nodeType = typeof key.value;

if (key.type === "Literal" && (nodeType === "string" || nodeType === "number")) {
if (key.type === "Literal" && (nodeType === "string" || nodeType === "number") && key.value !== "__proto__") {
context.report({
node,
message: MESSAGE_UNNECESSARY_COMPUTED,
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/rules/no-useless-computed-key.js
Expand Up @@ -22,7 +22,8 @@ ruleTester.run("no-useless-computed-key", rule, {
valid: [
"({ 'a': 0, b(){} })",
"({ [x]: 0 });",
"({ a: 0, [b](){} })"
"({ a: 0, [b](){} })",
"({ ['__proto__']: [] })"
],
invalid: [
{
Expand Down

0 comments on commit 8ac3518

Please sign in to comment.