SwiftLint: Exclude file for specific rule

Well, if you don’t want some specific rules to be applied to a specific file you can use the technique mentioned by @Benno Kress. For that you need to add a comment in your swift file as given below.

The rules will be disabled until the end of the file or until the linter sees a matching enable comment:

// swiftlint:disable <rule1> 

   YOUR CODE WHERE NO rule1 is applied

// swiftlint:enable <rule1>

It is also possible to skip some files by configuring swiftlint.
add a “.swiftlint.yml” file in the directory where you’ll run SwiftLint.

Add the following content to exclude some files. Lets say file1, file2 … etc

excluded: 
  - file1
  - file2
  - folder1
  - folder1/ExcludedFile.swift

To disable some rules completely add the following to the same “.swiftlint.yml” file.

disabled_rules: # rule identifiers to exclude from running
  - colon
  - comma
  - control_statement

for more information, refer the following links.

https://swifting.io/blog/2016/03/29/11-swiftlint/

https://github.com/realm/SwiftLint#disable-rules-in-code

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)