Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use swiftlint to lint a single file?

Tags:

swiftlint

I'd like to use swiftlint to lint a single file. How do I accomplish this? Checking the docs on https://github.com/realm/SwiftLint was not helpful.

like image 309
ablarg Avatar asked Aug 12 '16 17:08

ablarg


People also ask

When should I run Swiftlint?

Running SwiftLint on Build The best way to execute a linting tool is to have it run every time you build the Xcode Project. It means that the SwiftLint rules will be applied every time you compile your code.

How do I integrate Swiftlint?

You can integrate SwiftLint as a Xcode Build Tool Plug-in if you're working with a project in Xcode. Add SwiftLint as a package dependency to your project without linking any of the products. Select the target you want to add linting to and open the Build Phases inspector.

What is Swiftlint autocorrect?

If you wish to autocorrect violations as well, your script could run swiftlint autocorrect && swiftlint instead of just swiftlint . This will mean that all correctable violations are fixed, while ensuring warnings show up in your project for remaining violations.

Where do I put Swiftlint Yml?

swiftlint. yml file to your project directory. Note that this file should be added alongside your Xcode project and your Xcode workspace. It should not be placed inside of your project files directory.


2 Answers

You can also do this with:

swiftlint --path 'path to your file'
like image 155
Vladyslav Zavalykhatko Avatar answered Oct 16 '22 17:10

Vladyslav Zavalykhatko


SCRIPT_INPUT_FILE_COUNT=1 SCRIPT_INPUT_FILE_0="foo.swift" swiftlint lint --use-script-input-files
like image 35
ablarg Avatar answered Oct 16 '22 18:10

ablarg