If you try to disable the rule within the file with //swiflint:disable file_name you'll get the Superfluous Disable Command Violation.
Have same problem
@jpsim
//swiflint:disable file_name only disables the rule after the command. Have you tried adding //swiflint:disable:previous file_name on the first line?
I think, u should just use excluded option in swiftlint.yml
like this:
file_name:
excluded: ["MapUtils.swift", "MapTransforms.swift", "DateUtils.swift", "Utils.swift"]
@MortMerr that's also another option which IMO is even better in most cases.
hey @marcelofabri I'm also hitting this issue (where I have a few short classes in the same file that all present a certain type of Thing so my file is called Things.swift but inside it there is no class called Things.
I tried your suggestion of // swiftlint:disable:previous on the first line and the lint warning still triggers.
(I'm using SwiftLint 0.26.0 and Xcode 9.4.1)
Same issue, I have a few files named like "SOMETHING+Extensions".
Using // swiftlint:disable:previous file_name on the first line does not remove lint warnings.
Ended up with using excluded option as @MortMerr suggested.
(SwiftLint 0.27.0 and Xcode 10 beta 5)
It's the same here, I think that the rule can be disabled when the filename contains "Extension"
You could use the new prefix_pattern and suffix_pattern options that were added to 0.27.0 to configure the rule as you want.
If you're like me and would prefer to disable the rule in the file, try:
// swiftlint:disable:this file_name.
on the first line of the file.
Works for me.
@andris-zalitis solution worked for me :) thanks man!
@andris-zalitis 's answer is correct, // swiftlint:disable:this file_name on the first line of the file.
I'm closing this ticket because this is behaving as expected.
Most helpful comment
If you're like me and would prefer to disable the rule in the file, try:
// swiftlint:disable:this file_name.on the first line of the file.
Works for me.