dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.3k stars 1.59k forks source link

Lint rule for `!` postfix bang/exclamation and `late` null safety language features #58361

Open duttaoindril opened 3 years ago

duttaoindril commented 3 years ago

Describe the rule you'd like to see implemented A lint rule that just shows the presence of the postfix bang/exclamation null safety ! and late variable type.

This way, a team can decide if it's:

This could be very helpful to reach true compile-time sound null safety as we migrate to it fully.

Examples

https://dart.dev/null-safety/understanding-null-safety#late-variables

bwilkerson commented 3 years ago

If we add this support, then I would recommend making these be two separate lints so that teams can associate different severities with the different language features.

duttaoindril commented 3 years ago

If we add this support, then I would recommend making these be two separate lints so that teams can associate different severities with the different language features.

Definitely.

incendial commented 3 years ago

If anyone is interested to try those rules, we have them implemented in additional dart linter called Dart Code Metrics. Here is the docs for avoid late keyword and avoid non null assertion. Any feedback is welcome!