Skip to content

feat: port rule @stylistic/jsx-indent-props#1028

Merged
fansenze merged 1 commit into
mainfrom
feat/port-rule-jsx_indent_props-20260526
May 27, 2026
Merged

feat: port rule @stylistic/jsx-indent-props#1028
fansenze merged 1 commit into
mainfrom
feat/port-rule-jsx_indent_props-20260526

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

Summary

Port the @stylistic/jsx-indent-props rule to rslint. It enforces a consistent indentation style for the props of a JSX element — N spaces, a tab, or alignment with the first prop's column ("first"), with an optional ignoreTernaryOperator.

The @stylistic rule is byte-identical to react/jsx-indent-props, so the implementation is shared via BuildRule; only the registered name differs. This change also aligns a ternary-bump edge case in the shared implementation: when the first prop sits on the opening tag's ?/: line, upstream's getNodeIndent gives useOperator priority over useBracket, so the indent bump carries to the new-line props. Verified by a differential against @stylistic/eslint-plugin@5.10.0, including real-code runs over rsbuild/rspack (93 diagnostics, 0 divergence).

Related Links

Checklist

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

The @Stylistic rule is byte-identical to react/jsx-indent-props, so the
implementation is shared via BuildRule; only the registered name differs.

Also aligns a ternary-bump edge case in the shared implementation: when the
first prop sits on the opening tag's ?/: line, upstream's getNodeIndent gives
useOperator priority over useBracket, so the bump carries to the new-line
props. Verified by differential against @Stylistic 5.10.0 on rsbuild/rspack.
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 refactors the jsx-indent-props rule to support both the react and @stylistic variants using a shared BuildRule implementation. It also refines the ternary operator indentation logic to match upstream ESLint precedence and adds comprehensive test suites. The review comments identify potential nil pointer dereference vulnerabilities when handling AST properties in 'first' mode and during property iteration, offering robust code suggestions to ensure safety.

Comment thread internal/plugins/react/rules/jsx_indent_props/jsx_indent_props.go
Comment thread internal/plugins/react/rules/jsx_indent_props/jsx_indent_props.go
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 27, 2026

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: a65ecdc
Status: ✅  Deploy successful!
Preview URL: https://c42dcff2.rslint.pages.dev
Branch Preview URL: https://feat-port-rule-jsx-indent-pr.rslint.pages.dev

View logs

@fansenze fansenze force-pushed the feat/port-rule-jsx_indent_props-20260526 branch from c36ec01 to a65ecdc Compare May 27, 2026 03:13
@fansenze fansenze merged commit a9f0099 into main May 27, 2026
25 of 27 checks passed
@fansenze fansenze deleted the feat/port-rule-jsx_indent_props-20260526 branch May 27, 2026 04:20
eryue0220 added a commit to eryue0220/rslint that referenced this pull request May 27, 2026
… into feat/no-duplicate-hooks

* 'feat/no-duplicate-hooks' of github.com:eryue0220/rslint:
  test(eslint-plugin-runner): skip worker-pool e2e suites on windows (napi terminate aborts) (web-infra-dev#1031)
  feat: port rule react/checked-requires-onchange-or-readonly (web-infra-dev#1030)
  chore(deps): update actions/checkout action to v6 (web-infra-dev#1007)
  chore(deps): update actions/setup-go action to v6 (web-infra-dev#1009)
  chore(deps): update actions/setup-node action to v6 (web-infra-dev#1010)
  feat: port rule @stylistic/jsx-indent-props (web-infra-dev#1028)
  feat(eslint-plugin-runner): new package for ESLint plugin compatibility runtime (web-infra-dev#991)
  feat: port rule @stylistic/jsx-function-call-newline (web-infra-dev#1027)
  feat(eslint-plugin-jest): add `prefer-called-with` rule (web-infra-dev#1025)
  feat: port rule @stylistic/jsx-first-prop-new-line (web-infra-dev#1024)
  feat: port rule @stylistic/jsx-curly-spacing (web-infra-dev#1023)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant