3 ms·
All this is solved by a linter though, there's no point even trying to remember this, just define your linter rules and let it deal with it. It might not be th
by eterm 11y ago
All this is solved by a linter though, there's no point even trying to remember this, just define your linter rules and let it deal with it.
It might not be the default linter styles, but set up your linter for your project and give your mind more important things to focus on.
- hire_charts 11y agoA linter is also a great way to jump start learning a new language. If you encounter a warning that doesn't make sense to you, look it up. You'll start to get familiar with common language pitfalls without actually getting burned by any of them.
- chriswarbo 11y agoI didn't know linters had become so advanced. Can you recommend any which work on DSLs (including custom ones), and warn about 2D alignment issues? For example, here's some Nix code I have open right now: annotateAsts = import ./annotateAsts.nix { inherit stdenv annotatedb; }; runTypes = import ./runTypes.nix { inherit stdenv annotatedb jq; }; dumpAndAnnotate = import ./dumpAndAnnotate.nix { inherit downloadAndDump; }; It would be nice to have a tool rate various equivalent arrangements and warn if it finds one with a significantly better score, e.g. showing me the above if I'd given it something more confusing like: annotateAsts = import ./annotateAsts.nix { inherit stdenv annotatedb; }; runTypes = import ./runTypes.nix { inherit stdenv annotatedb jq; }; dumpAndAnnotate = import ./dumpAndAnnotate.nix { inherit downloadAndDump; }; Of course, as well as formatting it would be nice for equivalent representations of the same expression to be compared, e.g. using an SMT solver or genetic programming. For example, in Nix the variable names after "inherit" can be in any order, so it's easy to find permutations which highlight common elements (like "stdenv" and "annotatedb" above); if I'd written these in a different order (e.g. "inherit jq annotatedb stdenv;" on line two), it would be nice to be shown rearrangements which score more highly. It's not just linters either. I can't even find an indenter which handles 2D alignment. For example, indenting something like (random bash code I have open at the moment): jq -n --argfile asts <(echo "$ASTS") \ --argfile cmd <(echo "$CMD" | jq -s -R '.') \ --argfile result <(echo "$RESULT" | jq -s -R '.') \ --argfile scopecmd <(echo "$SCOPECMD" | jq -s -R '.') \ --argfile scoperesult <(echo "$SCOPERESULT" | jq -s -R '.') \ '{asts: $asts, cmd: $cmd, result: $result, scopecmd: $scopecmd, scoperesult: $scoperesult}' Emacs wants to put the second '--argfile' directly beneath '-n', which is clearly confusing compared to the above. If linters solve all typography issues, are there any which can be queried for the local-optimal indentation on a line-by-line basis?