Skip to main content

avoid-banned-file-names

added in: 1.4.0
⚙️
Pro+

Warns against using banned file names.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set entries (default is empty) to configure the list of regular expressions for file names to ban.

analysis_options.yaml
dart_code_metrics:
rules:
- avoid-banned-file-names:
entries:
- .*example.dart
warning

For Windows devices, ensure that the entries config works with Windows path separators.

Example

❌ Bad:

some_example.dart
// LINT: This file name matches the configured pattern (.*example.dart) and therefore is not allowed. Try renaming the file.
void main() {
// ...
}

✅ Good:

another_file.dart
// Correct, different name
void main() {
// ...
}