useMediaCaption (since v12.0.0)
Enforces that audio
and video
elements must have a track
for captions.
ESLint Equivalent: media-has-caption
Examples
Invalid
<video />
nursery/useMediaCaption.js:1:2 lint/nursery/useMediaCaption ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Provide a track for captions when using audio or video elements.
> 1 │ <video />
│ ^^^^^^^^^
2 │
ℹ Captions support users with hearing-impairments. They should be a transcription or translation of the dialogue, sound effects, musical cues, and other relevant audio information.
<audio>child</audio>
nursery/useMediaCaption.js:1:2 lint/nursery/useMediaCaption ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Provide a track for captions when using audio or video elements.
> 1 │ <audio>child</audio>
│ ^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Captions support users with hearing-impairments. They should be a transcription or translation of the dialogue, sound effects, musical cues, and other relevant audio information.
Valid
<audio>
<track kind="captions" {...props} />
</audio>
<video muted {...props}></video>