dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
631 stars 170 forks source link

implementation_imports linting rule only works in lib directory #4859

Open akasha19 opened 8 months ago

akasha19 commented 8 months ago

Describe the issue The implementations_imports rule only checks files that are in the lib directory of a package. src imports in other directories like test or bin are not found so there is no warning.

To Reproduce

analysis_options.yaml

linter:
  rules:
    - implementation_imports

any file in directory other than lib

import 'package:foo/src/something.dart';

Expected behavior As I don't understand why this rule would only be important in the lib directory and not other directories I'm assuming this is a bug.

Additional context Came here from https://stackoverflow.com/questions/77909927/why-does-the-implementation-imports-linting-rule-only-work-in-lib-directory

srawlins commented 8 months ago

Good catch. Big bug.

srawlins commented 8 months ago

This will take a bit of work to fix. New violations in flutter/engine, flutter/flutter, flutter/packages, the Dart SDK.

travissanderson-wf commented 2 months ago

Agreed this is a big one, we use this to make sure changing package src structure and file names won't break consumers but if they're importing in tests it will break their CI. This lint only protects their builds.