Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JetBrains Webstorm Integration #360

Closed
gdbtek opened this issue Apr 24, 2015 · 9 comments
Closed

JetBrains Webstorm Integration #360

gdbtek opened this issue Apr 24, 2015 · 9 comments

Comments

@gdbtek
Copy link

gdbtek commented Apr 24, 2015

I really do love this tool and I'm wondering if you have a thought to make this tool available as plugin in https://www.jetbrains.com/ IDEs?

Thanks

@gdbtek gdbtek changed the title Webstorm integration JetBrains Webstorm Integration Apr 24, 2015
@koalaman
Copy link
Owner

There's probably already a CheckStyle plugin for these, in which case you can use it with shellcheck's CheckStyle compatible xml output.

@gdbtek
Copy link
Author

gdbtek commented Apr 24, 2015

@koalaman , I could not find any plugins for WebStorm that can validate source code as good as shellcheck, not even close. The only plugin available for bash in WebStorm is: http://plugins.jetbrains.com/plugin/?id=4230

@koalaman
Copy link
Owner

I meant that the plugin wouldn't have to support bash at all. You can use a plugin that only supports validating for example C or Java code.

This works because shellcheck can mimic some of the underlying tools these plugins use:

$ gcc file.c
file.c:2:3: error: ‘foo’ undeclared (first use in this function)

$ clang file.c
file.c:2:3: error: use of undeclared identifier 'foo'; did you mean 'for'?

$ shellcheck -f gcc file.sh
file.sh:2:3: error: Double quote array expansions. [SC2068]

Since all these error messages have the same format, any plugin that supports showing errors from gcc or clang for C code also supports showing errors from ShellCheck, even if they were never intended to support shell scripts.

Similarly, ShellCheck can output CheckStyle XML, which your site lists an IDEA plugin for (but not a WebStorms plugin).

I don't have access to WebStorms so I can't test or suggest which plugins work well this way. However, it works fine in other editors that nominally only supports gcc, like Vim.

@WindomZ
Copy link

WindomZ commented Jul 1, 2017

I have a usage in WebStorms.

Go to File | Settings | Tools | External Tools for Windows and Linux, or WebStorm | Preferences | Tools | External Tools for OS X, and click + to add a new tool.

  • Name set Shellcheck
  • Program set shellcheck
  • Parameters set $FilePathRelativeToProjectRoot$
  • Working directory set $ProjectFileDir$

screenshot from 2017-07-02 02-07-26

If you add hotkey for it.
Go to File | Settings | Keymap for Windows and Linux, WebStorm | Preferences | Keymap for OS X, and type external tool name in search box.

This usage also applies to other JetBrains series(IntelliJ IDEA, PyCharm,PhpStorm, etc.).

@ghost
Copy link

ghost commented Jul 6, 2017

@WindomZ thanks for this post, I have set up clang-format in a similar fashion.

This is a generic way to proceed when there's a binary available, but no inline linter.

@christopher-hopper
Copy link

You can also use the method above by @WindomZ in conjunction with output filters, so that errors are hyperlinked to the file, line and column.

Settings | Tools | External Tools

  • Program: shellcheck
  • Parameters: -f gcc $FilePath$
  • Working directory: $ProjectFileDir$

Output Filters...

  • Name: gcc
  • Description: The gcc output format.
  • Regular expression to match output: $FILE_PATH$:$LINE$:$COLUMN$

screen shot 2017-08-31 at 4 00 51 pm

@hubertgrzeskowiak
Copy link

Hello fellow Googler. Here's what you came for:

Step 1

Set up external command. Important thing is that the working dir is the root of your system (or your harddrive letter on Windows).
Step 1

Step 2

Set output filter. It only matches the file name with full path, which is why we run shellcheck in the root dir.
Step 2

Step 3

Optionally set up hooks or key bindings.
Step 3

Profit

Sample result:
Profit

@singalen
Copy link

There is a plugin now: https://github.com/pwielgolaski/shellcheck-plugin/

@koalaman
Copy link
Owner

I've linked to this thread from https://github.com/koalaman/shellcheck/wiki/Contrib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants