JSLint plugin for anvil.js
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
src
.gitignore
README.md
header.js
package.json

README.md

Anvil JSLint Plugin

This plugin requires anvil.js version 0.8.* or greater.

Installation

	anvil install anvil.jslint

Usage

After you have installed the plugin you first need to reference the plugin inside the dependencies key of your build.json.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		// Required settings here...
	}
}

Then you will need to choose one of the following senarios in order for the plugin to know which files to lint.

  • Linting all your files
  • Linting Specifc Files
  • Linting All Files Except

Settings

Linting all your files

Let's say that you had 5 JavaScript files in your src folder and you wanted all of them to be linted when you build your project. The following "all": true setting will tell anvil.jslint that you want everything to be linted.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"all": true
	}
}

Linting Specific Files

If you had 5 JavaScript files in your src folder and you only wanted a specific subset of those to be linted, then you could use the include setting and provide a list of files you want to include in the linting process.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"include": [ "main.js" ]
	}
}

Linting All Files Except

If you had 5 JavaScript files in your src folder and you wanted most of them to be linted, but to ignore a couple of items, then you could use the exclude setting and provide a list of files you want to exclude in the linting process.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"exclude": [ "util.js" ]
	}
}

Breaking Build Option

By default if there are any errors that JSLint returns then the build process will be aborted. You can override this option by providing setting the breakBuild to false.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"all": true,
		"breakBuild": false
	}
}

Ignore Specific Errors

Sometimes there are JSLint errors that for one reason or another you want ignored by the build process. To do that you can provide an ignoreList option with a list of all the errors that you feel are acceptable for your project. You list the line, character, and reason (contains) of each error you'd like to ignore. You can provide a combination of these options for more or less flexibility.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"all": true,
		"ignoreList": [
			{ "line": 81, "character": 26, "reason": "'someVariable' is already defined." },
			... other options ...
		]
	}
}

The following option ignores reason for line 81 and character 26

{ "line": 81, "character": 26, "reason": "'someVariable' is already defined." }

The following option ignores any error on line 81 and character 12

{ "line": 81, "character": 12 }

The following option ignores reason anywhere on line 81

{ "line": 81, "reason": "'someVariable' is already defined." }

The following option ignores any errors on line 81

{ "line": 81 }

The following option ignores any errors matching reason anywhere in the file

{ "reason": "literal notation" }

JSLint Settings

You can always provide custom JSLint and global comments to the top of each of your JavaScript file to tweak it's lint settings, but that can be redundant and a nuisance. So, you can provide these common settings in your 'anvil.jshint' settings to be used during the linting process.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jslint" ],
	"anvil.jslint": {
		"all": true,
		"options": {
			"predef": {
				"console": false,
			},
			"white": true
		}
	}
}

Uninstallation

	anvil uninstall anvil.jslint

l