Skip to content

Commit

Permalink
Only treat props named "[" as computed prop when punctuator. Fixes gh…
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 28, 2014
1 parent 0c4962d commit 6a93570
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jshint.js
Expand Up @@ -3227,7 +3227,7 @@ var JSHINT = (function () {

expression(10);
} else {
if (state.tokens.next.value === "[") {
if (state.tokens.next.id === "[") {
// ComputedPropertyName
advance();
if (!state.option.esnext) {
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/parser.js
Expand Up @@ -3790,7 +3790,11 @@ exports["object ComputedPropertyName"] = function (test) {
"[vals[0]]: true,",
"[(1)]: true,",
"};",
"fn({ [a / 7]: true });"
"fn({ [a / 7]: true });",
"var b = { '[': 1 };",
"var c = { [b]: 1 };",
"var d = { 0: 1 };",
"var e = { ['s']: 1 };",
];

TestRun(test).test(code, { esnext: true });
Expand All @@ -3804,6 +3808,8 @@ exports["object ComputedPropertyName"] = function (test) {
.addError(10, "'computed property names' is only available in ES6 (use esnext option).")
.addError(11, "'computed property names' is only available in ES6 (use esnext option).")
.addError(13, "'computed property names' is only available in ES6 (use esnext option).")
.addError(15, "'computed property names' is only available in ES6 (use esnext option).")
.addError(17, "'computed property names' is only available in ES6 (use esnext option).")
.test(code);

test.done();
Expand Down

0 comments on commit 6a93570

Please sign in to comment.