The best way to run the JSHint JavaScript validator in TextMate 2.
Want to use ESLint instead? Try the javascript-eslint.tmbundle.
- Validate automatically when you save your file, and on-demand.
- Intelligently uses
.jshintrc
settings, whether stored in the same directory tree as your source file, in your home directory, or referenced from apackage.json
file. - Uses a separately-installed copy of
jshint
.- Does not include a bundled (possibly outdated) copy of JSHint.
- Fewer dependency problems.
- Common error codes include a link to the relevant explanation on jslinterrors.com.
If you don’t have JSHint, install it:
- Install Node.js.
[sudo] npm install -g jshint
Now install the bundle:
- Download the latest release .zip file.
- Extract it and double-click to install.
View the release notes.
In most cases no configuration is required. However, in some cases you may want to customize the following:
- Use
jshint
that is not on yourPATH
: Ifjshint
is not on yourPATH
, set theTM_JSHINT_EXTERNAL_JSHINT
variable to point to it. Set in TextMate > Preferences… > Variables. - Don’t validate on save: If you don’t want to validate your JavaScript automatically when you press
⌘S
:- Open the Bundle Editor (Bundles > Edit Bundles…).
- Navigate to JSHint (External) > Menu Actions > Save & Validate with JSHint.
- In the drawer that appears, delete the “Key Equivalent” of
⌘S
.
- Use a project-specific JSHint configuration:
- For Node.js: Add a key called
jsonHintConfig
to thepackage.json
file. This key should contain the filename of your JSHint configuration file (JSHint config syntax). - For any JavaScript project: Create a
.jshintrc
file (syntax). Place it in your source directory or any directory above it.
- For Node.js: Add a key called
- Quit TextMate.
- Open
~/Library/Application Support/Avian/Pristine Copy/Bundles
. - Trash
jshint-external.tmbundle
. - Open
~/Library/Application Support/Avian/Bundles
. - If there is a file called
JavaScript JSHint (External).tmbundle
, trash it. - You may need to clear TextMate’s cache by trashing
~/Library/Caches/com.macromates.TextMate.preview
.