prefer-correct-type-name
Warns when a type name contains unexpected characters, does not start with an uppercase character, or is too short or too long.
⚙️ Config
Set min-length
(default is 3
) to configure the minimum type name length.
Set max-length
(default is 40
) to configure the maximum type name length.
Set excluded
(default is none) to ignore specific type names.
analysis_options.yaml
dart_code_metrics:
rules:
- prefer-correct-type-name:
excluded: [ 'exampleExclude' ]
min-length: 3
max-length: 40
Example
❌ Bad:
// LINT: This name should only contain alphanumeric characters, begin with an uppercase character and be between 3 and 40 characters long.
class example {
// ...
}
// LINT: This name should only contain alphanumeric characters, begin with an uppercase character and be between 3 and 40 characters long.
class ex {
// ...
}
// LINT: This name should only contain alphanumeric characters, begin with an uppercase character and be between 3 and 40 characters long.
class multiplatformConfigurationPointWithExtras {
// ...
}
✅ Good:
class Example {
// ...
}
class _Example {
// ...
}