It is a bad practice for a package import to reference anything outside the
given package, or more generally, it is bad practice for a package import
to contain a "..". For example, a source file should not contain a
directive such as import 'package:foo/../some.dart'.
Details
This rule replaces the current HintCode named package_import_contains_dot_dot. As part of removing the notion of "hints," https://github.com/dart-lang/sdk/issues/50796, we want to move package_import_contains_dot_dot to the linter.
Kind
"bad practice"? haha, maybe errors...
Bad Examples
import 'package:foo/../tool/foo.dart';
Good Examples
import '../tool/foo.dart';
Discussion
Discussion checklist
[x] List any existing rules this proposal modifies, complements, overlaps or conflicts with.
[x] List any relevant issues (reported here, the SDK Tracker, or elsewhere).
[ ] If there's any prior art (e.g., in other linters), please add references here.
[ ] If this proposal corresponds to Effective Dart or Flutter Style Guide advice, please call it out. (If there isn't any corresponding advice, should there be?)
[ ] If this proposal is motivated by real-world examples, please provide as many details as you can. Demonstrating potential impact is especially valuable.
package_import_contains_dot_dot
Description
A package import shouldn't contain '..'.
It is a bad practice for a package import to reference anything outside the given package, or more generally, it is bad practice for a package import to contain a "..". For example, a source file should not contain a directive such as
import 'package:foo/../some.dart'
.Details
This rule replaces the current HintCode named
package_import_contains_dot_dot
. As part of removing the notion of "hints," https://github.com/dart-lang/sdk/issues/50796, we want to movepackage_import_contains_dot_dot
to the linter.Kind
"bad practice"? haha, maybe errors...
Bad Examples
Good Examples
Discussion
Discussion checklist