|
| 1 | +# Code Style Guide |
| 2 | + |
| 3 | +Code style is enforced using Visual Studio Code extensions. (specifically for JSONs) |
| 4 | + |
| 5 | +## .hx |
| 6 | +Formatting is handled by the `nadako.vshaxe` extension, which includes the Haxe Formatter. |
| 7 | +Haxe Formatter resolves issues such as indentation style and line breaks, and can be configured in `hxformat.json`. |
| 8 | + |
| 9 | +Code Quality is handled by the `vshaxe.haxe-checkstyle` extension, which includes Haxe Checkstyle. |
| 10 | + |
| 11 | +### Haxe Checkstyle Notes |
| 12 | +* Checks can be escalated to display as different severities in the Problems window. |
| 13 | + * Checks can be disabled by setting the severity to `IGNORE`. |
| 14 | +* `IndentationCharacter` checks what is used to indent, `Indentation` checks how deep the indentation is. |
| 15 | +* `CommentedOutCode` check is in place because old code should be retrieved via Git history. |
| 16 | +* TODO items: Enable these one-by-one and fix them to improve the overall code quality. |
| 17 | + - Re-configure `MethodLength` |
| 18 | + - Re-configure `CyclomaticComplexity` |
| 19 | + - Re-enable `MagicNumber` |
| 20 | + - Re-configure `NestedControlFlow` |
| 21 | + - Re-configure `NestedIfDepth` |
| 22 | + - Figure out something for `Trace` |
| 23 | + - Fix bug and enable `DocCommentStyle` |
| 24 | + |
| 25 | +## .json |
| 26 | +Formatting is handled by the `esbenp.prettier-vscode` extension, which includes Prettier. |
| 27 | +Prettier automatically handles formatting of JSON files, and can be configured in `.prettierrc.js`. |
| 28 | + |
| 29 | +### Prettier Notes |
| 30 | +* Prettier will automatically attempt to place expressions on a single line if they fit, but will keep them multi-line if they are manually made multi-line. |
| 31 | + * This means that long single-line objects are automatically expanded, and short multi-line objects aren't automatically collapsed. |
| 32 | + * You may want to use regex replacement to manually remove the first newline in short multi-line objects to convince Prettier to collapse them. |
0 commit comments