library_ names
Learn about the library_names linter rule.
Name libraries using lowercase_with_underscores.
Details
#
DO name libraries using
lowercase_with_underscores.
Some file systems are not case-sensitive, so many projects require filenames to be all lowercase. Using a separating character allows names to still be readable in that form. Using underscores as the separator ensures that the name is still a valid Dart identifier, which may be helpful if the language later supports symbolic imports.
BAD:
library peg-parser;
GOOD:
library peg_parser;
The lint file_names can be used to enforce the
same kind of naming on the file.
Enable
#
To enable the library_names rule, add
library_names under
linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- library_names
If you're instead using the YAML map syntax to configure
linter rules, add library_names: true under
linter > rules:
linter:
rules:
library_names: true
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.