codemodsquad / astx

Super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring
MIT License
104 stars 6 forks source link

refactor: find: rm useless condition #3

Open coderaiser opened 3 years ago

coderaiser commented 3 years ago

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

jedwards1211 commented 3 years ago

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

coderaiser commented 3 years ago

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