google / swift

The Swift Programming Language
https://swift.org/
840 stars 66 forks source link

Make it possible to disable specific formatter/linter rules with comments. #259

Closed dabelknap closed 5 years ago

dabelknap commented 5 years ago

This allows a user to place comments in the source to disable a chosen linter/formatter rule. As a first step, this functionality has been enabled for the NeverUseForceTry rule.

let a = try! someFunc()
// swift-format-disable: NeverUseForceTry
let b = try! anotherFunc()
// swift-format-enable: NeverUseForceTry
let c = try! thirdFunc()

Linter errors will only be raised on the first and last lines in the above example.