nbadal / ktlint-intellij-plugin

Ktlint plugin for IntelliJ IDEA + Android Studio
MIT License
158 stars 24 forks source link

Need help for setting custom baseline file for Ktlint plugin #526

Closed RahulSDeshpande closed 3 months ago

RahulSDeshpande commented 4 months ago

Hello @nbadal @paul-dingemans!

Background

I have been using Ktlint & your plugin since couple of years. In all my Kotlin projects, as a personal preference I stuck to the linting & formatting with the plugin version 0.13.0.

Problem

For all the later versions, my code was resulting in a major code reformatting because of the Ktlint enhancements. So I stuck to 0.13.0 for since then.

But the recent IDE versions 2023.3.1+ are not supporting 0.13.0 version, so had to upgrade to the latest plugin version 0.22.0. Which is again resulting into massive code reformatting.

Solution

To avoid this I need to set the older version of Ktlint baseline to suit my preference. I tried, but I am not able to set it.

Ktlint plugin issue

Can anyone please help me?

Details

My Android Studio config:

Android Studio Jellyfish | 2023.3.1 Patch 1
Build #AI-233.14808.21.2331.11842104, built on May 15, 2024
Runtime version: 17.0.10+0-17.0.10b1087.21-11572160 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.4.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 10
Registry:
  ide.instant.shutdown=false
  debugger.new.tool.window.layout=true
  ide.experimental.ui=true
  idea.ignore.disabled.plugins=true
  ide.images.show.chessboard=true
Non-Bundled Plugins:
  com.github.patou.gitmoji (1.14.0)
  io.github.biezhi.plugins.gitmoji (1.0.2)
  com.zhw.tgnet.android.AndroidProGuard (1.4)
  wu.seal.tool.jsontokotlin (3.7.4)
  com.github.airsaid.androidlocalize (3.0.0)
  com.nbadal.ktlint (0.22.0)
  com.programmersbox.Full-Multiplatform-Compose (1.0.26)
  com.jetbrains.kmm (0.8.2(233)-8)
  com.suusan2go.kotlin-fill-class (1.0.23)
  org.sonarlint.idea (10.5.0.78339)
  com.kaygisiz.dependencygraph (2.1)
  cn.yiiguxing.plugin.translate (3.6.1)

Any help is appreciated. Cheers. 👍🏼 🚀

paul-dingemans commented 4 months ago

It is a risky strategy to pin your ktlint version to an ancient version, although I can understand your wish to prevent massive code formatting changes.

In this case you are forced to upgrade to 0.22 version as the newer versions of the Intellij IDEA deprecated/removed functionality used in the older plugin version. We try to keep the plugin working with the oldest possible version of the Intellij IDEA platform, but sometimes we are forced to raise the minimum required version.

In the upcoming version of the plugin, it will be possible to select a specific version of the ktlint ruleset. This will also support the 0.50.0 version of ktlint. It is still a newer version than the one that was integrated in plugin version 0.13.0 but it might be accpetible to you. But do note, that there no guarrantee that this version will be kept supported in upcoming releases. You can already try out the beta version 0.23.0-beta-1.2024-05-19_16-14-58 (https://plugins.jetbrains.com/plugin/15057-ktlint/versions/beta).

paul-dingemans commented 3 months ago

Closed due to lack of response.