Closed
Description
library_with_comments_or_annotations
Description
Doc comments and/or annotations that are meant to be "scoped" to a library should be attached to a library;
directive and not just "floating".
Details
We have a bunch of silly rules trying to deal with doc comments and annotations "floating" that are meant to be scoped to a library (and not the first import/export directive).
Preferring these to be connected to a library directive would make their purpose clear and likely help formatting and code analysis tools.
Kind
style
Good Examples
/// This is a cool library doc comment
@WithAnAnnotation()
library; // assuming https://github.com/dart-lang/language/issues/1073 lands with support for no-name library directives
import 'dart:async';
Bad Examples
/// This is a bad floating library doc comment
@WithAFloatingAnnotation()
import 'dart:async';
Discussion
This is the ONE case where https://github.com/dart-lang/linter/issues/3686 (prefer avoiding library directives) would not apply!
Adding no-name libraries proposal: dart-lang/language#1073
This could likely be added to Effective Dart, I think.
Discussion checklist
- List any existing rules this proposal modifies, complements, overlaps or conflicts with.
- 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.