Skip to content

False positive for package_names lint for Pub Workspace name #60662

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

Open
n-bernat opened this issue May 1, 2025 · 1 comment
Open

False positive for package_names lint for Pub Workspace name #60662

n-bernat opened this issue May 1, 2025 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive P3 A lower priority bug or feature request

Comments

@n-bernat
Copy link

n-bernat commented May 1, 2025

When creating a pub workspace with analysis_options.yaml in the root directory, it reports that the package name of the main pubspec.yaml is invalid when it's set to name: _.

  • Dart: 3.7.2

Directory structure:

  • /pubspec.yaml
  • /analysis_options.yaml
  • /package_a
  • /package_b
  • /package_c

Contents of /pubspec.yaml:

name: _
publish_to: none
environment:
  sdk: ^3.6.0

workspace:
  - package_a
  - package_b
  - package_c

If I understand correctly the following regular expression fails:

// A lower-case underscored (snake-case) with leading underscores is defined as
// * An optional leading sequence of any number of underscores,
// * followed by a sequence of lower-case letters, digits and underscores,
// * with no two adjacent underscores,
// * and not ending in an underscore.
final _lowerCaseUnderScoreWithLeadingUnderscores = RegExp(
r'^_*[a-z](?:_?[a-z\d])*$',
);

Which is the first check in:

/// Returns true if this [id] is a valid package name.
bool isValidPackageName(String id) =>
_lowerCaseUnderScoreWithLeadingUnderscores.hasMatch(id) &&
isIdentifier(id) &&
!isReservedWord(id);

@n-bernat n-bernat added the area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. label May 1, 2025
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. P3 A lower priority bug or feature request devexp-linter Issues with the analyzer's support for the linter package linter-false-positive and removed area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. labels May 1, 2025
@bwilkerson
Copy link
Member

@jonasfj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

2 participants