-
Notifications
You must be signed in to change notification settings - Fork 175
Description
Enhancement: Add Rule Version Filtering Based on @SinceKtlint Annotations
Expected Behavior
Add a new configuration option to KtLint plugin that allows users to filter out rules that were introduced after a specified KtLint version. This would use the existing @SinceKtlint annotations present on all rules to determine which rules to include.
Proposed Configuration:
ktlint {
version.set("1.5.0")
maxRuleVersion.set("0.46.0") // Only include rules introduced up to version 0.46.0
}Why do I want this?
Upgrading to higher versions of Kotlin (e.g. 2.1.0) requires a newer version of Ktlint (we're currently on 1.2.1). If I upgrade it, I will cause failures due to the new rules not being respected, which I'd like to avoid.
With the proposed feature, I would be able to upgrade to the latest version (e.g. 1.7.1) which does have Kotlin 2.2 compatibility without having to introduce all the new rules between 1.2.1 and 1.7.1. This would then allow me to upgrade the rule set on my own time.
Current Behavior
No filtering allowed unless I manually exclude new rules myself.
Additional Information
- Current version of ktlint: all
I initially proposed this in pinterest/ktlint#3099 but was redirected to the plugin itself (you can see the discussion in the thread). Let me know your thoughts on this.