Informal poll - do you prefer configuring lint/for...
# ktlint
d
Informal poll - do you prefer configuring lint/formatting definitions in the Intellij IDE or using .editorconfig? Is one better suited to align with ktlint rules/formatting?
r
.editorconfig
for me. With the below everything seems to Just Work:
Copy code
root = true

[*]
insert_final_newline = true
max_line_length = 100

[*.{kt,kts}]
charset = utf-8
indent_style = space
indent_size = 2
# noinspection EditorConfigKeyCorrectness
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
ij_java_class_count_to_use_import_on_demand = 999
ij_java_names_count_to_use_import_on_demand = 999
ij_java_packages_to_use_import_on_demand=unset
ij_kotlin_packages_to_use_import_on_demand=unset
❤️ 1
d
do you use the "reformat code" ui actions in Android Studio?
r
In IntelliJ, but yes.
p
The
.editorconfig
should be considered as the best way to go (at least from ktlint perspective). The IDEA can be configured to use
.editorconfig
as well.
d
Is there a generate .editorconfig command similar to the applyToIdeaProject command?
i dont see one - can write it by hand
p
Please read the help. If it does not answer your questions, we are happy to help.
👍 1
d
Copy code
# Run command below from root directory of project
ktlint --android applyToIDEAProject
p
You can also generate it via the IDEA. Then it contains all your IDEA settings 😉
❤️ 1
n
+1 for .editorconfig
r
@dazza5000 we have an early-preview version of that command -> https://github.com/pinterest/ktlint/blob/c56168b1a1bbc6b31e384dc7f9dd4c04ab6dcb4f/[…]com/pinterest/ktlint/internal/GenerateEditorConfigSubCommand.kt but it’s very limited at the moment
ktlint generateEditorConfig
🔥 3