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

Add a way to make format-capable rules lint but not format #626

Open
allevato opened this issue Sep 15, 2023 · 2 comments
Open

Add a way to make format-capable rules lint but not format #626

allevato opened this issue Sep 15, 2023 · 2 comments

Comments

@allevato
Copy link
Collaborator

For rules that can both do linting and perform complex tree transformations during formatting, users may prefer having the diagnostics when linting but not automatically perform the transformation during formatting. Right now, you can only achieve this with separate configurations. It might be nice to have the ability to tell certain rules "only lint, but don't format".

The easiest way to achieve this would be to change the rules dictionary from [String: Bool] to [String: SomeMoreComplexValue] that lets the user apply different settings to different rules.

If we do this, we'd need to customize the decoding logic to preserve the original behavior of Boolean values from older configurations.

However, this might also be an opportunity to allow other customizations. For example, it's been requested before (but I can't seem to find an issue) to allow customizing the severity levels of different rules. And we could take the top-level customization structs for the rules and nest them in the rules themselves. So maybe this is worth a holistic configuration version bump to tackle multiple cleanups at once.

@natikgadzhi
Copy link
Contributor

This sounds interesting!

I think there's a spectrum (and somewhat of a slippery slope) of customizations that we could provide:

I think in some other languages where formatting is more valuable (ahem JavaScript), formatting and linters became very complex, and we probably don't want that for Swift.

How do you make decisions about flexibility vs complexity vs maintenance costs in swift-format? How should we go about it in this case?

@ahoppen
Copy link
Contributor

ahoppen commented Apr 23, 2024

Tracked in Apple’s issue tracker as rdar://126948389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants