Add the kotlin with ktlint for gradle and gradle kotlin dsl

This commit is contained in:
Sambo Chea 2021-03-08 12:54:09 +07:00
parent 163a1fc1d8
commit 9f8bad6454
11 changed files with 111 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
build/

View File

@ -1,2 +1,9 @@
# You and Me, Should Do This Way For Better Things
The collections of custom coding rules for CUBETIQ Development Team
## Linters
- Kotlin
- Java
- TypeScript
- JavaScript
- Dart

1
dart/README.md Normal file
View File

@ -0,0 +1 @@
# Dart Linter (?)

3
gradle/README.md Normal file
View File

@ -0,0 +1,3 @@
# Gradle Linter
- Kotlin (ktlint)
- Java (?)

1
gradle/java/README.md Normal file
View File

@ -0,0 +1 @@
# Java Linter (?)

View File

@ -0,0 +1,30 @@
[*.{kt,kts}]
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
indent_size=4
# true (recommended) / false
insert_final_newline=true
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off
# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
# by the ruleset identifier.
disabled_rules=no-wildcard-imports,experimental:annotation
# Defines the imports layout. The layout can be composed by the following symbols:
# "*" - wildcard. There must be at least one entry of a single wildcard to match all other imports. Matches anything after a specified symbol/import as well.
# "|" - blank line. Supports only single blank lines between imports. No blank line is allowed in the beginning or end of the layout.
# "^" - alias import, e.g. "^android.*" will match all android alias imports, "^" will match all other alias imports.
# import paths - these can be full paths, e.g. "java.util.List.*" as well as wildcard paths, e.g. "kotlin.**"
# Examples (we use ij_kotlin_imports_layout to set an imports layout for both ktlint and IDEA via a single property):
# ij_kotlin_imports_layout=* # alphabetical with capital letters before lower case letters (e.g. Z before a), no blank lines
# ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
# ij_kotlin_imports_layout=android.**,|,^org.junit.**,kotlin.io.Closeable.*,|,*,^ # custom imports layout
# According to https://kotlinlang.org/docs/reference/coding-conventions.html#names-for-test-methods it is acceptable to write method names
# in natural language. When using natural language, the description tends to be longer. Allow lines containing an identifier between
# backticks to be longer than the maximum line length. (Since 0.41.0)
# [**/test/**.kt]
# ktlint_ignore_back_ticked_identifier=true

4
gradle/kotlin/README.md Normal file
View File

@ -0,0 +1,4 @@
# Kotlin Linter (ktlint)
- Ktlint from Pinterest: [GitHub](https://github.com/pinterest/ktlint)
- Gradle Scripts
- Kotlin Gradle DSL

View File

@ -0,0 +1,29 @@
apply plugin: 'java'
repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.40.0"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}

View File

@ -0,0 +1,32 @@
val ktlint by configurations.creating
repositories {
jcenter()
}
dependencies {
ktlint("com.pinterest:ktlint:0.40.0")
}
val outputDir = "${project.buildDir}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))
val ktlintCheck by tasks.creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Check Kotlin code style."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
val ktlintFormat by tasks.creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Fix Kotlin code style deviations."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt")
}

1
javascript/README.md Normal file
View File

@ -0,0 +1 @@
# JavaScript (prettier)

1
typescript/README.md Normal file
View File

@ -0,0 +1 @@
# TypeScript Linter (prettier)