目录

unnecessary_library_directive

Avoid library directives unless they have documentation comments or annotations.

此规则自 Dart 2.19 版本起可用。

此规则提供 快速修复

详情

#

DO use library directives if you want to document a library and/or annotate a library.

BAD:

dart
library;

GOOD:

dart
/// This library does important things
library;
dart
@TestOn('js')
library;

NOTE: Due to limitations with this lint, libraries with parts will not be flagged for unnecessary library directives.

使用方法

#

要启用 unnecessary_library_directive 规则,请在你的 analysis_options.yaml 文件中,在 linter > rules 下添加 unnecessary_library_directive

analysis_options.yaml
yaml
linter:
  rules:
    - unnecessary_library_directive