Skip to content

no_leading_underscores_for_local_identifiers doesn't complain about local functions #58715

@goderbauer

Description

@goderbauer

The following code does not produce a no_leading_underscores_for_local_identifiers lint, even though I would have expected it to complain about _bar:

int foo() {
  int _bar() { // Why no no_leading_underscores_for_local_identifiers lint here?
    return 10;
  }
  return _bar();
}

Complaining here would also seem to be in line with "Effective Dart" [1] (emphasize mine):

There is no concept of “private” for local variables, parameters, local functions, or library prefixes. When one of those has a name that starts with an underscore, it sends a confusing signal to the reader. To avoid that, don’t use leading underscores in those names.

[1] https://dart.dev/guides/language/effective-dart/style#dont-use-a-leading-underscore-for-identifiers-that-arent-private

Metadata

Metadata

Assignees

Labels

devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions