Skip to content

Commit

Permalink
Fix issue with no-unused-vars
Browse files Browse the repository at this point in the history
Override functions without parameter names were triggering a false
positive.
  • Loading branch information
fvictorio committed Jan 28, 2020
1 parent d20e850 commit 6551578
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/best-practises/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NoUnusedVarsChecker extends BaseChecker {

if (!ignoreWhen(funcWithoutBlock, emptyBlock)) {
VarUsageScope.activate(node)
node.parameters.forEach(parameter => {
node.parameters.filter(parameter => parameter.name).forEach(parameter => {
this._addVariable(parameter)
})
}
Expand Down
14 changes: 14 additions & 0 deletions test/rules/best-practises/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ describe('Linter - no-unused-vars', () => {
})
)

it('should not emit an error in override functions without parameter names', () => {
const code = contractWith(`
function withdrawalAllowed(address) public view override returns (bool) {
return _state == State.Refunding;
}
`)

const report = linter.processStr(code, {
rules: { 'no-unused-vars': 'warn' }
})

assertNoWarnings(report)
})

function label(data) {
const items = data.split('\n')
const lastItemIndex = items.length - 1
Expand Down

0 comments on commit 6551578

Please sign in to comment.