Skip to main content

prefer-correct-type-name

added in: 1.0.0 style

Rule checks that the type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.

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.

dart_code_linter:
...
rules:
...
- prefer-correct-type-name:
excluded: [ 'exampleExclude' ]
min-length: 3
max-length: 40

Example

Bad:

class example { // not capitalized
//...
}
class ex { // length equals 2
//...
}
class multiplatformConfigurationPointWithExtras { // length equals 41
//...
}

Good:

class Example { // length equals 7
//...
}

class _Example { // length equals 7
//...
}