跳到主要內容

no_leading_underscores_for_library_prefixes

穩定
建議
提供修正

避免程式庫前綴使用底線開頭。

詳細資訊

#

請勿在程式庫前綴使用底線開頭。程式庫前綴沒有「私有」的概念。當其中一個名稱以底線開頭時,會向讀者發出令人困惑的訊號。為了避免這種情況,請勿在這些名稱中使用底線開頭。

錯誤範例

dart
import 'dart:core' as _core;

正確範例

dart
import 'dart:core' as core;

啟用

#

若要啟用 no_leading_underscores_for_library_prefixes 規則,請在您的 analysis_options.yaml 檔案中的 linter > rules 下方新增 no_leading_underscores_for_library_prefixes

analysis_options.yaml
yaml
linter:
  rules:
    - no_leading_underscores_for_library_prefixes

如果您改為使用 YAML 對應語法來設定 linter 規則,請在 linter > rules 下方新增 no_leading_underscores_for_library_prefixes: true

analysis_options.yaml
yaml
linter:
  rules:
    no_leading_underscores_for_library_prefixes: true