constant-identifier-names
Same as constant_identifier_names in Dart lints
- Group
- Style
- Path
lint/style/constant-identifier-names- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 209 of 512
Flags constant identifiers that are not lowerCamelCase.
Dart names constants in lowerCamelCase, not the SCREAMING_CAPS common in
other languages, so maxCount rather than MAX_COUNT. Following the
convention keeps constants visually consistent with every other identifier.
The rule covers const declarations at every scope — top-level, static and
instance fields, and locals — as well as enum values. The wildcard _ is
permitted.
Invalid
// Constant identifiers must be lowerCamelCase.
const MAX_VALUE = 100;
const PI = 3.14;
const HTTP_PORT = 80;
enum E { FIRST, second }
class C {
static const DEFAULT_SIZE = 10;
}
void f() {
const LOCAL_CONST = 1;
print(LOCAL_CONST);
}
void g() {
for (const FOR_LIMIT = 3; FOR_LIMIT > 0;) {
print(FOR_LIMIT);
}
} const MAX_VALUE = 100; const PI = 3.14; const HTTP_PORT = 80; enum E { FIRST, second }class C { static const DEFAULT_SIZE = 10;void f() { const LOCAL_CONST = 1;void g() { for (const FOR_LIMIT = 3; FOR_LIMIT > 0;) {Valid
// lowerCamelCase constant identifiers.
const maxValue = 100;
const pi = 3.14;
const httpPort = 80;
enum E { first, second }
class C {
static const defaultSize = 10;
}
void f() {
const localConst = 1;
print(localConst);
}
void g() {
for (const forLimit = 3; forLimit > 0;) {
print(forLimit);
}
}Configure constant-identifier-names
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"constant-identifier-names": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/constant-identifier-names: <reason>More style rules
- curly-braces-in-flow-control-structures
curly_braces_in_flow_control_structuresrecommendedRequires curly braces around the bodies of flow-control statements.
- dangling-library-doc-comments
dangling_library_doc_commentsrecommendedAttach library documentation to an explicit
librarydirective. - deprecated-consistency
deprecated_consistencyrecommendedFlags deprecations that are not carried through to related declarations.
- directives-ordering
directives_orderingFlags import and export directives that break the Effective Dart ordering.
- do-not-use-environment
do_not_use_environmentDisallow reading compilation environment declarations, including type aliases.
- double-literal-format
double-literal-formatFlags double literals written with redundant or missing digits.
- empty-constructor-bodies
empty_constructor_bodiesrecommendedFlags constructors with an empty block body
{}. - enum-constants-ordering
Flags enum constants whose declared names violate the configured order.