simple_directive_paths
Learn about the simple_directive_paths linter rule.
Use simple directive paths.
Details
#PREFER simple directive paths.
Using simple directive paths (avoiding redundant ./ or backtracking ../
segments) makes the code cleaner, more consistent, and easier to read. It
also reduces the risk of confusion when resolving paths relative to the
source file.
BAD:
import '../src/bar.dart';
GOOD:
import 'bar.dart';
Enable
#
To enable the simple_directive_paths rule, add simple_directive_paths under
linter > rules in your analysis_options.yaml
file:
linter:
rules:
- simple_directive_paths
If you're instead using the YAML map syntax to configure linter rules,
add simple_directive_paths: true under linter > rules:
linter:
rules:
simple_directive_paths: true
除非另有说明,文档之所提及适用于 Dart 3.11.0 版本报告页面问题.