SwiftLint -Disable Line Length Rules in a specific file

Viewed 7232

Current SwiftLint rules:

file_length:
  warning: 800
  error: 1500

The error

enter image description here

I followed this answer but the error doesn't go away

// swiftlint:disable force_cast

import UIKit

class MyClass: UIViewController {

}

// swiftlint:enable force_cast

How can I ignore SwiftLint rules in certain file?

1 Answers

The rule name is file_length, so you have to disable this rule:

// swiftlint:disable file_length

import UIKit

class MyClass: UIViewController {

}

Note: // swiftlint:enable <rule> is for cases when you want to ignore a specific rule only in a small code block (like a single func). If you'd like to disable a rule in file scope, there is no need to enable anything.

See Swiftlint docs.

Related