Skip to content

fix: add nil TypeChecker guard in no-ex-assign rule#600

Merged
fansenze merged 1 commit intomainfrom
fix/no-ex-assign-nil-checker-20260407
Apr 7, 2026
Merged

fix: add nil TypeChecker guard in no-ex-assign rule#600
fansenze merged 1 commit intomainfrom
fix/no-ex-assign-nil-checker-20260407

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Apr 7, 2026

Summary

collectCatchBindingNamesAndSymbols in the no-ex-assign rule accessed ctx.TypeChecker.GetSymbolAtLocation() without a nil check, causing a panic on files where no type checker is available (e.g. TS files not covered by any project config in the self-lint).

This fix adds nil guards at the two call sites (lines 24 and 39), consistent with how other core ESLint rules (no-func-assign, no-import-assign, no-setter-return, etc.) handle the absent checker.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

collectCatchBindingNamesAndSymbols accessed ctx.TypeChecker without
a nil check, causing a panic on files where no type checker is
available (e.g. TS files not covered by any project config).
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces nil checks for ctx.TypeChecker in the collectCatchBindingNamesAndSymbols function within internal/rules/no_ex_assign/no_ex_assign.go. These changes prevent potential nil pointer dereferences when attempting to retrieve symbols at specific locations. I have no feedback to provide.

@fansenze fansenze enabled auto-merge (squash) April 7, 2026 03:27
@fansenze fansenze merged commit ac9ce6d into main Apr 7, 2026
11 checks passed
@fansenze fansenze deleted the fix/no-ex-assign-nil-checker-20260407 branch April 7, 2026 03:36
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