You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an API consumer calls the KtlintRuleEngine it can provide an EditorConfigOverride. Currently, this EditorConfigOverride can only be defined via factory method from(vararg properties: Pair<EditorConfigProperty<*>, *>): EditorConfigOverride. The advantage from ktlint perspective is that it can be guarranteed at compile-time that the EditorConfigOverride only contains valid EditorConfigProperty. The downside of it, is that the API consumer must include the definitions of the EditorConfigProperty at compile time as well. Typically the EditorConfigProperty are defined inside rules which can be provided by different artifacts (either ktlint or provided by another rule provider).
From perspective of ktlint-gradle (and possibly also for other API consumer), it is preferred to provide the artifacts containing the EditorConfigProperty definitions only as runtime dependencies. This requires an API to build and EditorConfigOverride which is more Lazily evaluated. The signature of the factory method, could look like from(vararg properties: Pair<String, String>): EditorConfigOverride where the pair contains the name and value of a .editorconfig property.
When a Lazy EditorConfigOverride is provided to the KtlintRuleEngine, the properties provided have to be matched with properties that are used by the rules that are provided. Properties which can not be matched with a property provided by the rules can be ignored silently (but with a log warning). Properties which can be matched but have an invalid value according to the EditorConfigProperty definition will throw an exception before files are processed.
The text was updated successfully, but these errors were encountered:
Based on: https://kotlinlang.slack.com/archives/CKS3XG0LS/p1692379551133839
If an API consumer calls the
KtlintRuleEngine
it can provide anEditorConfigOverride
. Currently, thisEditorConfigOverride
can only be defined via factory methodfrom(vararg properties: Pair<EditorConfigProperty<*>, *>): EditorConfigOverride
. The advantage from ktlint perspective is that it can be guarranteed at compile-time that theEditorConfigOverride
only contains validEditorConfigProperty
. The downside of it, is that the API consumer must include the definitions of theEditorConfigProperty
at compile time as well. Typically theEditorConfigProperty
are defined inside rules which can be provided by different artifacts (either ktlint or provided by another rule provider).From perspective of
ktlint-gradle
(and possibly also for other API consumer), it is preferred to provide the artifacts containing theEditorConfigProperty
definitions only as runtime dependencies. This requires an API to build andEditorConfigOverride
which is more Lazily evaluated. The signature of the factory method, could look likefrom(vararg properties: Pair<String, String>): EditorConfigOverride
where the pair contains the name and value of a.editorconfig
property.When a Lazy
EditorConfigOverride
is provided to theKtlintRuleEngine
, the properties provided have to be matched with properties that are used by the rules that are provided. Properties which can not be matched with a property provided by the rules can be ignored silently (but with a log warning). Properties which can be matched but have an invalid value according to the EditorConfigProperty definition will throw an exception before files are processed.The text was updated successfully, but these errors were encountered: