-
Notifications
You must be signed in to change notification settings - Fork 31
add several rules to core and recommended #150
Conversation
lib/recommended.yaml
Outdated
@@ -21,6 +21,7 @@ linter: | |||
- avoid_single_cascade_in_expression_statements | |||
- constant_identifier_names | |||
- control_flow_in_finally | |||
- deprecated_consistency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to double check the behavior around class/constructor deprecation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that the lint does currently ask for constructors to be deprecated when the class is deprecated - I think we had discussed changing that.
I do notice that this requirement does impact what deprecations you see on usage of a type alias - if a constructor is not deprecated then usage of that constructor through an alias is not flagged with a diagnostic.
@deprecated
class C {
C();
@deprecated
C.namedDeprecated();
}
typedef Renamed = C;
void main() {
Renamed(); // No diagnostic
Renamed.namedDeprecated(); // Diagnostic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good catch. It looks like @pq has investigated this in https://github.com/dart-lang/linter/issues/4752 and we're free to remove the requirement (from the lint) to deprecate both the class and the ctor.
Let's delay adding this lint to the set until we've shipped an SDK w/ that update for the lint; I'll remove from this PR and update the github project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. This is interesting.
One thing to note is that you should see a diagnostic on the typedef declaration.
typedef Renamed = C; // Diagnostic
But you're right that you won't see it on Renamed()
.
I guess in practice if you exported the typedef maybe this could be a footgun for users but then you've made a conscious choice to ignore the diagnostic reported at the typedef declaration so maybe that's on you? Not sure what the right answer is... 🤔
* add several rules to core and recommended * remove `deprecated_consistency`
no_wildcard_variable_uses
,secure_pubspec_urls
, andtype_literal_in_constant_pattern
to coredeprecated_consistency
,unnecessary_to_list_in_spreads
, anduse_super_parameters
to recommendedprefer_equal_for_default_values
from recommendedKeeping the version at
3.0.0-wip
.Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.