Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0286317db3
Fetching contributors…

Cannot retrieve contributors at this time

file 155 lines (108 sloc) 3.845 kb

Autolint

Autolint watches your files for jslint-errors. DRY up your js-files, freeing them of all those linting config comments. Gather all your linting preferences in one place per project.

Changes from 0.1.5 to 1.0.0

Autolint now uses semantic versioning.

  • The configuration file is no longer a json-file, but a proper node module. Add module.exports = to the start of the file and rename to autolint.js to upgrade.
  • Autolint no longer runs without a config file. Running it without one will prompt you for a default config file to be created.
  • Passing --once to autolint makes it not-so-auto. Instead it is run once, exiting with a -1 error code if any lint is found. This makes it well suited for pre-commit-hooks and the like.
  • Updated bundled versions of jslint and jshint - these have been significantly changed since last, so your configuration file will certainly need an upgrade too.

Installation

Make sure you've got node.js and npm, then:

npm install autolint -g

Basic usage

Create a default configuration file by running:

autolint

Tweak the config to your liking, then start linting with:

autolint

Once running, you can see all errors in all files by pressing ctrl-c in the terminal window. To see errors in a single file, update its mtime by saving or touching it.

You can also skip the watching-part, and just lint the entire project once:

autolint --once

Configuration

Look at the default configuration lib/default-configuration.js then override specific items in autolint.js. autolint always looks for this file in the current directory.

Example:

module.exports = {
  paths: [
    "lib/**/*.js",
    "test/**/*.js"
  ],
  linterOptions: {
    node: true
  }
};

Excluding files

You can also tell autolint to skip linting some files, like so:

module.exports = {
  excludes: [
    "jquery",
    "underscore",
    "sinon",
    "raphael"
  ]
};

Any files (or paths) containing those words will not be linted, or counted towards your error total.

Growl

If you want autolint to notify you when new lint errors are introduced, you can download Growl here.

Make sure you also install the growlnotify in the Extras-folder.

Using JSHint

If JSLint is hurting your feelings, you can easily switch to JSHint by adding this to your configuration:

module.exports = {
  "linter": "jshint"
};

Contribute

If you want to help out with features or bug fixes, that's awesome. Check out todo.md for inspiration.

  • Fork the project.
  • Make your feature addition or bug fix.
  • Don't forget tests. This is important so I don't break it in a future version unintentionally.
  • Commit and send me a merge request.

Setting up development environment

Check out the source code from your fork:

git clone <url to your fork>
cd autolint

Fetch the dependencies with npm:

npm install

Install buster.js if you haven't already:

npm install buster -g

Then link buster in:

npm link buster

Run the tests to make sure everything works:

buster test

Install watchr to run the tests automatically:

gem install watchr

Then start the autotest with:

watchr autotest.watchr

If watchr can't be interrupted with 2x ctrl-c, switch to ruby ~1.9

Also make sure you follow the linting rules with:

autolint

of course. ^^

License

See LICENSE file.

Something went wrong with that request. Please try again.