SwiftLint: .swiftlint.yml is completely ignored

I just can’t get the .swiftlint.yml to load, I’ve tried to have it in the root folder of my project, in the built app folder, even in /usr/local/bin but it just won’t load…!

I’ve tried with both a clean build from master branch as well as the 0.4.0 release

swftlint runs as it should but it doesn’t ignore the /Pods and /Carthage folders 😦

My file excluded: # paths to ignore during linting. overridden byincluded. - Carthage - Pods # parameterized rules can be customized from this configuration file line_length: 200 # parameterized rules are first parameterized as a warning level, then error level. type_body_length: - 300 # warning - 400 # error # parameterized rules are first parameterized as a warning level, then error level. variable_name_max_length: - 40 # warning - 60 # error # parameterized rules are first parameterized as a warning level, then error level. variable_name_min_length: - 3 # warning - 2 # error

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20

Most upvoted comments

I reinstall SwiftLint. These are the commands I ran (copy/pasted from my Terminal):

$ which swiftlint
/usr/local/bin/swiftlint
$ swiftlint version
0.4.0
$ brew uninstall swiftlint
Uninstalling /usr/local/Cellar/swiftlint/0.4.0... (215 files, 55M)
$ which swiftlint
swiftlint not found
$ brew update
Already up-to-date.
$ brew install swiftlint
==> Downloading https://homebrew.bintray.com/bottles/swiftlint-0.4.0.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/swiftlint-0.4.0.yosemite.bottle.tar.gz
==> Pouring swiftlint-0.4.0.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/swiftlint/0.4.0: 215 files, 55M
$ which swiftlint
/usr/local/bin/swiftlint
$ swiftlint version
0.4.0

When testing this with a new project, everything seems to be working fine. Look like the problem is tied to my existing project. Will dig deeper and report my findings.

In my case, I had to delete spaces before the rules dash, so it looks like this:

disabled_rules:
- identifier_name

Swiftlint 0.34.0 is used.

I have it setup properly as per the README instructions. My file is named .swiftlint.yml and it is in the root directory of the project, side by side with the .xcworkspace.

I tried passing the path to swiftlint like this:

$ cd MyProject
$ swiftlint --config .swiftlint.yml
Unrecognized command: '--config'. See `swiftlint help`.

As you can see, I’m getting an error regarding unrecognized command.

EDIT:

And the version for good form:

$ swiftlint version
0.4.0

I was able to fix it by properly formatting our YAML file. image

Notice how the - trailing_whispace has 3 spaces instead of 2. Everything seems to be working fine now.

Maybe this would be a good enhancement: validate the YAML file if found?