-
Notifications
You must be signed in to change notification settings - Fork 232
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 ability to customize severity via config file #880
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
It looks like there's some noise in it from other merge commits (like the CMake and Package.swift files), can you rebase your changes on top of main
and push that?
In general, I agree that we need a way to do this, but I don't think adding a separate dictionary for rule severity is the right answer here. The configuration file has already grown to be a bit of a mess as more and more settings have been added to it, and I'd like to revisit it holistically instead of continuing to graft more things on top of it. Overall, I think we need to remove the distinction between "rules" (in the swift-syntax visitor/rewriter sense) and the settings that affect the pretty-printer.
In order to customize the severity of rules, I added the possibility to do so via the configuration files. If no severity is specified, we use the one pre-determined by the Rule itself. Example: ``` { "ruleSeverity": { "AlwaysUseLowerCamelCase": "warning", "AmbiguousTrailingClosureOverload": "error", } } ``` Issue: swiftlang#879
Thanks for the quick feedback. I rebased on top of main. I would agree that the config file can use some improvement. Generally, I don't think the separation between linting and formatting makes a lot of sense. There are linting rules that can/could provide rewrites as well (e.g the position of That being said, I think it is not bad to have a section in which you enable and configure the rules and a section that configure the severity. |
Yes, it would (and it would be the first one, since we've never done a breaking format change before).
Since the configuration is user-facing, I want to be extremely cautious about introducing large new capabilities in a format that we don't think is ideal if we plan to change the format later, because that makes it more difficult for end-users to work with. We've been somewhat relaxed about simple boolean or integer values for the pretty printer, but this is a much bigger change and I don't want to create churn for users by getting them accustomed to one format and then changing it under them shortly after. I might be able to take a look at redesigning the configuration in the coming weeks as other things slow down before the holidays. |
In order to check during CI for propper formatting, it is now also possible to specify severity for the formating rules. Issue: swiftlang#879
I changed my approach a little bit. This way, the configuration is still backward compatible. |
7a2aff7
to
1f8e4f0
Compare
In order to customize the severity of rules, I added the possibility to do so via the configuration files. If no severity is specified, we use the one pre-determined by the Rule itself. Example: ``` { "rules": { "AlwaysUseLowerCamelCase": "warning", "AmbiguousTrailingClosureOverload": "error", "UseLetInEveryBoundCaseVariable": "true", // use rule default "UseWhereClausesInForLoops": "false", // disabled } } ``` In addition, one can now control how pretty-print violations should be treated in the same way Example: ``` { "rules": { "TrailingComma": "warning", "LineLength": "error", "Indentation": "true", // use rule default "TrailingWhitespace": "false", // disabled } } ``` Issue: swiftlang#879
In order to customize the severity of rules, I added
the possibility to do so via the configuration files.
If no severity is specified, we use the one pre-determined
by the Rule itself.
Example:
Issue: #879