Skip to content

Conversation

@fansenze
Copy link
Contributor

@fansenze fansenze commented Jan 23, 2026

Summary

  • Port the @typescript-eslint/no-array-constructor rule to rslint
  • Disallow generic Array constructors in favor of array literals []
  • Support auto-fix to replace Array() and new Array() with []
  • Handle edge cases: new Array; (no parens), Array?.() (optional chaining), nested parentheses, comments, multi-line expressions
  • Fix panic in cmd/rslint/cmd.go when processing files without trailing newline

Test Plan

  • Go unit tests pass (go test ./internal/plugins/typescript/rules/no_array_constructor/...)
  • JS integration tests pass (npx rstest run no-array-constructor)
  • Lint checks pass (pnpm format:check && pnpm lint:go)
  • Build succeeds (pnpm run build:bin)

References

🤖 Generated with Claude Code

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for rslint ready!

Name Link
🔨 Latest commit 829a95d
🔍 Latest deploy log https://app.netlify.com/projects/rslint/deploys/697727d899c0490008571a5d
😎 Deploy Preview https://deploy-preview-443--rslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 23, 2026

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

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

View logs

@fansenze fansenze force-pushed the feat/port-rule-no_array_constructor-20260123 branch 3 times, most recently from e2e7367 to ea39960 Compare January 26, 2026 07:50
fansenze and others added 6 commits January 26, 2026 16:36
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]>
@fansenze fansenze force-pushed the feat/port-rule-no_array_constructor-20260123 branch from ea39960 to 829a95d Compare January 26, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants