Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

no-redeclare and Flow declarations #162

Closed
haggholm opened this issue Sep 17, 2018 · 2 comments
Closed

no-redeclare and Flow declarations #162

haggholm opened this issue Sep 17, 2018 · 2 comments

Comments

@haggholm
Copy link

Flow allows for explicit function declarations. I guess they’re mostly intended for separate declaration files, but I also find them very useful for documenting functions with more than one parameter format. Often, this seems to happen when a function with positional parameters gets too complex and is modified to an options object, but remains compatible with the old params to minimise disruption.

declare function foo(bar: boolean, baz: string, callback: Function): void;
declare function foo({ bar: boolean, baz: string, beep: SomeType, bloop: Object }, callback: Function): void;

function foo() {
   if (typeof arguments[0] === 'Object') // ...
}

This makes Flow happy and keeps type checking working, but it results in lots and lots of eslint warnings from no-redeclare.

Based on similar issues, it seems to me that this is the right project to raise this issue—if not, please let me know. It would be marvellous if eslint could simply ignore explicit declare statements for the purposes of the no-redeclare rule. Presumably, the point of no-redeclare is to avoid overriding actual runtime bindings.

@suchipi
Copy link
Member

suchipi commented Sep 20, 2018

Seems reasonable. I'm not sure whether this should be fixed in eslint or this plugin, though. I would have to do some research.

@kaicataldo
Copy link
Member

Thank you for the issue. Now that @babel/eslint-plugin has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants