Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint for importing a library from another package's lib/src directory. #57184

Closed
seaneagan opened this issue Feb 23, 2015 · 4 comments
Closed
Assignees
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-lint-request type-enhancement A request for a change that isn't a bug

Comments

@seaneagan
Copy link

Anything under lib/src is supposed to be private.

@pq pq added type-enhancement A request for a change that isn't a bug linter-lint-request labels Feb 24, 2015
@zoechi
Copy link
Contributor

zoechi commented Feb 24, 2015

Should ignore such imports from lib/src when it's from within the same package though.

@pq
Copy link
Member

pq commented Mar 24, 2015

A stab at wording.

DON'T import implementation files from another package.

From the the pub package layout doc:

The libraries inside "lib" are publicly visible: other packages are free to import them. But much of a package's code is internal implementation libraries that should only be imported and used by the package itself. Those go inside a subdirectory of lib called src. You can create subdirectories in there if it helps you organize things.

You are free to import libraries that live in lib/src from within other Dart code in the same package (like other libraries in lib, scripts in bin, and tests) but you should never import from another package's lib/src directory. Those files are not part of the package’s public API, and they might change in ways that could break your code.

Bad:

// In 'road_runner'
import 'package:acme/lib/src/internals.dart;

...

As always, refinements welcome!

@pq pq self-assigned this Mar 24, 2015
@zoechi
Copy link
Contributor

zoechi commented Mar 24, 2015

sgtm

pq referenced this issue in dart-lang/linter Oct 31, 2015
@pq
Copy link
Member

pq commented Nov 6, 2015

Implemented w/ c62ec70, pushed out in 0.1.4.

@pq pq closed this as completed Nov 6, 2015
@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants