Permalink
Browse files

[[FIX]] Don't throw "Duplicate class method" with computed method names

Fixes #2350
  • Loading branch information...
nicolo-ribaudo authored and jugglinmike committed May 11, 2015
1 parent 2ea9cb0 commit ab12dfb558d45654a160cb2a3b74b38d355e61b6
Showing with 23 additions and 0 deletions.
  1. +1 −0 src/jshint.js
  2. +22 −0 tests/unit/parser.js
@@ -3715,6 +3715,7 @@ var JSHINT = (function() {
}
if (name.id === "[") {
name = computedPropertyName();
computed = true;
} else if (isPropertyName(name)) {
// Non-Computed PropertyName
advance();
@@ -5342,6 +5342,28 @@ exports["class and method naming"] = function (test) {
test.done();
};

exports["computed class methods aren't duplicate"] = function (test) {
var code = [
"const obj = {};",
"class A {",
" [Symbol()]() {}",
" [Symbol()]() {}",
" [obj.property]() {}",
" [obj.property]() {}",
" [obj[0]]() {}",
" [obj[0]]() {}",
" [`template`]() {}",
" [`template2`]() {}",
"}"
];

// JSHint shouldn't throw a "Duplicate class method" warning with computed method names
// GH-2350
TestRun(test).test(code, { esnext: true });

test.done();
};

exports["class method this"] = function (test) {
var code = [
"class C {",

0 comments on commit ab12dfb

Please sign in to comment.