Skip to content

Commit

Permalink
Fix: Don't report setter params in class bodies as unused (fixes #7351)…
Browse files Browse the repository at this point in the history
… (#7352)
  • Loading branch information
not-an-aardvark authored and kaicataldo committed Oct 14, 2016
1 parent 0b85004 commit 2729d94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ module.exports = {
if (type === "Parameter") {

// skip any setter argument
if (def.node.parent.type === "Property" && def.node.parent.kind === "set") {
if ((def.node.parent.type === "Property" || def.node.parent.type === "MethodDefinition") && def.node.parent.kind === "set") {
continue;
}

Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ ruleTester.run("no-unused-vars", rule, {
options: [{argsIgnorePattern: "[cd]"}],
parserOptions: {ecmaVersion: 6},
},

// https://github.com/eslint/eslint/issues/7351
{
code: "(class { set foo(UNUSED) {} })",
parserOptions: {ecmaVersion: 6}
},
{
code: "class Foo { set bar(UNUSED) {} } console.log(Foo)",
parserOptions: {ecmaVersion: 6}
}
],
invalid: [
{ code: "function foox() { return foox(); }", errors: [definedError("foox")] },
Expand Down

0 comments on commit 2729d94

Please sign in to comment.