diff options
author | Jordan Demeulenaere <jdemeulenaere@google.com> | 2022-06-10 11:53:14 +0200 |
---|---|---|
committer | Jordan Demeulenaere <jdemeulenaere@google.com> | 2022-06-10 10:01:38 +0000 |
commit | de088d407c7ca6bb682527e8e802242668813ed4 (patch) | |
tree | d5f6623e19d9debd425b200c2465f4a652cc1e8d | |
parent | 1aaf3e4b038980ba4bbe7e08f42aa6949bb1836d (diff) | |
download | ktlint-de088d407c7ca6bb682527e8e802242668813ed4.tar.gz |
Configure ktlint the same way as google3 does
Given that we are going to use ktfmt to format our files and that ktlint
and ktfmt don't agree on indentation rules, let's configure ktlint to
disable rules that clash with ktfmt. The configuration is the same as in
google3 [1] with those additional changes:
* Indentation is set to 4.
* wrapping rule is disabled. This is not disabled in google3 yet
because this rules is causing issue starting from release 0.45 and
google3 is on 0.43 (while we are on 0.46/master).
[1] http://google3/third_party/kotlin/ktlint/.editorconfig
Bug: 235461679
Test: Manual
Change-Id: I851e511db06ae38ea89be0f90a86746a1fa92dac
-rw-r--r-- | .editorconfig | 12 | ||||
-rwxr-xr-x | ktlint.py | 2 |
2 files changed, 14 insertions, 0 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 @@ -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: @@ -45,6 +46,7 @@ def main(args=None): args = parser.parse_args() kt_files = [f for f in args.file if f.endswith('.kt') or f.endswith('.kts')] ktlint_args = kt_files[:] + ktlint_args += ['--editorconfig', EDITOR_CONFIG] if args.format: ktlint_args += ['-F'] if not ktlint_args: |