Quick, simple JSLint (or JSHint) in TextMate. Hurt your feelings in style. (See the `development` br...
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
Quick, simple JSLint and JSHint in TextMate. Hurt your feelings in style.
(CSS geeks: Only three images are used throughout the UI. The red, striped error uses only CSS.)
Download JSLintMate.tmbundle and double-click it. TextMate should install it for you automatically—that's all.
Or via Git:
To update to the latest version:
cd ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles git pull
Installation: While TextMate 2 is in development, installation is temporarily a bit more involved:
mkdir -p ~/Library/Application\ Support/Avian/Pristine\ Copy/Bundles/.
open ~/Library/Application\ Support/Avian/Pristine\ Copy/Bundles/.
Project setup: It's worth creating a
.tm_propertiesfile in your project directory containing this (source):
projectDirectory = "$CWD" TM_PROJECT_DIRECTORY = "$projectDirectory"
This lets you use
$TM_PROJECT_DIRECTORYin your JSLintMate settings, which is useful for pointing to project-specific JSLint/JSHint options and custom builds.
Display: In TextMate 2, JSLintMate runs in a panel in the main window, rather than in a separate window. To make TextMate 2 open JSLintMate in a separate window, run this in Terminal (source):
defaults write com.macromates.TextMate.preview htmlOutputPlacement window
JSLintMate has two modes:
Quick mode shows a tooltip with a preview of the problems (if any) whenever you hit command-S.
Full mode shows a full list of problems whenever you hit control-L (JSLint) or control-shift-L (JSHint).
While you're coding, hit command-S to save changes and automatically run the file through JSLint. If any problems are found, JSLintMate shows a few of them in a tooltip.
If you'd prefer to run JSHint on save:
jshint, then close the window to save changes.
If you don't want JSLintMate to do anything on save, open the Bundle Editor window again, and remove the keyboard shortcut for the Run JSLintMate and Save command.
To skip the tooltip and see the full list of problems, use full mode.
To see the full list of problems in a JS file, hit control-L to run it through JSLint, or control-shift-L to use JSHint. Click a problem to jump to that line in the file. Fix and repeat.
You can also navigate the list of problems with your keyboard: up/down/k/j to move up/down, and return to select.
If JSLint or JSHint are too strict or lenient for your taste, you can set options for each. These options serve as a barebones code style guide, and let teammates stick to the same standards. Three ways to do this:
Adding options atop each JS file gives you fine-grained control. For example:
/*jslint browser: true, newcap: true, nomen: false, plusplus: false, undef: false, vars: false, white: false */ /*global window, jQuery, $, MyApp */
This example is specifically for JSLint. To use it with JSHint, change
/*jshintand tweak options as needed.
You can maintain an options file to use your favorite JSLint/JSHint options across projects. These files can be written in JSON or YAML.
~/.jshintrc. JSLintMate reads from these paths by default, and automatically detects whether they contain JSON or YAML.
If you want to rename your options files or store them elsewhere:
TM_JSLINTMATE_JSHINT_OPTIONS_FILEto the file paths you prefer.
You can also store your options file in your project. This is great for sharing options with collaborators—everyone uses the same options for all JS files, and different projects can have different options.
To set this up:
TM_JSLINTMATE_JSLINT_OPTIONS_FILEto a path in your project, e.g.,
$TM_PROJECT_DIRECTORY/config/jslint.yml. Do the same for JSHint if needed, making sure to use a separate options file.
Options files are meant to be understood by a wide variety of tools, not just JSLintMate. This includes lint tools in other editors, continuous integration systems, and other automated testing systems.
Here's the old way to maintain personal, cross-project options. This feature will be removed in an upcoming version. Please use a
~/.jshintrcfile via the "Options Files" preferences instead. Bundle commands no longer need to be modified directly.
Add your list of options as
--linter-options. For example:
ruby "$TM_BUNDLE_SUPPORT/lib/jslintmate.rb" \ --linter-options=browser:true,white:false
TM_JSLINTMATE_JSHINT_OPTIONS_FILEsupport options file fallbacks. Change each setting to a colon-separated list of file paths, and JSLintMate will use the first readable file in each list.
$TM_PROJECT_DIRECTORY/config/jslint.json:~/.jslintrctells JSLintMate to first look for a project-specific options file (e.g., for options shared with a team). If this file is not readable, JSLintMate uses your personal options file as a fallback.
If you specify options in your JS files and in options files, they'll be merged at runtime:
/*jslint browser: true */
JSLintMate reports warnings from JSLint/JSHint about variables that are declared but not used. It's good to clean up code by removing unused variables, but if you'd rather not see these warnings:
To resume seeing warnings about unused variables, set this value back to
JSLintMate is packaged with copies of JSLint and JSHint, but you can use your own copies instead. This is useful for testing an edge build or using your own modified version.
If you store a copy of your linter in your project, point your bundle prefs at it:
TM_JSLINTMATE_JSLINT_FILEto point to your linter. This could be a path in your project (e.g.,
$TM_PROJECT_DIRECTORY/lib/jslint.js), a path in your home directory (e.g.,
~/lib/jslint.js), or anything else. If needed, do the same for JSHint, making sure to use a separate linter file.
This project is adapted from:
JSLintMate is released under the MIT License. The bundle contains copies of JSLint and JSHint, which use their own license(s). Use JSLintMate for good, not evil.