Rule request: Line comment formatting rule
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
I'd like to have a lint rule which validates the format of line and linline comments similar to Python's PEP8 inline comment rule.
Inline comments
Correct:
statement() // some comment
Incorrect:
statement()//some comment
statement() //some comment
statement() // some comment
Single line comments
This rule would be similar to the MARK rule added in #768, but would apply to all line comments.
Correct:
// some comment
statement()
Incorrect:
//some comment
statement()
// some comment
statement()
Example configuration
This would be my proposal for the default values based on the Python standard and my personal preferences:
inline_comment:
spaces_before: 2
spaces_after: 1
line_comment:
spaces_after: 1
I think 1 would also be an acceptable default for spaces_before.
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 reviewing the existing MARK rule referenced in #768 and the proposed inline_comment and line_comment configuration. Define the rule's handling of the listed correct and incorrect examples, then verify that the configured spacing defaults are enforced.
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
- 45/100