Maksim Nosov
Maksim Nosov

Reputation: 11

Custom rule for new line after/before MARK in SwiftLint

Could you help me? I want to write custom rule for SwiftLint. I would like to enforce putting one blank line before and after PRAGMA MARK: //

Example:

Error case

some code\n

// MARK - Smt\n

some code\n


Right case

some code\n\n // MARK - Smt\n\n

some code\n\n


Thx in advance

Upvotes: 1

Views: 501

Answers (1)

Akash Kundu
Akash Kundu

Reputation: 1358

I think you can try setting the regex to match "// MARK -" with newlines preceding it and coming after it.

To make sure SwiftLint only applies this to comments, you can set "match_kinds" to just comments on the SwiftLint yml file.

Upvotes: 0

Related Questions