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

Configure custom rulesets in .editorconfig #2939

Open
paulsamuels opened this issue Feb 11, 2025 · 3 comments
Open

Configure custom rulesets in .editorconfig #2939

paulsamuels opened this issue Feb 11, 2025 · 3 comments

Comments

@paulsamuels
Copy link

Expected Behavior

It would be useful if you could specify the path/s to custom rulesets in the .editorconfig. Currently to get my project to use custom rulesets I've had to make a custom wrapper that the team uses to invoke ktlint. Although this works it's not as integrated and it's easy for someone to invoke ktlint directly without loading the custom rulesets, often resulting in a failure being raised at some point later in the CI pipeline.

Additional information

  • Current version of ktlint: 1.5.0
@paul-dingemans
Copy link
Collaborator

Currently to get my project to use custom rulesets I've had to make a custom wrapper that the team uses to invoke ktlint.

What do you mean with this? How do you invoke ktlint? What build system are you using?

@paulsamuels
Copy link
Author

Ideally I'd just invoke ktlint on the command line. What I was meaning above was I currently have to write a wrapper like

ktlintw

#!/bin/bash

ktlint -R ktlint-custom-rules/ktlint-custom-rules.jar "$@"

This is all just from the terminal. We do also have a gradle task set up, but the start up time of gradle tasks is long enough to make it not ideal to use.

@paul-dingemans
Copy link
Collaborator

Ok clear. Adding a configuration for this to the .editorconfig could be a solution for your specific usage with ktlint CLI. But it would be unclear for users that use a different integration with the KtlintRuleEngine. Tools like Detekt provide a very specific set of rules to Ktlint, and do not use the concept of rulesets as far as I know. Having an .editorconfig property to set custom ktlint rulesets in the .editorconfig would than communicate an functionality that will not work in their use case.

Do you use different custom rulesets per project? If not, it might be simpler to provide your ktlint wrapper at a shared location.

Also, you might want to consider to use the ktlint-intellij-plugin (requires usage of an JetBrains IDEA, or Android Studion), as it provides instant formatting of your rules. It allows you to configure custom rulesets per project. But it has the same downside that you have to configure that per project.

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

2 participants