realm / realm/SwiftLint

Feature Request: disable rules for whole file

Open
#5,052 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
New feature request

After the introduction of the blanket_disable_command rule in https://github.com/realm/SwiftLint/pull/4731, all disabled rules have to be re-enabled again, otherwise the rule produces a warning.

There are some use cases where a rule should not be active for a certain file, e.g. in a Package.swift file or test classes.

At the moment this makes it necessary to disable the rule at the top of the file and to enable it again at the end of the file.

The re-enabling at the end of the file just to avoid the blanket_disable_command warning seems cumbersome.

It would be nice to introduce a new :file specifier (analog to the existing :previous, :this or :next specifiers) to explicitly convey the intention, that a rule is disabled for the whole file and doesn't need to be re-enabled again.

I think this could also be used to partially solve some uses cases of https://github.com/realm/SwiftLint/issues/2355

// swiftlint:disable:file <rule1> [<rule2> <rule3>...]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing blanket_disable_command rule and the handling of the :previous, :this, and :next specifiers. Trace how file-level disable and re-enable directives are parsed and validated, then define the expected behavior for a :file specifier using the example in the issue. Done means a file can disable selected rules without a matching re-enable directive and without a blanket-disable warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.