Is it expected that `ktlint_standard = disabled` i...
# ktlint
p
Is it expected that
ktlint_standard = disabled
in a overlayed pattern doesn't override an explicitly enabled (like
ktlint_standard_string-template-indent = enabled
) in the higher up block? At the moment we have to explicitly disable any explicitly enabled rules for generated code:
Copy code
root = true

[*]
insert_final_newline = true

[*.{kt,kts}]
# ...snip
ktlint_code_style=intellij_idea
ktlint_standard_string-template-indent = enabled

[*/build/generated/**.{kt,kts}]
ktlint_standard = disabled
ktlint_standard_string-template-indent = disabled
I can kind of see a reasoning (you've turned off the default set but enabled an explicit rule - you should explicitly disable it too) but it took us by surprise
ideally we'd just want to disable ktlint entirely for the directory - but I can't see that as an existing option, unless I've missed something.
ok - found https://pinterest.github.io/ktlint/latest/faq/#how-do-i-disable-ktlint-for-generated-code - ignore the above. Either way - I still question if doing something like the editor config above should result in the exception as it currently does:
Copy code
Skipping rule(s) which are depending on a rule which is not loaded. Please check if you need to add additional rule sets before creating an issue.                      
  - Rule with id 'RuleId(value=standard:string-template-indent)' requires rule with id 'RuleId(value=standard:indent)' to be loaded
or if dependent rules should be enabled implicitly unless disabled explicitly
p
Regarding your initial question, please try to reverse the blocks. So first the most specific blocks, and the most generic at the bottom.
p
still get the exception (but also, afaik editorconfig should be read top-to-bottom with precedence given to later rules) in a way we were saying "turn on this one standard rule and then turn off all standard rules" - expecting the latter to turn off the rule we'd turned on
p
The order has indeed no effect on that 'exception'. You can not get rid of it either. Please search issue tracker if you want more details about reasoning.
p
I understand the reasoning of rules being dependent - that's not the crux of my query (the message is fine - indicating that string-template-indent needs indent to be enabled) It's the processing order (and semantics of) the editor-config properties I was querying:
Copy code
ktlint_standard=disabled
ktlint_standard_string-template-indent=enabled
I would expect this to error (as I've disabled all, then enabled only one that has dependencies on rules now disabled) However
Copy code
ktlint_standard_string-template-indent=enabled
ktlint_standard=disabled
I assumed it to result in all standard rules being ultimately disabled
I can understand this being harder to enforce/validate though so am happy how it's working - just wanted to clarify what my initial query was about (i.e. not the interdependence of the rules but how the editorconfig is processed)
p
Ah now I understand your question. The order of the settings in the same block is irrelevant from the perspective of the
.editorconfig
parser. Both have in the end the same effect as you have noticed by now. Ktlint uses the ec4j library to parse the
.editorconfig