-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[explicit-function-return-type] Add option to ignore methods with specific names #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What should the option be like? How about {
ignoreMethods: [{
superClass: 'React.Component',
method: 'render',
}]
} ? |
TBH the more I think about it the less I like it. I don't think there's any good way to implement a "filter" config that works with the spirit of the rule (which is ensuring that every function has a defined return type). The better way to implement this would be to add an option to enable "superclass" checks for class methods. |
How about an option like: { ignoreFunctionNames: ['render', 'componentDidMount', ...etc]} Sure it is an overkill that affects much more functions than is intended. But it has the benefit that it is dead simple. |
I mean I don't hugely understand why it's such a burden to write out the 5-6 characters that is Also the future of React is functional components, which need a type annotation anyways. So I don't hugely like the idea of adding an option purely to support an old way of doing things. Like I said - I don't like having a whitelist of function names because it's indiscriminate of the context, and is also a pain to implement properly because you have to handle variable declarations, class methods, class properties, function declarations, arguments, etc. There's a lot of cases for such a simple option. |
This comment has been minimized.
This comment has been minimized.
Hi @bradzacher, wanted to know if there's an update here. I think that usually it's a non issue but when having to type the complex type in mapStateToProps or mapDispatchToProps, things look ugly and more copy paste then wanted. I'd appreciate you're opinion here. |
Chiming in here. This was a request at my current company also. I was hoping it supported |
I have the exact same issue: I started using Therefore, I switched to rule A |
We currently use a patch for typescript-eslint that does the same for functions that start with "setup" ( |
closing as |
Hi everyone, and thanks for all the great work on this plugin.
It would be nice if
explicit-function-return-type
would allow a way to set specific functions/methods to ignore for this check.I don't think it makes a lot of sense to declare types on React lifecycle methods, like
render
orcomponentDidMount
.These methods probably shouldn't be ignored by
eslint-plugin
itself, but maybe it could provide an escape hatch for other plugins to use?Right now the only 2 options available for this rule still do not allow to do this.
Thanks.
The text was updated successfully, but these errors were encountered: