summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-11 03:28:32 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-11 03:28:32 +0000
commit529112ae1dc611c34fcf68e93d8f6fa98f37c203 (patch)
treedffdf7e0d49949b39f154d2070eefb7bce140ad6
parentfe653bd4f4bf1b4c0988791ffa654aa64a48025b (diff)
parent4149cdeb0128facacfb2d09ddcfa0661259c177f (diff)
downloadktlint-android13-qpr1-s1-release.tar.gz
Change-Id: Ied8bb8df90fed810f8c7ff8d86a1a8a1143f0833
-rw-r--r--.editorconfig12
-rwxr-xr-xktlint.py7
2 files changed, 17 insertions, 2 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..e97aa07
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+[*.{kt,kts}]
+indent_size = 4
+max_line_length = 100
+trim_trailing_whitespace = true
+insert_final_newline = true
+ij_kotlin_imports_layout=*
+
+# Comma-separated list of rules to disable
+# ktlint disagrees on indentation with ktfmt in some cases
+# TODO(b/185904220): paren spacing disabled because of a ktfmt bug
+# TODO(b/189506168): curly spacing disabled because of a ktfmt bug
+disabled_rules=indent,paren-spacing,curly-spacing,wrapping
diff --git a/ktlint.py b/ktlint.py
index 16bc0f8..86b15ed 100755
--- a/ktlint.py
+++ b/ktlint.py
@@ -28,6 +28,7 @@ import sys
MAIN_DIRECTORY = os.path.normpath(os.path.dirname(__file__))
KTLINT_JAR = os.path.join(MAIN_DIRECTORY, 'ktlint-android-all.jar')
+EDITOR_CONFIG = os.path.join(MAIN_DIRECTORY, '.editorconfig')
FORMAT_MESSAGE = '''
**********************************************************************
To format run:
@@ -44,11 +45,13 @@ def main(args=None):
parser.set_defaults(format=False)
args = parser.parse_args()
kt_files = [f for f in args.file if f.endswith('.kt') or f.endswith('.kts')]
+ if not kt_files:
+ sys.exit(0)
+
ktlint_args = kt_files[:]
+ ktlint_args += ['--editorconfig', EDITOR_CONFIG]
if args.format:
ktlint_args += ['-F']
- if not ktlint_args:
- sys.exit(0)
ktlint_args += ['--android']