Is it possible to specify which `.editorconfig` sh...
# ktlint
r
Is it possible to specify which
.editorconfig
should be used to format a
Code.CodeSnippet
with
ktLintRuleEngine.format()
? I'm creating the ruleset like this:
Copy code
private val ruleProviders = buildSet {
        ServiceLoader.load(RuleSetProviderV2::class.java).flatMapTo(this) { it.getRuleProviders() }
    }
    private val ktLintRuleEngine = KtLintRuleEngine(ruleProviders = ruleProviders)
but I'm not sure if this will load the root
.editorconfig
from my project or just use some default ruleset.
I think I figured out a way:
Copy code
private val ktLintRuleEngine = KtLintRuleEngine(
        ruleProviders = ruleProviders,
        editorConfigDefaults = EditorConfigDefaults.load(
            File(System.getProperty("user.dir")).parentFile.resolve(".editorconfig").toPath(),
        ),
    )
Can I just get a confirmation that the
editorConfigDefaults
it's used also for
CodeSnippet
?
hey @Paul Dingemans do you know if that's the case?
p
It should work afaik. I could not find an actual unit test for it in the project. But I wrote one for the next version and that worked.
Tnx, for your PR. I will merge it later this week. It might be moved to a different location (also see below) or changed. This thread made once more clear that better documentation was needed which I now have written. While doing so, I learned for myself how the logging can and should be used. As this might be interesting for you, I would like to ask you to have a look at this PR. Please feel free to leave review remarks which would things even more clear.
r
Sure! I'll try to look at it tomorrow ­čÖé
I just added a couple of comments