Allow unused config/lib/pkgs without warning
Is your feature request related to a problem? Please describe.
In NixOS modules, it is common to start every file with { config, lib, pkgs, ... }: even if they are not used. Nixd creates a warning for unused arguments in this case.
Describe the solution you'd like
Provide an option to ignore unused arguments by name, so "standard" arguments like config, lib and pkgs can be ignored without fully disabling the unused arguments lint.
Describe alternatives you've considered I could disable unused arguments warning, or simply not care about the warning..
Perhaps this could also be restricted to the beginning of the file, not sure about that though.
Why not just remove unused things?
For example it is allowed & safe to do:
{ config, ... }:
Yes, that's also a possibility. My argument against that approach is this:
- Removing the unused arguments IMO does not improve readability at all
- Keeping them is more economic when modifying the file later. If the arguments are reduced to the minimal form, I need to check each time I modify the file if the arguments I am using are declared.
So for me, removing them has no benefit but some disadvantages.
But I am open to a discussion about this. Perhaps this feature would complicate nixd too much for a marginal improvement?
does not improve readability
Readability is difficult to quantify objectively. However, determining whether something is unused is straightforward: name is unused iff name.users().length() == 0.
If the arguments are reduced to the minimal form, I need to check each time I modify the file if the arguments I am using are declared.
A better solution might be to implement a code action that automatically adds a name to the top-level lambda when needed. This is feasible for LSP servers.
Perhaps this feature would complicate nixd too much
Yes, I generally prefer to avoid adding any special rules altogether—nothing should be treated as exceptional. Special cases aren't special enough to break the rules.
@bennofs May I close this issue?
Yes feel free to