Type Name

Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length. Private types may start with an underscore.

  • Identifier: type_name
  • Enabled by default: Yes
  • Supports autocorrection: No
  • Kind: idiomatic
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    min_length
    KeyValue
    warning 3
    error 0
    max_length
    KeyValue
    warning 40
    error 1000
    excluded []
    allowed_symbols []
    unallowed_symbols_severity error
    validates_start_with_lowercase error
    validate_protocols true

Non Triggering Examples

class MyType {}
private struct _MyType {}
//
// excluded: ["^`.+`$"]
//

struct `My Struct` {}

enum AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
typealias Foo = Void
private typealias Foo = Void
protocol Foo {
  associatedtype Bar
}
protocol Foo {
  associatedtype Bar: Equatable
}
enum MyType {
case value
}
//
// validate_protocols: false
//

protocol P {}

struct SomeStruct {
  enum `Type` {
    case x, y, z
  }
}

Triggering Examples

class ↓myType {}
enum ↓_MyType {}
class ↓`My Class` {}
private struct ↓MyType_ {}
struct ↓My {}
struct ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {}
class ↓MyView_Previews
private struct ↓_MyView_Previews
typealias ↓X = Void
private typealias ↓Foo_Bar = Void
private typealias ↓foo = Void
typealias ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = Void
protocol Foo {
  associatedtype ↓X
}
protocol Foo {
  associatedtype ↓Foo_Bar: Equatable
}
protocol Foo {
  associatedtype ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
}
protocol ↓X {}