diff --git a/rules/no-useless-undefined.js b/rules/no-useless-undefined.js index 4a24698a6a..8239bcba9f 100644 --- a/rules/no-useless-undefined.js +++ b/rules/no-useless-undefined.js @@ -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'; diff --git a/test/no-useless-undefined.mjs b/test/no-useless-undefined.mjs index c95c7dde35..fd10559916 100644 --- a/test/no-useless-undefined.mjs +++ b/test/no-useless-undefined.mjs @@ -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)',