Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create custom rule for .multilineTextAlignment for Text #5771

Open
MaksimBezdrobnoi opened this issue Aug 26, 2024 · 0 comments
Open

Create custom rule for .multilineTextAlignment for Text #5771

MaksimBezdrobnoi opened this issue Aug 26, 2024 · 0 comments
Labels
help Questions or user problems that require more explanation rather than code changes.

Comments

@MaksimBezdrobnoi
Copy link

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
@SimplyDanny SimplyDanny added the help Questions or user problems that require more explanation rather than code changes. label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Questions or user problems that require more explanation rather than code changes.
Projects
None yet
Development

No branches or pull requests

2 participants