Skip to content

feat: port rule no-undef#540

Merged
chenjiahan merged 1 commit intomainfrom
feat/port-rule-no-undef-20260317
Mar 27, 2026
Merged

feat: port rule no-undef#540
chenjiahan merged 1 commit intomainfrom
feat/port-rule-no-undef-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the no-undef rule from ESLint to rslint.

Disallow the use of undeclared variables

Related Links

Checklist

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

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the no-undef rule, a fundamental linting check ported from ESLint, to the rslint project. This rule is crucial for maintaining code quality by detecting references to variables that have not been declared, thereby preventing potential runtime errors and improving code robustness.

Highlights

  • New Rule Implementation: Implemented the no-undef rule, which identifies and reports the use of undeclared variables, enhancing code reliability.
  • Rule Integration: Integrated the new no-undef rule into the rslint configuration, making it available for use.
  • Testing and Documentation: Provided comprehensive unit tests and detailed documentation for the no-undef rule, including its options and examples.
Changelog
  • internal/config/config.go
    • Imported the no_undef package.
    • Registered the no-undef rule in the global rule registry.
  • internal/rules/no_undef/no_undef.go
    • Added the no-undef rule implementation, including parseOptions for the typeof option.
    • Implemented shouldSkip to filter out identifiers that are not value references.
    • Implemented isInTypeOnlyPosition and isStatementOrDeclarationBoundary to correctly handle type-only contexts.
  • internal/rules/no_undef/no_undef.md
    • Added documentation for the no-undef rule, detailing its purpose, typeof option, and examples.
  • internal/rules/no_undef/no_undef_test.go
    • Added unit tests for the no-undef rule, covering various valid and invalid code snippets and the typeof option.
  • packages/rslint-test-tools/rstest.config.mts
    • Added the no-undef.test.ts file to the list of ESLint rule tests.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-undef.test.ts.snap
    • Added a snapshot test file for the no-undef rule.
  • packages/rslint-test-tools/tests/eslint/rules/no-undef.test.ts
    • Added a new test file using RuleTester for the no-undef rule.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@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 successfully ports the no-undef rule from ESLint, which is a valuable addition for catching undeclared variables. The implementation is robust, leveraging the TypeScript type checker to handle various edge cases effectively. The new rule is well-integrated with proper configuration and comprehensive test coverage, including both unit and integration tests. I've identified a couple of minor opportunities for code simplification in the rule's implementation to enhance maintainability by removing redundant checks. Overall, this is a well-executed feature.

@fansenze fansenze force-pushed the feat/port-rule-no-undef-20260317 branch 2 times, most recently from bb9e017 to bc53c9f Compare March 17, 2026 11:37
@fansenze fansenze force-pushed the feat/port-rule-no-undef-20260317 branch 4 times, most recently from 154178e to 2c85f88 Compare March 18, 2026 03:48
@fansenze fansenze force-pushed the feat/port-rule-no-undef-20260317 branch 2 times, most recently from 9444f9b to 0a6214d Compare March 27, 2026 03:38
@fansenze fansenze force-pushed the feat/port-rule-no-undef-20260317 branch from 08856da to 60f9da5 Compare March 27, 2026 04:26
@chenjiahan chenjiahan merged commit 78f2da8 into main Mar 27, 2026
10 checks passed
@chenjiahan chenjiahan deleted the feat/port-rule-no-undef-20260317 branch March 27, 2026 08:19
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