-
Notifications
You must be signed in to change notification settings - Fork 14
feat: port rule @typescript-eslint/no-array-constructor #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fansenze
wants to merge
6
commits into
main
Choose a base branch
from
feat/port-rule-no_array_constructor-20260123
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+979
−5
Conversation
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
✅ Deploy Preview for rslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Deploying rslint with
|
| Latest commit: |
829a95d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fff9ebc7.rslint.pages.dev |
| Branch Preview URL: | https://feat-port-rule-no-array-cons.rslint.pages.dev |
e2e7367 to
ea39960
Compare
Disallow generic Array constructors in favor of array literal notation. The rule reports Array() and new Array() calls with 0 or multiple arguments (single-argument calls like Array(5) are allowed as they create arrays with a specific size). Includes auto-fix to replace constructor calls with array literals. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Added missing commands to the skill documentation: - pnpm format:check - check JS/TS formatting - pnpm format - auto-fix JS/TS formatting - pnpm lint:go - check Go lint issues - pnpm format:go - auto-fix Go formatting These commands are required before committing to ensure code passes CI checks. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Refactor getArgumentsText to use scanner.GetScannerForSourceFile instead of manual character scanning for better robustness - Add test case for `new Array;` (without parentheses) - Add test cases with comments to match JS test coverage - Add multi-line test cases Go test invalid cases: 9 → 14 (now aligned with JS tests) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fixed a bug where nested parentheses like `Array((x), y)` or `Array(foo(), bar())` would produce incorrect fix output. The issue was that each `(` token would overwrite `openParenEnd`, causing the fix to extract text from the wrong position. Solution: Track parenthesis depth to correctly match the outermost opening and closing parentheses. Added test cases: - `Array((x), y);` → `[(x), y];` - `Array(foo(), bar());` → `[foo(), bar()];` Co-Authored-By: Claude Opus 4.5 <[email protected]>
Added documentation for common patterns discovered during rule porting: AST_PATTERNS.md: - Token Scanning section: using scanner.GetScannerForSourceFile API - Nested Structure Handling: tracking depth for parentheses/brackets PORT_RULE.md: - Improved AST Shim API Warning with concrete example - Added test coverage alignment step in Phase 4 QUICK_REFERENCE.md: - Added Go/JS test coverage alignment to checklist Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fix index out of range panic in printDiagnosticDefault when processing files that don't end with a newline. The boundary check incorrectly compared `line == len(lineMap)` instead of `line == len(lineMap)-1`, causing an out-of-bounds access to `lineMap[line+1]` on the last line. Co-Authored-By: Claude Opus 4.5 <[email protected]>
ea39960 to
829a95d
Compare
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
@typescript-eslint/no-array-constructorrule to rslintArrayconstructors in favor of array literals[]Array()andnew Array()with[]new Array;(no parens),Array?.()(optional chaining), nested parentheses, comments, multi-line expressionscmd/rslint/cmd.gowhen processing files without trailing newlineTest Plan
go test ./internal/plugins/typescript/rules/no_array_constructor/...)npx rstest run no-array-constructor)pnpm format:check && pnpm lint:go)pnpm run build:bin)References
🤖 Generated with Claude Code