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