-
Notifications
You must be signed in to change notification settings - Fork 1.7k
lint rule omit_obvious_property_types should be suppressed on public apis when type_annotate_public_apis is enabled. #60642
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
There could be different ways to handle this. It seems reasonable to me to enable a lint like However, it also seems reasonable to me if a developer or an organization chooses to enable Yet another reasonable approach would be to have type annotations on public declarations, no exceptions, and then having type annotations on private non-local variables if and only if the type is nonobvious. An interesting corner case is a public member of a private class/mixin/etc, including the case where said class is accessible to other libraries because of a We could easily come up with additional reasonable policies, there's no obvious end in sight. Consequently, we might want
That is one possible way to enable those two lints to coexist, but not the only reasonable one. I suppose the ability of one lint to change the behavior based on the enabledness of another lint is a new kind of behavior. WDYT, @bwilkerson, would that be feasible? Does it generalize properly to all the situations where lints are being checked? It does certainly happen now and then that there is a request for lints to be configurable. One difficulty with this is that there is no end to the amount of smarts we could add to lints (or that we could specify for specific combinations of lints). The simplest way to get the requested behavior would probably be to create a completely separate lint |
I can't think of any existing lints whose behavior is changed by the enablement of another lint. There's already a way for a lint to discover whether another lint is enabled, so this wouldn't be difficult to implement, but the hard part here would include
There are probably other problems that I'm not thinking of at the moment, but those are enough to make me think that we don't want to go down this road.
Yep. And we've consistently said "no" to this kind of request. Even though there are cases where some level of configurability would admittedly be useful, allowing configurability has a tendency to exponentially increase both the complexity of the tooling from a user's perspective and the maintenance cost for the tool maintainers. I believe that in the long run it ends up being more expensive than it's worth. In my mind, allowing interactions between lint rules has the same cost / benefit analysis. It just wouldn't be worth it in the long run.
That is a simpler way, but that also places an extra burden on users (having to understand the differences between the variants and choose the right combination) as well as a mantenance cost for us. The simplest is probably to suggest that users either (a) don't enable both rules, or (b) use an |
dart 3.7.
The follow code triggers a warning when the lint omit_obvious_property_types is enabled.
The problem is that if you also have type_annotate_public_apis enabled then removing the type will trigger the type_annotate_public_apis warning.
If type_annotate_public_apis is enabled and the variable is part of the public api then omit_obvious_property_types should be suppressed for that variable.
The text was updated successfully, but these errors were encountered: