-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path.editorconfig
More file actions
80 lines (62 loc) · 4 KB
/
.editorconfig
File metadata and controls
80 lines (62 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# top-most .editorconfig file
root = true
# Global Settings: Apply to all file types in the project ✨
[*]
end_of_line = lf # Use Unix-style line endings (LF)
insert_final_newline = true # Ensure a newline character at the end of every file
trim_trailing_whitespace = true # Remove trailing whitespace on lines
charset = utf-8 # Use UTF-8 encoding for all files
# Kotlin-Specific Settings: Tailored for .kt and .kts files 📏
[*.{kt,kts}]
indent_size = 4 # Standard Kotlin indentation is 4 spaces
indent_style = space # Use spaces for indentation
# Max Line Length: Adhering to Android Kotlin Style Guide (often 100 or 120) ✍️
max_line_length = 100 # The hard limit for line length
ktlint_standard_max_line_length = 100 # KtLint-specific rule for line length
# Trailing Commas: Highly Recommended for Clean Diffs and Reordering! 👍
# Set to 'true' to allow/encourage trailing commas in declarations and call sites.
# If you *really* want to remove them, set these to 'false'.
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
# Import Order: Keep your imports tidy and consistent 📦
# Prioritizes Android/AndroidX, then common, then Java/Kotlin built-ins.
ij_kotlin_imports_layout=*,android.,androidx.,com.,org.,java.,kotlin.,^
# Blank Lines: For readability and consistent spacing 📖
ij_kotlin_blank_lines_around_declarations_in_class_body = 1 # One blank line around class members
ij_kotlin_blank_lines_before_package = 0 # No blank lines before package declaration
ij_kotlin_blank_lines_after_package = 1 # One blank line after package declaration
ij_kotlin_blank_lines_before_imports = 1 # One blank line before imports block
ij_kotlin_blank_lines_after_imports = 1 # One blank line after imports block
# KtLint Rules Configuration: Fine-tuning behavior for the linter ⚙️
# These directly map to KtLint's standard rules. Consult KtLint docs for full list.
# Allow wildcard imports (common in Android, e.g., 'import android.view.*')
ktlint_standard_no-wildcard-imports = disabled
# Ensure a final newline at the end of the file
ktlint_standard_final-newline = enabled
# Enforce filename matches top-level class/object/interface name
ktlint_standard_filename = enabled
# --- One-Line Preference Configuration! ⭐ ---
# This is where we tell KtLint to be less aggressive with line breaks and
# keep things on one line as much as possible, respecting 'max_line_length'.
# 1. Disable multiline-expression-wrapping:
# This is key for short lambdas, if-expressions, when-branches to stay on one line.
# Example: `val result = if (condition) "A" else "B"` instead of breaking.
# Disabling this means it will only break if 'max_line_length' is exceeded.
ktlint_standard_multiline-expression-wrapping = disabled
# 2. Disable string-template-indent (often related to multiline-expression-wrapping issues)
ktlint_standard_string-template-indent = disabled
# 3. Consider disabling argument-list-wrapping if it's too eager to break:
# Default behavior for KtLint might put each argument on a new line if it exceeds a certain length.
# Disabling it means arguments will try to stay on one line until 'max_line_length' is hit.
# ktlint_standard_argument-list-wrapping = disabled # Uncomment to try this!
# 4. Consider disabling chain-wrapping for chained calls:
# If you prefer `obj.doSomething().anotherThing()` to stay on one line until it's too long.
# ktlint_standard_chain-wrapping = disabled # Uncomment to try this!
# Exclusions: Ignore specific files or directories from linting/formatting 🚫
# Crucial for generated code, build files, or test files if their style differs.
[**/build/**/*.kt] # Exclude all Kotlin files within 'build' directories
ktlint = disabled
[**/src/test/**/*.kt] # Exclude Kotlin files in 'src/test' (if your test style is different)
ktlint = disabled
# [path/to/specific/generated/file.kt] # Example for a specific generated file
# ktlint = disabled