SRA*_*VAN 17 lint inline dart flutter disable
有没有办法在颤动中禁用线条的 linting 规则?
我有一个特定的用例,我想禁用两行的 linting。我已经写了很多业务逻辑,所以我无法更改代码。
abstract class ReviewName {
static final NEW = 'NEW';
static final OLD = 'OLD';
}
Run Code Online (Sandbox Code Playgroud)
上面的代码会有 linting 错误: Name non-constant identifiers using lowerCamelCase.dart(non_constant_identifier_names)
有什么方法可以避免仅两行的 lint 错误?
Ric*_*eap 21
使用// ignore:
语法,例如:
abstract class ReviewName {
// ignore: non_constant_identifier_names
static final NEW = 'NEW';
// ignore: non_constant_identifier_names
static final OLD = 'OLD';
}
Run Code Online (Sandbox Code Playgroud)
规则名称列表在这里。
Sur*_*gch 17
要忽略一个线,您可以添加行的上方评论:
// ignore: non_constant_identifier_names
final NEW = 'NEW';
Run Code Online (Sandbox Code Playgroud)
要忽略整个文件,您可以在文件顶部添加注释:
// ignore_for_file: non_constant_identifier_names
Run Code Online (Sandbox Code Playgroud)
要忽略整个项目,您可以在analysis_options.yaml文件中将规则设置为 false:
include: package:lints/recommended.yaml
linter:
rules:
non_constant_identifier_names: false
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6070 次 |
最近记录: |