Code Monkey home page Code Monkey logo

vscode-shellcheck's Introduction

ShellCheck for Visual Studio Code

Integrates ShellCheck into VS Code, a linter for Shell scripts.

ci Current Version Install Count

Quick start

Extension GIF

Disclaimer

vscode-shellcheck (this "extension"), requires shellcheck (the awesome static analysis tool for shell scripts) to work.

Since v0.10.0, precompiled shellcheck binaries are bundled for these platforms:

  • Linux (x86_64)
  • macOS (x86_64)
  • Windows: precompiled 32bit binary will be used on both 32bit and 64bit Windows, please note that this requires you have WoW64 enabled, although it's not a problem for Desktop users.

Requirements

  1. Run Install Extension command from Command Palette.
  2. Search and choose shellcheck.

Options

There are various options that can be configured by making changes to your user or workspace preferences.

Default options are:

{
  "shellcheck.enable": true,
  "shellcheck.enableQuickFix": true,
  "shellcheck.run": "onType",
  "shellcheck.executablePath": "", // Priority: user defined > bundled shellcheck binary > "shellcheck"
  "shellcheck.exclude": [],
  "shellcheck.customArgs": [],
  "shellcheck.ignorePatterns": {
    "**/*.xonshrc": true,
    "**/*.xsh": true,
    "**/*.zsh": true,
    "**/*.zshrc": true,
    "**/zshrc": true,
    "**/*.zprofile": true,
    "**/zprofile": true,
    "**/*.zlogin": true,
    "**/zlogin": true,
    "**/*.zlogout": true,
    "**/zlogout": true,
    "**/*.zshenv": true,
    "**/zshenv": true,
    "**/*.zsh-theme": true
  },
  "shellcheck.ignoreFileSchemes": ["git", "gitfs"]
}

shellcheck.ignorePatterns

The shellcheck.ignorePatterns works exactly the same as search.exclude, read more about glob patterns here

For example:

{
  "shellcheck.ignorePatterns": {
    "**/*.zsh": true,
    "**/*.zsh*": true,
    "**/.git/*.sh": true,
    "**/folder/**/*.sh": true
  }
}

Fix all errors on save

The auto-fixable errors can be fixed automatically on save by using the following configuration:

{
  "editor.codeActionsOnSave": {
    "source.fixAll.shellcheck": true
  }
}

Alternatively, you can fix all errors on demand by running the command Fix All in the VS Code Command Palette.

Lint onType or onSave

By default the linter will lint as you type. Alternatively, set shellcheck.run to onSave if you want to lint only when the file is saved (works best if auto-save is on).

{
  "shellcheck.run": "onType" // also: "onSave"
}

Excluding Checks

By default all shellcheck checks are performed and reported on as necessary. To globally ignore certain checks in all files, add the "SC identifiers" to shellcheck.exclude. For example, to exclude SC1017:

{
  "shellcheck.exclude": ["1017"]
}

Using Docker version of shellcheck

In order to get it work, you need a "shim" script, and then, just remember, do not try to construct command line arguments for shellcheck yourself.

Here is a simple "shim" script to get start with (See discussion: #24):

#!/bin/bash

exec docker run --rm -i -v "$PWD:/mnt:ro" koalaman/shellcheck:v0.7.0 "$@"

Acknowledgements

This extension is based on @hoovercj's Haskell Linter.

Contributors

LICENSE

This extension is licensed under the MIT license.

Bundled shellcheck binaries are licensed under GPLv3.

vscode-shellcheck's People

Contributors

bmalehorn avatar dependabot[bot] avatar felipecrs avatar greenkeeper[bot] avatar jblaine avatar meramsey avatar ralish avatar semantic-release-bot avatar sylveon avatar timonwong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.