Create custom rule for .multilineTextAlignment for Text
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
Hi! I want to create new custom_rules to validate that SwiftUI Text has .multilineTextAlignment. But I had a lot of problems
Right now my regex rule looks like this:
\\bText\\([^\\)]*\\)(?!\\s*\\.(multilineTextAlignment|modifier\\())
And everything works fine until it hits:
Text("\(address.postalCode), \(address.city)")
Text(value(from: anotherValue))
Text("\(intValue)")
Text(textValue) + Text(" ") + Text(anotherTextValue)
Text(
veryBigName
)
Do you have any ideas on how to avoid this problem?
Full custom_rule:
custom_rules:
multiline_text_alignment_rule:
name: "Multiline Text Alignment"
regex: "\\bText\\([^\\)]*\\)(?!\\s*\\.(multilineTextAlignment|modifier\\())"
message: "Text should have a .multilineTextAlignment() or .modifier()"
severity: error
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 with SwiftLint's custom_rules configuration and the supplied multiline_text_alignment_rule regex, then compare it with each SwiftUI Text example in the issue. Done means establishing whether the requested validation can be expressed reliably as a custom rule and documenting or implementing a defined approach for these cases.
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