Chris Lee
07/20/2023, 5:40 PMroot = true
[*.{kt,kts}]
charset = utf-8
end_of_line = lf
ktlint_code_style = ktlint_official
[dsl/*.{kt,kts}]
ktlint_standard_filename = disabled
ktlint_standard_max-line-length = disabled
…fails to disable the two rules in the second stanza. Moving those rules to the first stanza works.
Running 0.50.0 via ktlint-gradle v11.5.0
Have tried variations on the syntax such as dsl/**.{kt,kts}
without luck.Paul Dingemans
07/20/2023, 5:45 PMChris Lee
07/20/2023, 5:46 PMChris Lee
07/20/2023, 5:47 PM./ktlint
- the second stanza is not processed.Paul Dingemans
07/20/2023, 6:01 PMChris Lee
07/20/2023, 6:02 PMChris Lee
07/20/2023, 6:02 PMPaul Dingemans
07/20/2023, 6:06 PMChris Lee
07/20/2023, 6:08 PMPaul Dingemans
07/20/2023, 6:14 PM.editorconfig
we use a library. Cam you share the link to the docs that mislead you?Chris Lee
07/20/2023, 6:15 PM[*.{kt,kts}]
ktlint_standard_import-ordering = disabled
[api/*.{kt,kts}]
ktlint_standard_indent = disabled
Paul Dingemans
07/20/2023, 6:17 PMPaul Dingemans
07/22/2023, 7:29 PM[**/api/*.{kt,kts}]
ktlint_standard_indent = disabled
Can you verify that it works for you as well so that I can change the documentation? Or feel free, to submit a PR for it 😉Chris Lee
07/22/2023, 8:47 PM.editorconfig
root = true
[*.{kt,kts}]
charset = utf-8
end_of_line = lf
max_line_length = 200
ktlint_code_style = ktlint_official
ktlint_standard = enabled
ktlint_experimental = disabled
ktlint_ignore_back_ticked_identifier = true
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 3
ktlint_function_signature_body_expression_wrapping = default
ktlint_standard_max-line-length = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_chain-wrapping = enabled
ktlint_standard_function-signature = enabled
ktlint_standard_enum-wrapping = enabled
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_method_call_chain_wrap = split_into_lines
[**/dsl/*.{kt,kts}]
ktlint_standard = disabled
ktlint_standard_filename = disabled
Invoking ktlint this way:
val ktlint: Configuration by configurations.creating
dependencies {
ktlint("com.pinterest:ktlint:0.50.0")
}
val ktlintFormat = tasks.register<JavaExec>("ktlintFormat") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Check Kotlin code style and format"
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
args("--format", "**/src/**/*.kt", "**.kts", "!build-logic/build/**")
// args("--format", "**/src/**/*.kt", "**.kts", "!build-logic/build/**", "!dsl/src/**/*.kt")
}
Results in lots of:`/Users/chrislee/IdeaProjects/cloudshift/kotlin/awscdk-dsl-kotlin/dsl/src/main/kotlin/cloudshift/awscdk/dsl/cloudassembly/schema/_schema.kt11: File '_schema.kt' contains a single top level declaration and should be named 'Schema.kt' (standard:filename)`
The goal it to selectively disable rules for dsl/**
as its generated code, or exclude it entirely.
Have been able to accomplish this by:
• separate .editorconfig in dsl
folder;
• or, excluding it in the command line args (commented out in the gradle snippet above)
Have not been able to influence it from within a single root .editorconfig
.Chris Lee
07/22/2023, 8:48 PMPaul Dingemans
07/23/2023, 7:46 PM.editorconfig
. Did you by accident happen to change the .editorconfig
file in IntelliJ IDEA (or Android Studio)? And did you save the file explicitly before rerunning ktlint
? I see it happen regularly that without an explicit save of .editorconfig
that the changes are not picked up by ktlint
. Other question that I have, is the directory where the root .editorconfig
is stored.Chris Lee
07/23/2023, 7:51 PM.editorconfig
back to the above (added back [**/dsl/*.{kt,kts}]
section) and removed the dsl
exclusion from the command line (as above), and also confirmed (via cat .editorconfig
) that the changes are indeed saved.
It still does not disable for **/dsl
:
/Users/chrislee/IdeaProjects/cloudshift/kotlin/awscdk-dsl-kotlin/dsl/src/main/kotlin/cloudshift/awscdk/dsl/services/oam/_oam.kt:1:1: File '_oam.kt' contains a single top level declaration and should be named 'Oam.kt' (standard:filename)
The root .editorconfig
is at the root of the project; the dsl
directory (to exclude) is also at the root of the project, and does not contain an .editorconfig
(there are no other .editorconfig
files in the project).Chris Lee
07/23/2023, 7:54 PM------------------------------------------------------------
Gradle 8.2.1
------------------------------------------------------------
Build time: 2023-07-10 12:12:35 UTC
Revision: a38ec64d3c4612da9083cc506a1ccb212afeecaa
Kotlin: 1.8.20
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 19.0.2 (<http://Amazon.com|Amazon.com> Inc. 19.0.2+7-FR)
OS: Mac OS X 13.4.1 aarch64
Chris Lee
07/23/2023, 7:57 PM➜ awscdk-dsl-kotlin git:(main) ✗ ktlint --version
0.50.0
Has the same challenge of not honouring the additional section in`.editorconfig`Chris Lee
07/23/2023, 7:58 PMChris Lee
07/23/2023, 8:02 PM.editorconfig