Search code examples
swiftswiftlint

Swiftlint underscore name swift


I use swiftlint in my project. The project name is ABC xx and it works fine with swiftlint. Now I decided to include Unitest in my application and I have to import @testable import ABC_xx into the swift test file which is class ABC_xxTests: XCTestCase { not I get an error with Swiftlinter which says Type Name Violation: Type name should only contain alphanumeric characters: 'ABC_xxTests' (type_name) how do I sort this error


Solution

  • The following swiftlint rule enable the use of underscore in your Swift class names:

    type_name:
      allowed_symbols: "_"
    

    EDIT: If you want to enable the use of underscore also for variable names use:

    identifier_name:
      allowed_symbols: "_"