annotate_redeclares
注解重复声明的成员。
详情
#应该注解重复声明的成员。
这种做法提高了代码可读性,并有助于防止无意中重复声明成员,或在成员不再重复声明时(例如由于重命名重构)感到意外。
差
dart
class C {
void f() { }
}
extension type E(C c) implements C {
void f() {
...
}
}
好
dart
import 'package:meta/meta.dart';
class C {
void f() { }
}
extension type E(C c) implements C {
@redeclare
void f() {
...
}
}
启用
#要启用 annotate_redeclares
规则,请在您的 analysis_options.yaml
文件中的 linter > rules 下添加 annotate_redeclares
analysis_options.yaml
yaml
linter:
rules:
- annotate_redeclares
如果您正在使用 YAML 映射语法配置 linter 规则,请在 linter > rules 下添加 annotate_redeclares: true
analysis_options.yaml
yaml
linter:
rules:
annotate_redeclares: true