Rules
ref-name
Enforces identifier names assigned from 'useRef' calls to be either 'ref' or end with 'Ref'.
Full Name in eslint-plugin-react-naming-convention
react-naming-convention/ref-nameFull Name in @eslint-react/eslint-plugin
@eslint-react/naming-convention-ref-namePresets
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
Enforces identifier names assigned from useRef calls to be either ref or end with Ref.
Common Violations
Invalid
const count = useRef(0);
// ^^^ A ref identifier must be named 'ref' or end in 'Ref'.const input = useRef<HTMLInputElement>(null);
// ^^^ A ref identifier must be named 'ref' or end in 'Ref'.const value = useRef(null);
// ^^^ A ref identifier must be named 'ref' or end in 'Ref'.Valid
const ref = useRef(0);const countRef = useRef(0);const inputRef = useRef<HTMLInputElement>(null);const valueRef = useRef(null);Resources
Further Reading
See Also
react-naming-convention/id-name
Enforces identifier names assigned fromuseIdcalls to be eitheridor end withId.