ESLint is telling me this error message inside my JS module: error no-unneeded-ternary Unnecessary use of conditional expression for default assignment
The error comes in the get
method on the return
statement return val ? val : defaultVal;
?
import ls from 'local-storage';
export default {
get(key, defaultVal = null) {
var val = ls(key);
return val ? val : defaultVal;
},
set(key, val) {
return ls(key, val);
},
remove(key) {
return ls.remove(key);
},
};
Any idea why do I get this error message? I have found some resource on ESLint's website regarding this error message here but it applies to boolean expressions and I can not figure out why would that apply to my code...