camel-case-types

Same as camel_case_types in Dart lints

Group
Style
Path
lint/style/camel-case-types
Default
On (recommended)
Origin
Dart lints
Rule
196 of 512
recommended

Flags type names that are not UpperCamelCase.

Classes, mixins, enums, extension types, and type aliases are all types and read most predictably when named in UpperCamelCase, matching the rest of the Dart ecosystem. Leading underscores are ignored, then each word must begin with an uppercase letter or $; a name that is entirely underscores is treated as a wildcard and never flagged.

Invalid

example.dartdart
// Type names must be UpperCamelCase.

class my_class {}

class Foo_Bar {}

enum my_enum { a, b }

mixin my_mixin {}

typedef my_callback = void Function();

extension type my_id(int i) {}
Name types using `UpperCamelCase`.
2
3class my_class {}
Name types using `UpperCamelCase`.
4
5class Foo_Bar {}
Name types using `UpperCamelCase`.
6
7enum my_enum { a, b }
Name types using `UpperCamelCase`.
8
9mixin my_mixin {}
Name types using `UpperCamelCase`.
10
11typedef my_callback = void Function();
Name types using `UpperCamelCase`.
12
13extension type my_id(int i) {}

Valid

example.dartdart
// UpperCamelCase type names.

class MyClass {}

class HTTPRequest {}

class _Private {}

enum Color { red, green, blue }

mixin Flying {}

typedef IntList = List<int>;

extension type UserId(int i) {}

Configure camel-case-types

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "camel-case-types": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/camel-case-types: <reason>