Uh oh!
There was an error while loading. Please reload this page.
Add ECS linter and formatter - #8
Conversation
- Introduced a new linter package (ecs_lint) that includes various linting rules for naming conventions, empty blocks, unreachable code, and formatting issues. - Implemented helper functions for checking naming styles (snake_case, UPPER_SNAKE_CASE) and identifying comments or blank lines. - Enhanced the parser (ecs_parser) to support format-specific syntax and lexical rules. - Created a test file (test_lint.ecs) containing intentional style issues to verify the linter's functionality.
- Introduced `get_fmt_grammar` and `get_fmt_syntax` functions to handle format-specific grammar and syntax. - Updated `get_lexical` to accept a `strict` parameter, allowing for different lexical rules based on mode. - Modified grammar rules to differentiate between strict and non-strict parsing, particularly in handling comments and newlines. - Enhanced syntax definitions to use function pointers for end-of-line and end-of-statement handling based on the parsing mode. - Removed redundant code and improved overall structure for better maintainability and readability.
…ved readability and maintainability
…handling and code structure
… and unused expressions
…s and syntax handling
…o reflect latest releases
… and useless expressions
There was a problem hiding this comment.
Pull request overview
Adds first-party linting and formatting support to the ECS toolchain by extending the parser to support a strict/comment-preserving mode, introducing new ecs_lint / ecs_format packages, wiring them into the ecs bootstrap wrapper, and adding unit tests + fixtures to validate behavior.
Changes:
- Extend
ecs_parserwith strict/non-strict lexical + syntax modes to preserve comments/newlines for formatter use. - Add
ecs_lint(AST + source-based lint rules) andecs_format(AST-driven formatter using strict grammar). - Add wrapper flags (
-l,-F,-n) and unit tests/fixtures to exercise parser modes and lint rules.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| unit_tests/test_parser_modes.ecs | Adds unit coverage for strict vs non-strict parser mode behavior. |
| unit_tests/test_lint_rules.ecs | Adds unit coverage asserting expected lint rule detections and severity counts. |
| tests/test_lint.ecs | Adds an intentionally “bad style” fixture file to trigger lint rules. |
| imports/ecs.csp | Introduces lambda_base marker type and updates function type validation for lambdas. |
| imports/ecs_parser.csp | Adds strict-aware lexical/syntax generation and updates default grammar wiring. |
| imports/ecs_lint.csp | New linter implementation (rules + AST walker + report printing). |
| imports/ecs_generator.csp | Updates lambda body handling and generated lambda struct base type; improves REPL error cleanup. |
| imports/ecs_format.csp | New formatter implementation using strict grammar and comment-aware line handling. |
| imports/ecs_bootstrap.csp | Adds ecs -l / ecs -F / ecs -n modes, adjusts cache behavior, and updates exit codes. |
| csbuild/ecs.json | Bumps ecs package version to reflect runtime type-system change. |
| csbuild/ecs_parser.json | Bumps ecs_parser package version to reflect strict mode API. |
| csbuild/ecs_lint.json | Adds build package definition for the new linter. |
| csbuild/ecs_generator.json | Bumps ecs_generator package version for lambda-related changes. |
| csbuild/ecs_format.json | Adds build package definition for the new formatter. |
| csbuild/ecs_bootstrap.json | Bumps wrapper version and adds dependencies on new lint/format packages. |
Comments suppressed due to low confidence (1)
imports/ecs_lint.csp:400
- The position for trailing consecutive blank lines at EOF uses 0-based line indexes (
ctx.code_buff.size - blank_count). This will point to the wrong line in reports; it should be 1-based like other parsergen positions.
if blank_count > 2
ctx.add_issue({1, ctx.code_buff.size - blank_count}, "Too many consecutive blank lines (" + to_string(blank_count) + ").", SEVERITY_INFO, "consecutive_blank_lines")
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
No description provided.