dart-lang / site-www

Source for Dart website
https://dart.dev
Other
936 stars 675 forks source link

Link `prefer_const_constructors` with related Effective Dart #5862

Closed MaryaBelanger closed 1 month ago

MaryaBelanger commented 1 month ago

Links the Effect Dart entry "CONSIDER making your constructor const if the class supports it" to the prefer_const_constructors lint.

Section staged here: https://dart-dev--pr5862-const-lint-aiwlnawg.web.app/effective-dart/design#consider-making-your-constructor-const-if-the-class-supports-it

dart-github-bot commented 1 month ago

Visit the preview URL for this PR (updated for commit 921ddae156e2a052a705499c941c1fbb3eead35f):

https://dart-dev--pr5862-const-lint-aiwlnawg.web.app

bwilkerson commented 1 month ago

Hmm I think this a bit different, the lint is about calling an already existing const constructor. While the Effective Dart rule is about making the constructor declaration const.

I agree.

Perhaps https://dart.dev/tools/linter-rules/prefer_const_constructors_in_immutables would be more related?

Sort of, but it's specific to classes marked with the @immutable annotation, so not really. We don't have a lint that matches this guideline.

We don't, in general, have lints for the CONSIDER guidelines because there tend to be too many false positives to make having a lint add any value to the user.

MaryaBelanger commented 1 month ago

I see now that it's not an exact match. Thank you both for explaining! I'll close this