Skip to content

feat: port rule no-var#532

Open
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-var-20260317
Open

feat: port rule no-var#532
fansenze wants to merge 1 commit intomainfrom
feat/port-rule-no-var-20260317

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 17, 2026

Summary

Port the no-var rule from ESLint to rslint.

Require let or const instead of var

Related Links

Checklist

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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-var rule, a significant addition to the linter's capabilities. Its primary goal is to guide developers towards modern JavaScript variable declaration practices by flagging instances of var and promoting the use of let and const. This change enhances code quality and consistency across projects using rslint by aligning with current best practices.

Highlights

  • New Linting Rule: Implemented the no-var rule, which disallows the use of var for variable declarations, promoting let and const instead.
  • Rule Integration: The new no-var rule has been integrated into the rslint configuration and registered for use.
  • Comprehensive Testing and Documentation: Added dedicated Go-based unit tests, TypeScript-based RuleTester tests, snapshot tests, and markdown documentation for the no-var rule.
Changelog
  • internal/config/config.go
    • Imported the no_var rule package.
    • Registered the no-var rule in the global rule registry.
  • internal/rules/no_var/no_var.go
    • Added the NoVarRule definition, including its name and Run function.
    • Implemented the rule logic to identify VariableStatement nodes that are not block-scoped (i.e., var declarations) and report them.
  • internal/rules/no_var/no_var.md
    • Created documentation explaining the no-var rule, its purpose, and providing examples of correct and incorrect code.
  • internal/rules/no_var/no_var_test.go
    • Added Go-based unit tests for the no-var rule, including valid and invalid test cases ported from ESLint.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the new no-var.test.ts file.
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-var.test.ts.snap
    • Generated snapshot tests for the no-var rule's invalid cases, capturing diagnostic output.
  • packages/rslint-test-tools/tests/eslint/rules/no-var.test.ts
    • Added TypeScript-based RuleTester tests for the no-var rule, defining valid and invalid code examples.
Activity
  • No specific activity (comments, reviews, etc.) 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
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 ports the no-var rule from ESLint. The implementation is a good start, but it currently misses detecting var declarations inside loop initializers (for, for-in, for-of), which is a key part of this rule's functionality. I've provided a suggestion to fix the rule implementation to cover these cases. I've also suggested adding corresponding test cases to both the Go unit tests and the TypeScript E2E tests to ensure complete coverage and prevent regressions.

@fansenze fansenze force-pushed the feat/port-rule-no-var-20260317 branch from a3be05b to 025be5d Compare March 17, 2026 11:33
@fansenze fansenze force-pushed the feat/port-rule-no-var-20260317 branch 2 times, most recently from ca74d78 to cdf1247 Compare March 18, 2026 02:53
@fansenze fansenze force-pushed the feat/port-rule-no-var-20260317 branch from cdf1247 to 6cc6d15 Compare March 18, 2026 03:02
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.

1 participant