Skip to content

Commit

Permalink
no-useless-undefined: Ignore React 19 useRef calls (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
chirokas authored Oct 3, 2024
1 parent e39ae89 commit 5f744e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rules/no-useless-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const shouldIgnore = node => {
|| name === 'createContext'
// `setState(undefined)`
|| /^set[A-Z]/.test(name)
// React 19 useRef
|| name === 'useRef'

// https://vuejs.org/api/reactivity-core.html#ref
|| name === 'ref';
Expand Down
2 changes: 2 additions & 0 deletions test/no-useless-undefined.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ test({
'array.unshift(undefined);',
'createContext(undefined);',
'React.createContext(undefined);',
'useRef(undefined);',
'React.useRef(undefined);',
'setState(undefined)',
'setState?.(undefined)',
'props.setState(undefined)',
Expand Down

0 comments on commit 5f744e8

Please sign in to comment.