prefer-dom-node-text-content
UnreleasedConfiguration
rslint.config.ts
Rule Details
Prefer .textContent over .innerText on DOM nodes. Reading .innerText depends
on rendered layout and can trigger reflow. Use .innerText when you need the
text as rendered. MDN Node.textContent
This rule checks dot access, including optional chains, and identifier keys in object destructuring. It skips values known to have a non-DOM type. Its editor suggestion preserves the local name in shorthand destructuring.
Examples of incorrect code
Examples of correct code
Options
This rule has no options.
Differences from upstream
With project type information, rslint can distinguish browser DOM types from
application types that share their names. For example, if ./library exports
its own Node class, eslint-plugin-unicorn reports the access below and rslint
skips it.