Skip to content

Allow a library directive without a name #535

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

Closed
xvrh opened this issue Aug 10, 2017 · 3 comments
Closed

Allow a library directive without a name #535

xvrh opened this issue Aug 10, 2017 · 3 comments
Labels
feature Proposed language feature that solves one or more problems request Requests to resolve a particular developer problem small-feature A small feature which is relatively cheap to implement.

Comments

@xvrh
Copy link

xvrh commented Aug 10, 2017

Several tools depend on the ability to add some metadata (@annotation) at a file level.

With the test package you can write

@Skip()
library my_test;

import 'package:test/test.dart';

Or

@Skip()

import 'package:test/test.dart';

The second form, is kind of a hack. The @Skip() attribute is in fact attached to the first import directive.
It causes problems with auto-formatters that re-order or remove imports. (See dart-lang/test#517)

The first form is safer but it requires to write a name for the library.
The linter recommends the name to be of the form package_name.test.path.to.file (http://dart-lang.github.io/linter/lints/package_prefixed_library_names.html).
This rule is necessary to avoid a warning because 2 libraries have the same name.
But this is tedious to write and to maintain.

I would like to write either:

@Skip()
library;

import 'package:test/test.dart';

Or that the analyzer doesn't report warnings if 2 libraries are named _. So I can write

@Skip()
library _;

import 'package:test/test.dart';
@lrhn
Copy link
Member

lrhn commented Aug 10, 2017

I think it's a very reasonable feature (and so simple I'll label it as both feature and request).

We already have special-casing in DartDoc where it considers a doc-comment on the first import as really being a library documentation. This would allow documentation on the library without having to name the library.

@munificent munificent transferred this issue from dart-lang/sdk Aug 21, 2019
@munificent munificent added the request Requests to resolve a particular developer problem label Aug 21, 2019
@lrhn lrhn added the feature Proposed language feature that solves one or more problems label Aug 27, 2019
@evanweible-wf
Copy link

@lrhn Any update on this? If it is indeed simple to implement, I think it'd be an awesome quality-of-life improvement.

@munificent munificent added the small-feature A small feature which is relatively cheap to implement. label Sep 10, 2020
@lrhn
Copy link
Member

lrhn commented Nov 18, 2020

Duplicate of #1073

@lrhn lrhn marked this as a duplicate of #1073 Nov 18, 2020
@lrhn lrhn closed this as completed Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems request Requests to resolve a particular developer problem small-feature A small feature which is relatively cheap to implement.
Projects
None yet
Development

No branches or pull requests

4 participants