|
| 1 | +--- |
| 2 | +name: check-code-style |
| 3 | +description: Check and fix code style with ktlint |
| 4 | +argument-hint: "[action: format|check]" |
| 5 | +level: 1 |
| 6 | +triggers: |
| 7 | + - "format" |
| 8 | + - "ktlint" |
| 9 | + - "check style" |
| 10 | + - "fix style" |
| 11 | +--- |
| 12 | + |
| 13 | +# Check Code Style Skill |
| 14 | + |
| 15 | +Check and automatically fix code style issues using ktlint. |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +Run this skill before committing code to ensure style compliance. |
| 20 | + |
| 21 | +## Commands |
| 22 | + |
| 23 | +### Auto-Fix Code Style |
| 24 | +```bash |
| 25 | +./gradlew ktlintFormat |
| 26 | +``` |
| 27 | + |
| 28 | +### Check Code Style (No Auto-Fix) |
| 29 | +```bash |
| 30 | +./gradlew ktlint |
| 31 | +``` |
| 32 | + |
| 33 | +### Check Specific Module |
| 34 | +```bash |
| 35 | +./gradlew :cropper:ktlint |
| 36 | +``` |
| 37 | + |
| 38 | +## Style Rules |
| 39 | + |
| 40 | +This project uses: |
| 41 | +- **ktlint 1.3.1** |
| 42 | +- **IntelliJ IDEA code style** |
| 43 | +- **2-space indentation** |
| 44 | +- **Trailing commas enabled** |
| 45 | +- **Experimental ktlint features enabled** |
| 46 | + |
| 47 | +See `.editorconfig` for specific rule configuration. |
| 48 | + |
| 49 | +## Common Style Issues |
| 50 | + |
| 51 | +### Indentation |
| 52 | +**Rule**: 2 spaces, no tabs |
| 53 | +**Fix**: Run `./gradlew ktlintFormat` |
| 54 | + |
| 55 | +### Trailing Commas |
| 56 | +**Rule**: Allowed and encouraged |
| 57 | +**Example**: |
| 58 | +```kotlin |
| 59 | +// Good |
| 60 | +listOf( |
| 61 | + "one", |
| 62 | + "two", |
| 63 | + "three", // Trailing comma OK |
| 64 | +) |
| 65 | + |
| 66 | +// Also OK |
| 67 | +listOf("one", "two", "three") |
| 68 | +``` |
| 69 | + |
| 70 | +### Import Order |
| 71 | +**Fix**: Auto-fixed by ktlintFormat |
| 72 | + |
| 73 | +### Line Length |
| 74 | +**Rule**: Disabled (no max length) |
| 75 | +**Note**: Still keep lines reasonable for readability |
| 76 | + |
| 77 | +## What to Check |
| 78 | + |
| 79 | +After running ktlintFormat: |
| 80 | +1. ✅ Review the changes made |
| 81 | +2. ✅ Ensure formatting is correct |
| 82 | +3. ✅ Run `./gradlew ktlint` to verify |
| 83 | +4. ✅ Commit the formatted code |
| 84 | + |
| 85 | +## Integration with Build |
| 86 | + |
| 87 | +ktlint runs automatically in CI/CD pipeline. |
| 88 | +Always run locally before pushing. |
0 commit comments