summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2022-12-09 10:30:40 -0800
committerXin Li <delphij@google.com>2022-12-09 10:30:40 -0800
commit2ace708d3b4d05e02a21aff22fa4cd79a3259eb8 (patch)
treedffdf7e0d49949b39f154d2070eefb7bce140ad6
parentb549aeeae2c18e5c5f47fac3aa751093be51b58a (diff)
parent00e265c5a09eb8786314139a256b87f14263e34e (diff)
downloadktlint-2ace708d3b4d05e02a21aff22fa4cd79a3259eb8.tar.gz
Bug: 261731544 Merged-In: Iaf21df8e85943229c1d832b186825b41cf231b2d Change-Id: Iac9c866a297918b5d4960c577d22e7892c06a415
-rw-r--r--.editorconfig12
-rw-r--r--ktlint-android-all.jarbin31786185 -> 62738111 bytes
-rwxr-xr-xktlint.py7
3 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-android-all.jar b/ktlint-android-all.jar
index fce8357..8de50b3 100644
--- a/ktlint-android-all.jar
+++ b/ktlint-android-all.jar
Binary files differ
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']