跳到主要內容

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