UNPKG

eslint-plugin-remeda

Version:
32 lines (18 loc) • 839 B
# remeda/prefer-nullish-coalescing šŸ’¼ This rule is enabled in the āœ… `recommended` config. šŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). <!-- end auto-generated rule header --> When checking if a variable is not nil as a test for a ternary equation, it's more coincise to just use the nullish coalescing operator. ## Rule Details This rule takes no arguments. The following patterns are considered warnings: ```js const myExpression = !isNullish(myVar) ? myVar : myOtherVar; ``` The following patterns are not considered warnings: ```js const myExpression = !isNullish(myVar) ? mySecondVar : myThirdVar; const myExpression = myVar ?? myOtherVar; ``` ## When Not To Use It If you do not want to enforce using nullish coalescing.