JSHint & BBEdit

BBEdit’s bbresults utility makes it easy to pipe output from shell commands into an easy-to-navigate results/search window.

JavaScript developers who still write their code in BBEdit (as opposed to Sublime, Atom, Textmate, Visual Studio Code or whatever the text editor du jour is) will find the following AppleScript invaluable:

    tell application "BBEdit"
        set mydoc to file of (document 1 of window 1)
    end tell
    set posixPath to POSIX path of mydoc
    if (posixPath ends with ".js" or posixPath ends with ".json") then
        set cmd to "/usr/local/bin/node /usr/local/bin/jshint " & (quoted form of POSIX path of mydoc) & " | /usr/local/bin/bbresults -e --pattern '(?P<file>.+?):\\sline\\s(?P<line>\\d+),\\scol\\s((?P<col>\\d+),)?\\s+(?P<msg>.*)$'"
        do shell script cmd
    end if
on error
end try

Save the script in ~/Library/Application Support/BBEdit/Scripts (and you’ll probably want to assign a keyboard shortcut via the Scripts palette, too).