We have, um, a lot, of 'unused bindings' from code like this:
This warning helps with variable shadowing
I like my linter to warn me about things that are likely to be an actual problem when running the code and unused bindings don’t cross that threshold for meInteresting, I understand this reasoning, but personally I think it does cross that threshold.
Like if you have foo and bar and you are supposed to use them both, but you made a copy-paste mistake and used bar in two places, foo is then unused and linter warns about that, and that definitely is a bug in the code
I agree. I love being warned about unused bindings.
Yes, I can think on multiple cases where the linter saves you from bugs like that, it's not a silver bullet tho, but it's worth it for sure
> What do people do about these?
For reagent components I use with-let
+1 for preferring prefix underscore. no information/readability lost, the variable name is still there, and you also signal to a human reader that it is intentionally unused. lsp-rename is very necessary to my workflow and removes any pain from things like this
What do people do about these? I know I could throw underscores all over the place, but I'm wondering if that's the best idea, or if there's something better.
I turn them off on my projects, not a fan of adding and removing underscores
I feel a warning is too strong for this. I especially don’t like it when folks replace a name with just an underscore so you don’t know what arg you’re getting anymore. I believe cursive just greys out the unused locals, I feel that’s the best solution for this as it’s communicating the info without the need to touch the code. Would love that in emacs as well.
You just turn off 'unused binding' everywhere?
You don't like adding an _ prefix? _baz? Then you still get the name, but with no warning.
+1 to adding a leading underscore
no, because then I need to touch two places when I want to use it again
and in cljc code with reader conditionals it gets even more silly I think, then you start introducing reader conditionals if you’re only using it in one branch
I like my linter to warn me about things that are likely to be an actual problem when running the code and unused bindings don’t cross that threshold for me
leading underscore seems a lot better than replacing the whole name with underscore, but still not ideal.
I'm not super excited to turn off 'unused binding' because I think it's really helpful when refactoring - finding out a function doesn't use an input anymore is great.
greying out the name would be ideal I think
guess it’s not too different from the reference count
> no, because then I need to touch two places when I want to use it again
No, you can rename via lsp and you do it once
I'm totally into prefixing with _
and you can quickly do lsp-rename add _ and done
👍