How do `kotlinter` or `ktlint-gradle` detect the `...
# ktlint
r
How do
kotlinter
or
ktlint-gradle
detect the
.editorconfig
file? Using plain
ktlint
I have no issues but with either plugin it doesn’t seem to respect the
.editorconfig
(e.g. uses experimental rules when I have experimental rules disabled, confirmed with plain
ktlint
). My
.editorconfig
lives in the root directory of the project.
e
Never had that issue.. How are you applying the plugin?
m
Have you tried killing the deamon wtih
./gradlew --stop
after modifying editorconfig file? I recall there was an issue where editorconfig content was cached by ktlint and both plugins weren't properly reseting ktlint caches 👀
j
IIRC, we fixed that by adding the
.editorconfig
file as a task input
m
yeah, but it's required the task to be run incrementally: https://github.com/JLLeitschuh/ktlint-gradle/blob/83382192c0c3d3dede7b7ab323c1e74f[…]tlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt I don't remember the exact scenario 🤔 Wouldn't it break if the task continues to fail? 1. You run the task, ktlint caches editorconfig, the task fails 2. You adjust the editorconfig content 3. Run the task again, it is not incremental (since the last execution has failed), editorconfig caches are not invalidated 4. As the result ktlint doesn't respect updated settings on the second run
j
@wakingrufus ^
w
👀 i can look into this
m
If you're looking at the code around listening for editorconfig changes, you may also want to look at the bug I reported: https://github.com/JLLeitschuh/ktlint-gradle/issues/575 😛
r
gradlew --stop
seems to have fixed the issue. Thanks!
m
I can also mention that the plugin still uses the KtLint.trimMemory() to reset the editorconfig caches and traverses through filesystem manually. Ktlint added dedicated apis for that: https://github.com/pinterest/ktlint/pull/1659/files - the
editorConfigFilePaths
and
reloadEditorConfigFile
362 Views