Auto-lint: convert .map(lambda → JSX) to list comprehension syntax (W3039)#5622
Open
SupulHeshan wants to merge 9 commits intojaseci-labs:mainfrom
Open
Auto-lint: convert .map(lambda → JSX) to list comprehension syntax (W3039)#5622SupulHeshan wants to merge 9 commits intojaseci-labs:mainfrom
SupulHeshan wants to merge 9 commits intojaseci-labs:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new auto-lint rule W3039 (map-lambda-to-comprehension) to rewrite React-style .map(lambda ... { return <jsx>; }) patterns into Jac list comprehension JSX syntax, improving idiomatic Jac output during auto-lint formatting.
Changes:
- Adds W3039 diagnostic text + kebab-case alias mapping.
- Extends
JacAutoLintPassAPI with helpers for building syntheticNamenodes and performing the.map(...)→ListComprAST rewrite. - Wires the conversion into
exit_func_callso it runs during auto-lint formatting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
jac/jaclang/jac0core/diagnostics.jac |
Defines W3039 warning message and adds alias mapping for config/back-compat. |
jac/jaclang/compiler/passes/tool/jac_auto_lint_pass.jac |
Imports W3039 and declares the new conversion helpers on the pass. |
jac/jaclang/compiler/passes/tool/impl/jac_auto_lint_pass.impl.jac |
Implements detection + AST rewrite and invokes it from exit_func_call. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new auto-lint rule W3039 (
map-lambda-to-comprehension) that automaticallyconverts verbose React-style
.map()lambda patterns to Jac's native JSX comprehension syntax.Before:
After:
When the lambda has no index parameter, the simpler form is used:
Changes
diagnostics.jac- addsW3039warning with kebab aliasmap-lambda-to-comprehensionjac_auto_lint_pass.jac- importsW3039, declares_make_name_nodeand_convert_map_to_comprehensionjac_auto_lint_pass.impl.jac- implements the detection + AST rewrite; wired intoexit_func_callPattern matched
<expr>.map(lambda ...)({ ... })with exactly one statement:return <JsxElement>int-typed parameter is recognized as the loop index →enumerate()is injected automatically