Giter Site home page Giter Site logo

anvil.jshint's Introduction

Anvil JSHint Plugin

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

Installation

	anvil install anvil.jshint

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.jshint" ],
	"anvil.jshint": {
		// 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.jshint that you want everything to be linted.

{
	"source": "src",
	"spec": "spec",
	"output": [ "build" ],
	"dependencies" : [ "anvil.jshint" ],
	"anvil.jshint": {
		"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.jshint" ],
	"anvil.jshint": {
		"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.jshint" ],
	"anvil.jshint": {
		"exclude": [ "util.js" ]
	}
}

Breaking Build Option

By default if there are any errors that JSHint 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.jshint" ],
	"anvil.jshint": {
		"all": true,
		"breakBuild": false
	}
}

Ignore Specific Errors

Sometimes there are JSHint errors that for one reason or another you want ignored by the build process. To do that you can provide an ignore 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.jshint" ],
	"anvil.jshint": {
		"all": true,
		"ignore": [
			{ "file": "bad.js", line": 81, "character": 26, "reason": "'someVariable' is already defined." },
			... other options ...
		]
	}
}

The following option ignores reason for line 81 and character 26 in bad.js

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

The following option ignores any error on line 81 and character 12 in bad.js

{ "file": "bad.js", "line": 81, "character": 12 }

The following option ignores reason anywhere on line 81 in bad.js

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

The following option ignores any errors on line 81 in bad.js

{ "file": "bad.js", "line": 81 }

The following option ignores any errors matching reason anywhere in bad.js

{ "file": "bad.js", "reason": "literal notation" }

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

{ "reason": "literal notation" }

JSHint Settings

You can always provide custom JSHint 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.jshint" ],
	"anvil.jshint": {
		"all": true,
		"options": {
			"globals": {
				"console": false,
			},
			"white": true
		}
	}
}

Uninstallation

anvil uninstall anvil.jshint

TODOS

  • .jshintrc in pwd then all way up, then $HOME
  • Get unit test coverage once Anvil.js allows assertion of logs
  • Make options/globals be on a per folder basis

anvil.jshint's People

Contributors

arobson avatar dcneiner avatar elijahmanor avatar eliperelman avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.