Skip to content

Commit 0f3c0b6

Browse files
committed
Ktlint setup
1 parent e703c73 commit 0f3c0b6

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
5+
ktlint_code_style = ktlint_official
6+
insert_final_newline = false
7+
ij_kotlin_packages_to_use_import_on_demand = false
8+
ij_kotlin_allow_trailing_comma = true
9+
ij_kotlin_allow_trailing_comma_on_call_site = true
10+
max_line_length = off
11+
ktlint_function_naming_ignore_when_annotated_with = Composable
12+
ktlint_standard_import-ordering = disabled
13+
ktlint_standard_no-empty-first-line-in-class-body = disabled
14+
ktlint_standard_annotation = disabled
15+
ktlint_standard_multiline-expression-wrapping = disabled
16+
ktlint_standard_string-template-indent = disabled

composeApp/build.gradle.kts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
33
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
44
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
55
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
6+
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
67

78
plugins {
89
alias(libs.plugins.kotlinMultiplatform)
910
alias(libs.plugins.androidApplication)
1011
alias(libs.plugins.composeMultiplatform)
1112
alias(libs.plugins.composeCompiler)
1213
alias(libs.plugins.serialization)
14+
alias(libs.plugins.ktlint)
15+
}
16+
17+
ktlint {
18+
android = true
19+
ignoreFailures = false
20+
reporters {
21+
reporter(ReporterType.PLAIN)
22+
reporter(ReporterType.CHECKSTYLE)
23+
reporter(ReporterType.SARIF)
24+
}
1325
}
1426

1527
kotlin {
@@ -19,20 +31,20 @@ kotlin {
1931
jvmTarget.set(JvmTarget.JVM_11)
2032
}
2133
}
22-
34+
2335
listOf(
2436
iosX64(),
2537
iosArm64(),
26-
iosSimulatorArm64()
38+
iosSimulatorArm64(),
2739
).forEach { iosTarget ->
2840
iosTarget.binaries.framework {
2941
baseName = "ComposeApp"
3042
isStatic = true
3143
}
3244
}
33-
45+
3446
jvm("desktop")
35-
47+
3648
@OptIn(ExperimentalWasmDsl::class)
3749
wasmJs {
3850
moduleName = "composeApp"
@@ -52,10 +64,10 @@ kotlin {
5264
}
5365
binaries.executable()
5466
}
55-
67+
5668
sourceSets {
5769
val desktopMain by getting
58-
70+
5971
androidMain.dependencies {
6072
implementation(compose.preview)
6173
implementation(libs.androidx.activity.compose)
@@ -135,4 +147,4 @@ compose.desktop {
135147
packageVersion = "1.0.0"
136148
}
137149
}
138-
}
150+
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ kotlinx-serialization-json = "1.7.3"
1919
ktor-bom = "3.0.1"
2020
koin = "4.0.4"
2121
navigation-compose = "2.9.0"
22+
ktlint = "12.2.0"
2223

2324
[libraries]
2425
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" }
@@ -57,4 +58,5 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" }
5758
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
5859
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
5960
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
60-
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
61+
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
62+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }

0 commit comments

Comments
 (0)