unicorn/better-dom-traversing
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/better-dom-traversing": "error",
},
},
];element.childNodes[0];element.children[0];element.children[2];element.firstChild;element.firstElementChild;element.querySelector(':scope selector');Examples from the ESLint documentation.
unicorn/better-dom-traversing
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/better-dom-traversing": "error",
},
},
];Oxlint does not have this rule.
nursery/useBetterDomTraversing
nursery · since 2.5.13
{
"linter": {
"rules": {
"nursery": {
"useBetterDomTraversing": "error"
}
}
}
}Prefer top-level await over top-level promises and async function calls.
Prefer drawing canvases directly instead of converting them to images.
Prefer using the String.raw tag to avoid escaping \.
Disallow arithmetic and bitwise operations that always evaluate to 0.
Disallow unnecessary .toArray() on iterators.
Disallow interpolation into SQL strings passed to Node’s node:sqlite APIs.