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
Unless stated otherwise, the documentation on this site reflects Dart 3.11.0. Report an issue.