跳到主要內容

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