sindresorhus/eslint-plugin-unicorn
Rule proposal: `prefer-scoped-selector`
Chiusa
#1429 aperta il 16 lug 2021
help wantednew rule
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Many people don't know the Element.querySelector() and Element.querySelectorAll() behaves differently than most common JavaScript DOM libraries, details.
Got the idea here
Fail
const inner = element.querySelectorAll('.outer .inner');
Pass
const inner = document.querySelectorAll('.outer .inner');
const inner = element.querySelectorAll(':scope .outer .inner');
I'm not sure about these, they are never going to get wrong result.
const inner = element.querySelectorAll('.a');
const inner = element.querySelectorAll('.a + .b');
Should we enforce them consistently, or only check descendant combinator and child combinator?