feat: port rule react/checked-requires-onchange-or-readonly#1030
Merged
fansenze merged 2 commits intoMay 27, 2026
Merged
Conversation
Full parity required aligning the shared reactutil.IsCreateElementCall detector with upstream: accept optional-chain pragma (React?.createElement), reject parenthesized optional chains and TS-wrapped pragmas ((React as any).createElement). no_unstable_nested_components shared the same divergence and is corrected to match.
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements the new react/checked-requires-onchange-or-readonly rule, which ensures that checked attributes on <input> elements are accompanied by either onChange or readOnly attributes. It also refactors the pragma factory call detection logic in create_element.go to align with ESLint's handling of parenthesized optional chains and TS expression wrappers. The review feedback highlights several critical areas where missing nil checks on AST nodes (resulting from parser recovery on malformed syntax) could lead to nil pointer dereference panics. Code suggestions were provided to safely handle these edge cases.
Defensive: if a parenthesized callee flattens to nil (only possible for the empty-parens `()` syntax-error shape, which rslint does not lint), return early instead of nil-dereferencing through IsOptionalChain / callee.Kind.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port the
react/checked-requires-onchange-or-readonlyrule from eslint-plugin-react to rslint.It enforces that an
<input>(orReact.createElement('input', ...)) usingcheckedalso hasonChangeorreadOnly, and forbids combiningcheckedwithdefaultChecked.Achieving full upstream parity required aligning the shared
reactutil.IsCreateElementCalldetector with eslint-plugin-react'sisCreateElement:React?.createElement(...));(React?.createElement)(...)) and TS-wrapped pragmas ((React as any).createElement(...)), which upstream does not recognize.These were differential-verified against eslint-plugin-react. The same divergence affected
no_unstable_nested_components(which uses the same detector), so its two TS-wrapper test cases were corrected to match upstream.Related Links
Checklist