Skip to content

feat: port 8 ESLint core rules#471

Open
fansenze wants to merge 3 commits intomainfrom
feat/port-rules-batch-20260211
Open

feat: port 8 ESLint core rules#471
fansenze wants to merge 3 commits intomainfrom
feat/port-rules-batch-20260211

Conversation

@fansenze
Copy link
Contributor

@fansenze fansenze commented Feb 11, 2026

Summary

Port 8 ESLint core rules to rslint.

Rules ported

Rule Description Doc
default-case Require default case in switch statements link
no-case-declarations Disallow lexical declarations in case clauses link
no-console Disallow the use of console link
no-dupe-args Disallow duplicate arguments in function definitions link
no-dupe-keys Disallow duplicate keys in object literals link
no-duplicate-case Disallow duplicate case labels link
no-empty Disallow empty block statements link
no-empty-pattern Disallow empty destructuring patterns link

Related Links

Checklist

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

@gemini-code-assist
Copy link

Summary of Changes

Hello @fansenze, 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 significantly enhances RSLint's rule set by porting eight essential ESLint core rules. The additions cover common JavaScript pitfalls and best practices, such as enforcing default cases in switch statements, preventing lexical declarations in case clauses, disallowing console usage, and detecting duplicate function arguments or object keys. This effort improves code quality and consistency for users leveraging RSLint.

Highlights

  • New ESLint Core Rules: Eight ESLint core rules have been ported to RSLint, expanding its linting capabilities. These include default-case, no-case-declarations, no-console, no-dupe-args, no-dupe-keys, no-duplicate-case, no-empty, and no-empty-pattern.
  • Comprehensive Rule Implementation: Each new rule comes with its Go implementation, dedicated Go unit tests, detailed documentation, and JavaScript integration tests with snapshots to ensure correctness and compatibility.
  • Test Infrastructure Updates: The rstest.config.mts file has been updated to include the new JavaScript integration tests, ensuring that all new rules are properly tested within the RSLint framework.
Changelog
  • cmd/tsgo/semantic.go
    • Adjusted indentation for struct fields
  • internal/config/config.go
    • Added imports for eight new ESLint rules
    • Registered eight new ESLint rules in the global rule registry
  • internal/inspector/flags.go
    • Adjusted indentation for map entries
  • internal/inspector/types.go
    • Adjusted indentation for struct fields
  • internal/linter/source_code_fixer_test.go
    • Adjusted indentation in test case definition
  • internal/plugins/typescript/rules/prefer_readonly/prefer_readonly.go
    • Adjusted indentation for constants and struct fields
  • internal/rules/default_case/default_case.go
    • Added implementation for the default-case rule, requiring default cases in switch statements or an opt-out comment
  • internal/rules/default_case/default_case.md
    • Added documentation for the default-case rule, including examples and options
  • internal/rules/default_case/default_case_test.go
    • Added Go unit tests for the default-case rule
  • internal/rules/no_case_declarations/no_case_declarations.go
    • Added implementation for the no-case-declarations rule, disallowing lexical declarations in case clauses
  • internal/rules/no_case_declarations/no_case_declarations.md
    • Added documentation for the no-case-declarations rule, including examples
  • internal/rules/no_case_declarations/no_case_declarations_test.go
    • Added Go unit tests for the no-case-declarations rule
  • internal/rules/no_console/no_console.go
    • Added implementation for the no-console rule, disallowing console usage with an allow option
  • internal/rules/no_console/no_console.md
    • Added documentation for the no-console rule, including examples and options
  • internal/rules/no_console/no_console_test.go
    • Added Go unit tests for the no-console rule
  • internal/rules/no_dupe_args/no_dupe_args.go
    • Added implementation for the no-dupe-args rule, disallowing duplicate function parameter names
  • internal/rules/no_dupe_args/no_dupe_args.md
    • Added documentation for the no-dupe-args rule, including examples
  • internal/rules/no_dupe_args/no_dupe_args_test.go
    • Added Go unit tests for the no-dupe-args rule
  • internal/rules/no_dupe_keys/no_dupe_keys.go
    • Added implementation for the no-dupe-keys rule, disallowing duplicate keys in object literals
  • internal/rules/no_dupe_keys/no_dupe_keys.md
    • Added documentation for the no-dupe-keys rule, including examples
  • internal/rules/no_dupe_keys/no_dupe_keys_test.go
    • Added Go unit tests for the no-dupe-keys rule
  • internal/rules/no_duplicate_case/no_duplicate_case.go
    • Added implementation for the no-duplicate-case rule, disallowing duplicate case labels in switch statements
  • internal/rules/no_duplicate_case/no_duplicate_case.md
    • Added documentation for the no-duplicate-case rule, including examples
  • internal/rules/no_duplicate_case/no_duplicate_case_test.go
    • Added Go unit tests for the no-duplicate-case rule
  • internal/rules/no_empty/no_empty.go
    • Added implementation for the no-empty rule, disallowing empty block statements and switch statements
  • internal/rules/no_empty/no_empty.md
    • Added documentation for the no-empty rule, including examples and options
  • internal/rules/no_empty/no_empty_test.go
    • Added Go unit tests for the no-empty rule
  • internal/rules/no_empty_pattern/no_empty_pattern.go
    • Added implementation for the no-empty-pattern rule, disallowing empty destructuring patterns
  • internal/rules/no_empty_pattern/no_empty_pattern.md
    • Added documentation for the no-empty-pattern rule, including examples and options
  • internal/rules/no_empty_pattern/no_empty_pattern_test.go
    • Added Go unit tests for the no-empty-pattern rule
  • packages/rslint-test-tools/rstest.config.mts
    • Updated test configuration to include new ESLint rule test files
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/default-case.test.ts.snap
    • Added snapshot for default-case rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-case-declarations.test.ts.snap
    • Added snapshot for no-case-declarations rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-console.test.ts.snap
    • Added snapshot for no-console rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-dupe-args.test.ts.snap
    • Added snapshot for no-dupe-args rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-dupe-keys.test.ts.snap
    • Added snapshot for no-dupe-keys rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-duplicate-case.test.ts.snap
    • Added snapshot for no-duplicate-case rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-empty-pattern.test.ts.snap
    • Added snapshot for no-empty-pattern rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/snapshots/no-empty.test.ts.snap
    • Added snapshot for no-empty rule integration tests
  • packages/rslint-test-tools/tests/eslint/rules/default-case.test.ts
    • Added JavaScript integration tests for the default-case rule
  • packages/rslint-test-tools/tests/eslint/rules/no-case-declarations.test.ts
    • Added JavaScript integration tests for the no-case-declarations rule
  • packages/rslint-test-tools/tests/eslint/rules/no-console.test.ts
    • Added JavaScript integration tests for the no-console rule
  • packages/rslint-test-tools/tests/eslint/rules/no-dupe-args.test.ts
    • Added JavaScript integration tests for the no-dupe-args rule
  • packages/rslint-test-tools/tests/eslint/rules/no-dupe-keys.test.ts
    • Added JavaScript integration tests for the no-dupe-keys rule
  • packages/rslint-test-tools/tests/eslint/rules/no-duplicate-case.test.ts
    • Added JavaScript integration tests for the no-duplicate-case rule
  • packages/rslint-test-tools/tests/eslint/rules/no-empty-pattern.test.ts
    • Added JavaScript integration tests for the no-empty-pattern rule
  • packages/rslint-test-tools/tests/eslint/rules/no-empty.test.ts
    • Added JavaScript integration tests for the no-empty rule
Activity
  • The pull request was opened by fansenze.
  • No human activity (comments, reviews) has occurred on 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

@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 8 ESLint core rules to RSLint, including implementations, tests, and documentation. The changes are well-structured and the new rules are correctly integrated. I found one issue in the no-empty-pattern rule implementation where the logic to detect if a binding pattern is a function parameter is flawed for nested destructuring cases. I've provided a more robust implementation using ast.FindAncestor. The rest of the implementations look solid.

@fansenze fansenze force-pushed the feat/port-rules-batch-20260211 branch 3 times, most recently from d87eb7a to 292c6ea Compare February 12, 2026 02:42
@fansenze fansenze force-pushed the feat/port-rules-batch-20260211 branch from 80b260b to 89446c9 Compare February 12, 2026 03:32
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