Add ability to change rule configuration via comments
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
Today we can disable and enable rules on the fly using comments like // swiftlint:enable rule_identifier.
It would be quite useful to also be able to change some rules' parameters via comments as well, especially to locally extend some limits without entirely disable that rule.
For example, one might have configured the file_length rule in its .swiftlint.yml to trigger a warning after 400 lines. But then for a specific file which happens to be like 480 lines, they want to allow going a little over the limit for that specific case.
They could // swiftlint:disable file_length but doing that means that if in the future the file grows to 1000 lines, it won't warn anymore.
It would be way better to be able to set a new limit of 500 for this file instead of disabling the rule.
We could imagine multiple syntaxes for that comment, like:
// swiftlint:param rule_identifier value
// swiftlint:rule_identifier value
But some rules might be able to configure more than just the warning/error level, so maybe we should come up with a more explicit syntax, like:
// swiftlint:rule_identifier warning:value error:value2
// swiftlint:trailing_whitespace ignores_empty_lines:true
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how SwiftLint reads inline comments such as swiftlint:enable and how .swiftlint.yml supplies rule configuration, using file_length and trailing_whitespace as examples. Compare the proposed comment syntaxes and define which rule parameters can be overridden locally before determining what behavior and validation would count as done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100