astx icon indicating copy to clipboard operation
astx copied to clipboard

refactor: find: rm useless condition

Open coderaiser opened this issue 4 years ago • 2 comments

Both parts of expression:

const nodeTypes = Array.isArray(matcher.nodeType)
    ? matcher.nodeType
    : matcher.nodeType

Returns same result, and can be simplified to:

matcher.nodeType

Just landed this case to @putout/plugin-simplify-ternary 🎉
With commit https://github.com/coderaiser/putout/commit/c08ec496d62fe1786d2f9031d4957789c3e28cb9

coderaiser avatar Apr 09 '21 13:04 coderaiser

Actually this was a bug and the else condition should be [matcher.nodeType]. Weird that I missed this...

jedwards1211 avatar Apr 24 '21 20:04 jedwards1211

There is more such cases, you can find them with putout :). Static analysis can’t be to much.

coderaiser avatar Apr 25 '21 09:04 coderaiser