Skip to content

feat: port 14 eslint-plugin-react rules#494

Merged
fansenze merged 1 commit intomainfrom
feat/port-rules-batch-20260306
Mar 12, 2026
Merged

feat: port 14 eslint-plugin-react rules#494
fansenze merged 1 commit intomainfrom
feat/port-rules-batch-20260306

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 6, 2026

Summary

Port 14 eslint-plugin-react rules to rslint.

Rules ported

Rule Description Doc
react/self-closing-comp Enforce self-closing on components without children link
react/void-dom-elements-no-children Prevent void DOM elements from receiving children link
react/style-prop-object Enforce style prop value is an object link
react/jsx-boolean-value Enforce boolean attributes notation in JSX link
react/jsx-equals-spacing Enforce spacing around = in JSX attributes link
react/jsx-filename-extension Restrict file extensions that may contain JSX link
react/jsx-first-prop-new-line Enforce position of the first prop in JSX link
react/jsx-max-props-per-line Limit maximum of props on a single line in JSX link
react/jsx-props-no-multi-spaces Disallow multiple spaces between JSX props link
react/jsx-closing-tag-location Enforce closing tag location for multiline JSX link
react/jsx-wrap-multilines Prevent missing parentheses around multiline JSX link
react/jsx-uses-react No-op (handled by TypeChecker) link
react/jsx-uses-vars No-op (handled by TypeChecker) link
react/react-in-jsx-scope No-op (handled by TypeChecker) link

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 integrates 14 core eslint-plugin-react rules into the rslint tool, written in Go. This enhancement provides developers with a more comprehensive set of linting checks specifically tailored for React applications, promoting better code quality, consistency, and adherence to React best practices. The new rules cover various aspects of JSX syntax and component usage, from attribute formatting to element structure and file conventions.

Highlights

  • New React ESLint Rules: Implemented 14 eslint-plugin-react rules in Go, significantly expanding rslint's React linting capabilities.
  • JSX Attribute Formatting: Added rules such as react/jsx-boolean-value, react/jsx-equals-spacing, react/jsx-first-prop-new-line, react/jsx-max-props-per-line, and react/jsx-props-no-multi-spaces to enforce consistent styling and best practices for JSX attributes.
  • JSX Structure and Syntax: Introduced react/jsx-closing-tag-location, react/jsx-wrap-multilines, react/self-closing-comp, react/style-prop-object, and react/void-dom-elements-no-children to ensure correct and idiomatic JSX element structure and usage.
  • File Naming and Compatibility: Included react/jsx-filename-extension to restrict file extensions for JSX, and added react/jsx-uses-react, react/jsx-uses-vars, and react/react-in-jsx-scope as no-op rules for configuration compatibility with ESLint.
  • Comprehensive Testing: Each new rule comes with dedicated Go-based tests and corresponding JavaScript/TypeScript test cases, ensuring robust validation of the ported logic.
Changelog
  • internal/config/config.go
    • Imported the new React plugin.
    • Registered all rules provided by the React plugin within the global rule registry.
  • internal/plugins/react/all.go
    • Added a new file to centralize the registration and export of all new React rules.
  • internal/plugins/react/plugin.go
    • Added a new file to define the eslint-plugin-react plugin name.
  • internal/plugins/react/rules/fixtures/file.ts
    • Added a new empty TypeScript fixture file for testing purposes.
  • internal/plugins/react/rules/fixtures/fixtures.go
    • Added a new utility file to provide the root directory for test fixtures.
  • internal/plugins/react/rules/fixtures/react.tsx
    • Added a new empty TSX fixture file for testing purposes.
  • internal/plugins/react/rules/fixtures/tsconfig.json
    • Added a new TypeScript configuration for React rule fixtures.
  • internal/plugins/react/rules/jsx_boolean_value/jsx_boolean_value.go
    • Implemented the jsx-boolean-value rule logic to enforce boolean attribute notation.
  • internal/plugins/react/rules/jsx_boolean_value/jsx_boolean_value_test.go
    • Added tests for the jsx-boolean-value rule.
  • internal/plugins/react/rules/jsx_closing_tag_location/jsx_closing_tag_location.go
    • Implemented the jsx-closing-tag-location rule logic to enforce consistent closing tag placement.
  • internal/plugins/react/rules/jsx_closing_tag_location/jsx_closing_tag_location_test.go
    • Added tests for the jsx-closing-tag-location rule.
  • internal/plugins/react/rules/jsx_equals_spacing/jsx_equals_spacing.go
    • Implemented the jsx-equals-spacing rule logic to enforce spacing around = in JSX attributes.
  • internal/plugins/react/rules/jsx_equals_spacing/jsx_equals_spacing_test.go
    • Added tests for the jsx-equals-spacing rule.
  • internal/plugins/react/rules/jsx_filename_extension/jsx_filename_extension.go
    • Implemented the jsx-filename-extension rule logic to restrict file extensions for JSX.
  • internal/plugins/react/rules/jsx_filename_extension/jsx_filename_extension_test.go
    • Added tests for the jsx-filename-extension rule.
  • internal/plugins/react/rules/jsx_first_prop_new_line/jsx_first_prop_new_line.go
    • Implemented the jsx-first-prop-new_line rule logic to enforce first prop positioning.
  • internal/plugins/react/rules/jsx_first_prop_new_line/jsx_first_prop_new_line_test.go
    • Added tests for the jsx-first-prop-new_line rule.
  • internal/plugins/react/rules/jsx_max_props_per_line/jsx_max_props_per_line.go
    • Implemented the jsx-max-props-per-line rule logic to limit props per line.
  • internal/plugins/react/rules/jsx_max_props_per_line/jsx_max_props_per_line_test.go
    • Added tests for the jsx-max-props-per-line rule.
  • internal/plugins/react/rules/jsx_props_no_multi_spaces/jsx_props_no_multi_spaces.go
    • Implemented the jsx-props-no-multi-spaces rule logic to prevent multiple spaces between props.
  • internal/plugins/react/rules/jsx_props_no_multi_spaces/jsx_props_no_multi_spaces_test.go
    • Added tests for the jsx-props-no-multi-spaces rule.
  • internal/plugins/react/rules/jsx_uses_react/jsx_uses_react.go
    • Implemented the jsx-uses-react rule as a no-op for compatibility.
  • internal/plugins/react/rules/jsx_uses_react/jsx_uses_react_test.go
    • Added tests for the jsx-uses-react rule.
  • internal/plugins/react/rules/jsx_uses_vars/jsx_uses_vars.go
    • Implemented the jsx-uses-vars rule as a no-op for compatibility.
  • internal/plugins/react/rules/jsx_uses_vars/jsx_uses_vars_test.go
    • Added tests for the jsx-uses-vars rule.
  • internal/plugins/react/rules/jsx_wrap_multilines/jsx_wrap_multilines.go
    • Implemented the jsx-wrap-multilines rule logic to enforce parentheses around multiline JSX.
  • internal/plugins/react/rules/jsx_wrap_multilines/jsx_wrap_multilines_test.go
    • Added tests for the jsx-wrap-multilines rule.
  • internal/plugins/react/rules/react_in_jsx_scope/react_in_jsx_scope.go
    • Implemented the react-in-jsx-scope rule as a no-op for compatibility.
  • internal/plugins/react/rules/react_in_jsx_scope/react_in_jsx_scope_test.go
    • Added tests for the react-in-jsx-scope rule.
  • internal/plugins/react/rules/self_closing_comp/self_closing_comp.go
    • Implemented the self-closing-comp rule logic to enforce self-closing for empty components.
  • internal/plugins/react/rules/self_closing_comp/self_closing_comp_test.go
    • Added tests for the self-closing-comp rule.
  • internal/plugins/react/rules/style_prop_object/style_prop_object.go
    • Implemented the style-prop-object rule logic to enforce object values for style props.
  • internal/plugins/react/rules/style_prop_object/style_prop_object_test.go
    • Added tests for the style-prop-object rule.
  • internal/plugins/react/rules/void_dom_elements_no_children/void_dom_elements_no_children.go
    • Implemented the void-dom-elements-no-children rule logic to prevent children in void DOM elements.
  • internal/plugins/react/rules/void_dom_elements_no_children/void_dom_elements_no_children_test.go
    • Added tests for the void-dom-elements-no-children rule.
  • packages/rslint-test-tools/rstest.config.mts
    • Updated the test configuration to include the newly added eslint-plugin-react rule tests.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rslint.json
    • Added a new ESLint configuration file specifically for testing eslint-plugin-react rules.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rule-tester.ts
    • Added a new custom rule tester for eslint-plugin-react rules, adapted from ESLint's rule tester.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-boolean-value.test.ts
    • Added JavaScript/TypeScript tests for the jsx-boolean-value rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-closing-tag-location.test.ts
    • Added JavaScript/TypeScript tests for the jsx-closing-tag-location rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-equals-spacing.test.ts
    • Added JavaScript/TypeScript tests for the jsx-equals-spacing rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-filename-extension.test.ts
    • Added JavaScript/TypeScript tests for the jsx-filename-extension rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-first-prop-new-line.test.ts
    • Added JavaScript/TypeScript tests for the jsx-first-prop-new-line rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-max-props-per-line.test.ts
    • Added JavaScript/TypeScript tests for the jsx-max-props-per-line rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-props-no-multi-spaces.test.ts
    • Added JavaScript/TypeScript tests for the jsx-props-no-multi-spaces rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/jsx-wrap-multilines.test.ts
    • Added JavaScript/TypeScript tests for the jsx-wrap-multilines rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/self-closing-comp.test.ts
    • Added JavaScript/TypeScript tests for the self-closing-comp rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/style-prop-object.test.ts
    • Added JavaScript/TypeScript tests for the style-prop-object rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/rules/void-dom-elements-no-children.test.ts
    • Added JavaScript/TypeScript tests for the void-dom-elements-no-children rule.
  • packages/rslint-test-tools/tests/eslint-plugin-react/tsconfig.files.json
    • Added a new TypeScript configuration for React test files.
  • packages/rslint-test-tools/tests/eslint-plugin-react/tsconfig.virtual.json
    • Added a new TypeScript configuration for virtual React test files.
Activity
  • No human activity has been recorded 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
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 is an impressive pull request that ports 14 eslint-plugin-react rules to Go. The implementations are well-structured, with each rule in its own package, complete with both Go unit tests and TypeScript-based integration tests. The code quality is high, and the rules appear to correctly implement the logic of their ESLint counterparts, including handling various configuration options. The no-op rules are also correctly identified and justified. I have one minor suggestion to improve code maintainability by reducing some duplication.

@fansenze fansenze force-pushed the feat/port-rules-batch-20260306 branch 23 times, most recently from 9cc733b to 42a15b1 Compare March 12, 2026 04:35
Port the following rules from eslint-plugin-react to Go:
- react/jsx-boolean-value
- react/jsx-closing-tag-location
- react/jsx-equals-spacing
- react/jsx-filename-extension
- react/jsx-first-prop-new-line
- react/jsx-max-props-per-line
- react/jsx-props-no-multi-spaces
- react/jsx-uses-react
- react/jsx-uses-vars
- react/jsx-wrap-multilines
- react/react-in-jsx-scope
- react/self-closing-comp
- react/style-prop-object
- react/void-dom-elements-no-children
@fansenze fansenze force-pushed the feat/port-rules-batch-20260306 branch from 42a15b1 to 1004840 Compare March 12, 2026 06:02
@fansenze fansenze requested a review from hardfist March 12, 2026 06:20
@fansenze fansenze merged commit 440089a into main Mar 12, 2026
14 checks passed
@fansenze fansenze deleted the feat/port-rules-batch-20260306 branch March 12, 2026 06:25
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