sindresorhus/eslint-plugin-unicorn

autofix `unicorn/prefer-array-some` can corrupt code easily

Closed

#2,007 opened on Dec 6, 2022

 (2 comments) (0 reactions) (0 assignees)JavaScript (468 forks)user submission
bughelp wanted

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

code like

var res = $module.filter(selector.disabled).length > 0;

is currently autofixed to

var res = $module.some(selector.disabled);

but there is no $().some jQuery function, so the code is broken after autofix

IMHO the rule is legit, but there should be no autofix if the source cannot be 100% reasoned as an array

Contributor guide