feat: add multi-language formatters for native platform code#414
feat: add multi-language formatters for native platform code#414realmeylisdev wants to merge 12 commits intoVeryGoodOpenSource:mainfrom
Conversation
Add formatting and linting support for non-Dart languages in templates: - Kotlin: ktlint for Android files - Swift: SwiftFormat for iOS/macOS files - C++: clang-format for Windows/Linux files New configuration files: - .editorconfig: shared editor settings - .swiftformat: Swift formatting rules - .clang-format: C++ formatting rules New reusable workflows: - kotlin_format.yaml - swift_format.yaml - cpp_format.yaml Updated template workflows with native format checks: - very_good_core - very_good_flame_game - very_good_flutter_plugin - very_good_wear_app Closes VeryGoodOpenSource#127
Format Kotlin, Swift, and C++ files in templates to comply with the new multi-language formatter CI checks: - Kotlin: Fix import ordering, spacing, unused imports, line wrapping - Swift: Fix 4-space indentation, import sorting, blank lines in scopes - C++: Apply Google style formatting, pointer alignment, else placement
- Wrap long lines in GeneratedPluginRegistrant.swift - Wrap long lines in Package.swift files and add trailing newline - Fix if/else brace style in Linux plugin - Re-format Linux example files with clang-format
- Exclude Flutter auto-generated files from swift-format checks - Fix Kotlin plugin formatting to comply with ktlint rules
- Wrap class signature, MethodChannel args, and onMethodCall params in Kotlin plugin template to satisfy ktlint line length rules - Update .swiftformat exclude patterns to use glob syntax for proper matching of Flutter-generated files
- Format Windows plugin C++ file to comply with clang-format rules - Fix circular import in Fluttium check_platform_name action by using relative import
- Format Linux plugin C++ files (.cc and .h) to comply with clang-format - Break long comment lines in iOS/macOS Package.swift to meet 100-char limit
|
@marcossevilla I think I got it right correct now. Please review! |
|
Hey @meylis1998, I’ve had a chance to look over this. I think we might be overthinking the formatting in the workflows. Wouldn’t it be simpler to start with some research if there’s already a workflow in place for this? Also, are the formatting configurations standardized? I was thinking, before adding formatting to each platform, we should first add one at a time and check out the standard configurations for each formatter before making any changes. |
Hey @marcossevilla, thanks for the review! You raise good points. On existing workflows: You're right to ask. I checked and there's no existing workflow for Swift/Kotlin/C++ formatting - only Dart. However, I did create reusable workflows ( On standardized configurations:
I should research the canonical/default configurations for each formatter before customizing. On adding one at a time: Agreed. This PR required 8 fix commits after the initial implementation, which suggests it's too broad. I'll split this into separate PRs:
This will also let us validate each formatter's config against the standard before moving on. I'll also look into existing GitHub Actions (like |
|
@meylis1998 are you okay closing this in favor of the following PRs breaking down each formatter? |
if you'd like me to resolve them one by one and you'll eventually give it a merge then I can do it either way I'm okay with closing it, appreciate your attention @marcossevilla |
|
I see all the CI erros now resolved |
@meylis1998 yes, that would be the approach I'd like to follow 👍 |
Summary
Adds formatting and linting support for non-Dart languages in templates, addressing #127.
Changes
New Configuration Files
.editorconfig.swiftformat.clang-formatNew Reusable Workflows
kotlin_format.yaml- Kotlin linting with ktlintswift_format.yaml- Swift formatting with SwiftFormatcpp_format.yaml- C++ formatting with clang-formatUpdated Template Workflows
very_good_corevery_good_flame_gamevery_good_flutter_pluginvery_good_wear_appTest Plan
Closes #127