Skip to content

Allow a library directive without a name #535

Closed
@xvrh

Description

@xvrh

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';

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problemsrequestRequests to resolve a particular developer problemsmall-featureA small feature which is relatively cheap to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions