Skip to content

Add ECS linter and formatter - #8

Merged
mikecovlee merged 13 commits into
mainfrom
format_lint
Jul 24, 2026
Merged

Add ECS linter and formatter#8
mikecovlee merged 13 commits into
mainfrom
format_lint

Conversation

@mikecovlee

Copy link
Copy Markdown
Member

No description provided.

- 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_parser with strict/non-strict lexical + syntax modes to preserve comments/newlines for formatter use.
  • Add ecs_lint (AST + source-based lint rules) and ecs_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.

Comment thread imports/ecs_lint.csp
Comment thread imports/ecs_lint.csp
Comment thread imports/ecs_bootstrap.csp Outdated
@mikecovlee
mikecovlee merged commit a23311d into main Jul 24, 2026
3 checks passed
@mikecovlee
mikecovlee deleted the format_lint branch July 24, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants