From 9f8bad6454131ec7b4ce5135bcad24a14220166e Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Mon, 8 Mar 2021 12:54:09 +0700 Subject: [PATCH] Add the kotlin with ktlint for gradle and gradle kotlin dsl --- .gitignore | 2 ++ README.md | 7 +++++++ dart/README.md | 1 + gradle/README.md | 3 +++ gradle/java/README.md | 1 + gradle/kotlin/.editorconfig | 30 ++++++++++++++++++++++++++++++ gradle/kotlin/README.md | 4 ++++ gradle/kotlin/build.gradle | 29 +++++++++++++++++++++++++++++ gradle/kotlin/build.gradle.kts | 32 ++++++++++++++++++++++++++++++++ javascript/README.md | 1 + typescript/README.md | 1 + 11 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 dart/README.md create mode 100644 gradle/README.md create mode 100644 gradle/java/README.md create mode 100644 gradle/kotlin/.editorconfig create mode 100644 gradle/kotlin/README.md create mode 100644 gradle/kotlin/build.gradle create mode 100644 gradle/kotlin/build.gradle.kts create mode 100644 javascript/README.md create mode 100644 typescript/README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aaab5ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +build/ \ No newline at end of file diff --git a/README.md b/README.md index 6d1272f..3cedd94 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/dart/README.md b/dart/README.md new file mode 100644 index 0000000..39f81b7 --- /dev/null +++ b/dart/README.md @@ -0,0 +1 @@ +# Dart Linter (?) \ No newline at end of file diff --git a/gradle/README.md b/gradle/README.md new file mode 100644 index 0000000..aa01dec --- /dev/null +++ b/gradle/README.md @@ -0,0 +1,3 @@ +# Gradle Linter +- Kotlin (ktlint) +- Java (?) \ No newline at end of file diff --git a/gradle/java/README.md b/gradle/java/README.md new file mode 100644 index 0000000..6e743c4 --- /dev/null +++ b/gradle/java/README.md @@ -0,0 +1 @@ +# Java Linter (?) \ No newline at end of file diff --git a/gradle/kotlin/.editorconfig b/gradle/kotlin/.editorconfig new file mode 100644 index 0000000..e2fb0fa --- /dev/null +++ b/gradle/kotlin/.editorconfig @@ -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 \ No newline at end of file diff --git a/gradle/kotlin/README.md b/gradle/kotlin/README.md new file mode 100644 index 0000000..a8c57ba --- /dev/null +++ b/gradle/kotlin/README.md @@ -0,0 +1,4 @@ +# Kotlin Linter (ktlint) +- Ktlint from Pinterest: [GitHub](https://github.com/pinterest/ktlint) +- Gradle Scripts + - Kotlin Gradle DSL \ No newline at end of file diff --git a/gradle/kotlin/build.gradle b/gradle/kotlin/build.gradle new file mode 100644 index 0000000..473947c --- /dev/null +++ b/gradle/kotlin/build.gradle @@ -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" +} \ No newline at end of file diff --git a/gradle/kotlin/build.gradle.kts b/gradle/kotlin/build.gradle.kts new file mode 100644 index 0000000..20e9053 --- /dev/null +++ b/gradle/kotlin/build.gradle.kts @@ -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") +} \ No newline at end of file diff --git a/javascript/README.md b/javascript/README.md new file mode 100644 index 0000000..0d0b0bd --- /dev/null +++ b/javascript/README.md @@ -0,0 +1 @@ +# JavaScript (prettier) \ No newline at end of file diff --git a/typescript/README.md b/typescript/README.md new file mode 100644 index 0000000..4715b11 --- /dev/null +++ b/typescript/README.md @@ -0,0 +1 @@ +# TypeScript Linter (prettier) \ No newline at end of file