飞镖 analysis_options.yaml 行为

dart analysis_options.yaml behaviour

我用这段代码创建了一个 dart 文件:-

在实践中查看 dart 分析器工具的代码。

现在,我创建了一个 analysis_options.yaml 文件来添加 linting 但在此之后没有显示 info :-

现在,我知道我可以在 analysis_options.yaml 中添加 empty_statements: info。 但是为什么它抑制了默认的info。 如果这发生在其他一些信息或警告上,人们将无法知道它,因为它会被抑制。 例如,如果我添加此行(不更改 analysis_options.yaml 中的任何内容):-

正如我们所见,没有显示 info。 但是如果没有 analysis_options.yaml 文件,则会显示:-

那么,我应该编写每个 lint from here 吗? 为什么默认 info/warnings 被抑制?

假设您正在使用此 lint package 作为开发依赖项,那么您的 analysis_options.yaml 文件应该在顶部包含此行:

include: package:lint/analysis_options.yaml

编辑: 至于为什么启用这个,其他规则被抑制了。我认为是因为这个:

... only 27/150+ rules to be enabled. While some are contradictory to each other and can not enabled together, a big chunk of rules isn't enabled because it requires too much work to update all of Googles existing code.

For developers outside Google, it is the norm to have separate lint rules per project. One project might enable more rules then others."