6 ms·
I’d flag this if I saw this in a code review. It’s to cute and hard to see what’s happening. Would much rather just see someone prefix with an underscore if the
by travisd 4y ago
I’d flag this if I saw this in a code review. It’s to cute and hard to see what’s happening. Would much rather just see someone prefix with an underscore if they don’t need the variable (const [id, _email, name] = loadUserInfo(…); is preferable to const [id, , name]).
- postalrat 4y agoWhy on earth would you prefer they create variables that aren't used. Learn the language.
- kamranjon 4y agoUnfortunately eslint would likely flag this as unused vars, so typically you would not do this as you've described. Object destructuring is a bit more forgiving and can be a nice alternative: const {id, name} = loadUserInfo() - assuming you wrote loadUserInfo and are in control of the return value.
- artdigital 4y agoYou can easily add a rule to eslint that makes it not complain _xxx for unused variables: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern https://eslint.org/docs/latest/rules/no-unused-vars#argsigno...
- deleted 4y ago[deleted]