Skip to content

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Oct 17:36
· 206 commits to main since this release

shell-lsp 0.3.0 makes # shellcheck directives first-class in the editor,
describes every check, adds six native checks, parses more of what the
shells accept, and fixes a parser crash and two kinds of findings that
never reached files with Windows line endings or a byte order mark.

Highlights

  • Editing directives: completion inside # shellcheck comments for keys,
    every check code (typing 208 finds SC2086), optional check names, shells
    and source= paths; hover on a code shows its severity, summary, wiki or
    rules link and how many findings the directive silences here;
    source= paths are links and go-to-definition targets; directives are
    highlighted.

  • Every check described: all 473 checks carry a one-line summary, shown
    in hover and completion and listed with their severities and optional
    names in docs/checks.md.
    shell-lsp check --list-optional names the codes each optional check
    turns on.

  • New native checks
    (docs/rules.md):

    • SL2004 a trap set inside $(…) or a pipeline stage, which never
      reaches the script;
    • SL2005 an exit inside $(…) or a pipeline stage that only leaves
      the subshell while the script carries on;
    • SL2006 a mktemp file or directory nothing ever removes, with a fix
      that adds a cleanup trap;
    • SL2007 a function that pushdes without ever popding;
    • SL2008 a ${…} the shell accepts when reading the script but stops on
      with "bad substitution" when it runs it, such as ${};
    • SL2009 (optional, enable=unused-directives) disable= codes that
      silence nothing, with a safe fix that removes them.
  • More of the shells' grammar: associative-array keys such as [e/]=0
    and ${m[a.b]}, and expansions bash only rejects at run time, now parse
    instead of producing syntax errors; on a 2,579-script corpus the
    remaining parse errors are in a file bash rejects too.

  • Faster than 0.2.0 despite the new checks: about 6% less CPU and 8%
    less memory per keystroke on a 5,000-line script, 11% less CPU and 18%
    fewer system calls when diagnosing a whole workspace cold, and 8% less CPU
    for shell-lsp check.

Fixes

  • v=$(( x y )) and similar one-character typos inside arithmetic made
    the parser panic, losing every diagnostic for the document and crashing
    shell-lsp check (fixed upstream-ready as fork patch 0017).
  • Scripts saved with Windows line endings, which bash fails on with
    $'\r': command not found, now get SC1017, and a UTF-8 byte order mark
    that breaks the shebang gets SC1082, in the editor and from the command
    line; both were lost when the text was normalised before linting.
  • A document with classic Mac line endings no longer falls out of sync when
    an edit joins a lone carriage return and a line feed.
  • Typo hints after a syntax error on a very long line no longer scan the
    whole line: 1.7 s became 18 ms on a 1.7 MB line.
  • SC3012 names >= and <= as written in a [ ] test.
  • On Windows, stopping a Bats run, or the server exiting, now ends every
    process the suite started instead of only bash, by running each suite in
    a job object.

Install

Release binaries for Linux, macOS and Windows (amd64, arm64) with
SHA256SUMS are attached below. Alternatively
go install github.com/stubbedev/shell-lsp@v0.3.0 or
nix profile install github:stubbedev/shell-lsp. For VS Code, install the
Shell LSP extension, or shell-lsp-0.3.0.vsix below. Editor setup:
docs/editors.md.

Known limitations

  • .shellcheckrc files get no completion or hover, because editors do not
    send them to language servers.