4 comments (4 comments)3 reactions (3 reactions)0 assignees (0 assignees)JavaScript468 forks (468 forks)user submission
help wantednew rule
Repository metrics
- Stars
- 5,022 stars (5,022 stars)
- PR merge metrics
- Avg merge 1d 16h (Avg merge 1d 16h)399 merged PRs in 30d (399 merged PRs in 30d)
Description
More readable
.childNodes[0] -> .firstChild
.children[0] -> .firstElementChild
More robust
.children[1] -> .querySelector('selector')
.children[1].children[2] -> .querySelector('selector')
.parentElement.parentElement -> .closest('selector')
.querySelector('a').querySelector('b') -> .querySelector('a b')
Contributor guide
- Research direction
- Examine existing rules in the `rules` directory of eslint plugin unicorn, particularly those related to DOM node methods. The proposed patterns (`.childNodes[0]` > `.firstChild`, etc.) can be implemented using AST selectors. The rule should suggest using more specific methods for readability and robustness. Look at the rule structure in files like `prefer dom node append.js` for reference. The implementation involves detecting the pattern and suggesting the replacement. Tests should be added following the existing test patterns.
- Tech stack
- javascript
- Domain
- developer experience
- Issue type
- Feature
- Prerequisites
- ESLint rule developmentJavaScriptAST basics