sindresorhus/eslint-plugin-unicorn
Rule change proposal regarding `prefer-ternary`:
Chiusa
#1620 aperta il 24 nov 2021
enhancementhelp wanted
Metriche repository
- Star
- (5022 stelle)
- Metriche merge PR
- (Merge medio 4h 30m) (26 PR mergiate in 30 g)
Descrizione
Description
prefer-ternary currently only supports
'simple' if-else statements, where 'simple' means the consequent and alternate are each one line and have the same basic type and form.
Would it be possible to also detect the following example?:
Fail
const data = getData();
const defaultData = getDefaultData();
let items = defaultData;
if (data.length) {
items = data;
}
Pass
const data = getData();
const defaultData = getDefaultData();
const items = data.length ? data : defaultData;