Closed Gerschtli closed 2 years ago
Splices evaluate to strings anyway, and should be quoted for uniformity IMO.
I know there are some edge cases right now (if the splice evaluates to null, this suggestion actually results in invalid nix code; interaction between quoted splices and paths may be affected). There are some bugs with parsing certain cases in the underlying library (rnix-parser) as well.
If you find that this rule results in too many false positives, or if suggestions result in too many syntax errors, please feel free to report here!
I am still not sure how quoting slices would help in readability, correctness and/or maintainability..
Is it possible to disable? I also find this not very useful
There was actually a pr in nixpkgs that removed quotes this: https://github.com/NixOS/nixpkgs/pull/68339 (that was not the only thing that pr did)
Hmm interesting, I did see a couple of PRs that added quotes. It looks like adding quotes to unquoted splices was also on the nix-linter roadmap as well:
Check for unquoted splices, e.g.
foo = bar.${baz};
, since leaving off quotes is just horrible ;)
Anyhow, if folks generally dislike this lint, I think it would be better as opt-in. There is no way to disable lints right now, a configuration file or similar is definitely on the roadmap.
As a side, do you think it would be worth adding a lint that removes quotes from splices that don't require it?
I think that's a good idea. Maybe a configuration option like
string-interpolation-quotation = "quoted" | "unquoted" | "unchanged"
This lint has been removed on master
, changes will be reflected in the next release. The fix suggested by this lint breaks a bunch of valid nix 2.4 syntax.
This lint has been removed altogether.
Very cool project! I tried it out and wondered why are unquoted splices an anti-pattern?
Thank you very much :)