eslint/typescript-eslint-parser

no-dupe-args and no-redeclare false positives in 20.1.0

vkrol opened this issue · 8 comments

vkrol commented

What version of TypeScript are you using?
3.1.4

What version of typescript-eslint-parser are you using?
20.1.0

What code were you trying to parse?

function foo({ bar }: { bar: string }) {
	console.log(bar);
}

What did you expect to happen?
No errors.

What happened?

  1:1   error  Duplicate param 'bar'         no-dupe-args
  1:25  error  'bar' is already defined      no-redeclare

I'm experiencing this issue as well after updating my vue-cli ts deps to latest.

Thank you for this report.

I wonder we can disable both rules no-dupe-args and no-redeclare because TypeScript verifies those itself?

That's my solution right now. Turn them off.

This is happening for a ton of stuff, including no-shadow. Here's some output from my lints.

  3:90  error  'Theme' is already declared in the upper scope  no-shadow

  20:39  error  'Options' is already declared in the upper scope  no-shadow

  28:3   error  Duplicate param 'id'          no-dupe-args
  28:3   error  Duplicate param 'name'        no-dupe-args
  28:3   error  Duplicate param 'tagName'     no-dupe-args
  28:3   error  Duplicate param 'type'        no-dupe-args
  33:8   error  'id' is already defined       no-redeclare
  33:21  error  'name' is already defined     no-redeclare
  33:36  error  'tagName' is already defined  no-redeclare
  33:54  error  'type' is already defined     no-redeclare

And a code example:

import { Theme } from '../types';

export default function buildInputStyles(theme: Theme) {

Is this related to the eslint visitor keys change?

Is this related to the eslint visitor keys change?

Yes. As I mentioned on #516 (comment), the change changed traversal in scope analysis, too. (I had assumed people has disabled rules of variables because tsc verifies it)

I will try to fix the scope analysis soon.

vkrol commented

I wonder we can disable both rules no-dupe-args and no-redeclare because TypeScript verifies those itself?

@mysticatea strictly speaking, TypeScript does not verify no-redeclare always. This is not an error in TS:

var a = 3;
var a = 10;

Just stumbled upon this too, would be great to have it ignore TS syntax.

vkrol commented

@mysticatea thank you!