Skip to content
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

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

Open
duttaoindril opened this issue Mar 26, 2021 · 3 comments
Labels
lint-request type-enhancement A request for a change that isn't a bug

Comments

@duttaoindril
Copy link

duttaoindril commented Mar 26, 2021

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:

  • ignore - ”No preference.”
  • info - "Best Practices are to not use this."
  • warning - "Using this may cause the application to break in runtime."
  • error - "To keep in line with code standards, we don't want to use this."

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

@duttaoindril duttaoindril added type-enhancement A request for a change that isn't a bug lint-request labels Mar 26, 2021
@bwilkerson
Copy link
Member

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
Copy link
Author

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.

@duttaoindril duttaoindril changed the title Lint rule for ! bang/exclamation and late null safety. Lint rule for ! postfix bang/exclamation and late null safety. Mar 26, 2021
@duttaoindril duttaoindril changed the title Lint rule for ! postfix bang/exclamation and late null safety. Lint rule for ! postfix bang/exclamation and late null safety language features Mar 26, 2021
@pq pq added the NNBD label Mar 26, 2021
@incendial
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants