Swiftlint: Disable rule warnings/errors but still run rule with autocorrect

Created on 12 Jul 2017  路  4Comments  路  Source: realm/SwiftLint

When we get certain warnings (mainly whitespace warnings), we don't want to get warned everytime, since Swiftlint can take care of this for us.
However, swiftlint autocorrect is not fast enough to run in the build process (we run it as a push hook).
I would like it if we could disable warnings / errors for a rule, but keep it enabled for swiftlint autocorrect.

question

Most helpful comment

You can do this if you use multiple SwiftLint configuration files.

# .swiftlint.yml
disabled_rules:
  - trailing_whitespace
# .swiftlint-autocorrect.yml
whitelist_rules:
  - trailing_whitespace
$ swiftlint lint --config .swiftlint.yml
$ swiftlint autocorrect --config .swiftlint-autocorrect.yml

All 4 comments

You can do this if you use multiple SwiftLint configuration files.

# .swiftlint.yml
disabled_rules:
  - trailing_whitespace
# .swiftlint-autocorrect.yml
whitelist_rules:
  - trailing_whitespace
$ swiftlint lint --config .swiftlint.yml
$ swiftlint autocorrect --config .swiftlint-autocorrect.yml

Although this solution would work, it would require me to duplicate the normal set of rules, correct?
Because yaml does not support import/include statements.

Yes, SwiftLint configs don't yet support merging/inheriting. That's tracked in #676.

Closing this for now since we already have several tickets tracking merging/inheriting/importing configurations.

Was this page helpful?
0 / 5 - 0 ratings