file_names
Name source files using lowercase_with_underscores
.
This rule is available as of Dart 2.0.0.
Rule sets: core, recommended, flutter
Details
#DO name source files 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:
SliderMenu.dart
filesystem.dart
file-system.dart
GOOD:
slider_menu.dart
file_system.dart
Files without a strict .dart
extension are ignored. For example:
OK:
file-system.g.dart
SliderMenu.css.dart
The lint library_names
can be used to enforce the same kind of naming on the
library.
Usage
#To enable the file_names
rule,
add file_names
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- file_names
除非另有说明,文档之所提及适用于 Dart 3.5.0 版本,本页面最后更新时间: 2024-09-22。 查看文档源码 或者 报告页面问题。