Skip to main content

simple_directive_paths

Learn about the simple_directive_paths linter rule.

Unreleased
Fix available
Released in Dart 3.12

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:

dart
import '../src/bar.dart';

GOOD:

dart
import 'bar.dart';

Enable

#

To enable the simple_directive_paths rule, add simple_directive_paths under linter > rules in your analysis_options.yaml file:

analysis_options.yaml
yaml
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:

analysis_options.yaml
yaml
linter:
  rules:
    simple_directive_paths: true