iTranslated by AI
Exploring the Interesting Lint Rules in the Riverpod Repository
Introduction
In Flutter, when you create a new project, the flutter_lints package is configured by default, so I think many people use it as is.
Actually, I was one of them, but I started thinking I wanted to make the rules a bit stricter, and I happened to take a look at how Riverpod handles it 👀.
If you're wondering what Lint is, I found the following article very easy to understand 👀
https://zenn.dev/sugitlab/articles/flutter_linter_recommend_sugitlab
Riverpod's Lint Rules
First, let's take a look at analysis_options.yaml 👀
It seems to be importing something called all_lint_rules.yaml.
(You can already tell what it's doing from the name.)
all_lint_rules.yaml literally describes all the rules available in Flutter! ❗
https://github.com/rrousselGit/riverpod/blob/master/all_lint_rules.yaml
Returning to analysis_options.yaml again.
It seems they are disabling the rules they don't use here. Also, the reason for disabling each one is written out.
Example) prefer_double_quotes conflicts with prefer_single_quotes. Single quotes are easier to type and don't affect readability.
Summary
Conclusion
In Riverpod, they were importing all Lint rules first and then disabling the ones they didn't need.
As someone who was thinking about which rules to add, it felt like an interesting reverse approach.
Starting from the strictest state and removing only what is unnecessary seemed like a good idea.
Addendum
mono-san informed me that Remi-san (the author of Riverpod) has also written about this in his blog.
Also, there seems to be a package for covering all rules, so if you're thinking of trying this approach, it might be worth considering using that package.
https://twitter.com/_mono/status/1634086597045129216?s=20
Addendum 2
all_lint_rules_community still had some old rules remaining and was a bit difficult to use 🥺 (maybe because it's auto-updated?).
This package maintained by Muramatsu-san also has a file for covering all rules, and it seemed good as it excludes old rules, etc. 🥳
https://pub.dev/packages/altive_lints
I tried the following configuration.
I'm using Muramatsu-san's package while borrowing settings from Riverpod and adjusting them slightly to my preference.
https://github.com/K9i-0/flutter_k9i_portfolio/blob/main/analysis_options.yaml
Discussion