Skip to content

Commit

Permalink
Added support for exclusions. Corrected/improved documentation. Fixed…
Browse files Browse the repository at this point in the history
… output for number of errors.
  • Loading branch information
arthurakay committed Jun 6, 2012
1 parent 091ad4d commit 1d00986
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 25 additions & 2 deletions PhantomLint.js
Expand Up @@ -25,6 +25,11 @@ PhantomLint = {
*/
files : [],

/**
* @property
*/
exclusions : null,

/**
* @property
*/
Expand Down Expand Up @@ -66,7 +71,8 @@ PhantomLint = {
/**
* @method
* @param {object} config
* @cfg {string} filepaths An array of relative filepaths to the folders containing JS files
* @cfg {array} filepaths An array of relative filepaths to the folders containing JS files
* @cfg {array} exclusions An array of relative filepaths to the folders containing JS files that should NOT be linted
* @cfg {object} lintOptions A configuration object to add/override the default options for JS Lint
* @cfg {boolean} verbose false to hide verbose output in your terminal (defaults to true)
* @cfg {string} jsLint A relative filepath to the local JSLint file to use (defaults to ./assets/jslint.js)
Expand All @@ -81,6 +87,7 @@ PhantomLint = {
if (config.stopOnFirstError !== undefined) { this.stopOnFirstError = config.stopOnFirstError; }
if (config.jsLint !== undefined) { this.jsLint = config.jsLint; }
if (config.logFile !== undefined) { this.logFile = config.logFile; }
if (config.exclusions !== undefined) { this.exclusions = config.exclusions; }

this.log('JSLint? ' + phantom.injectJs(this.jsLint), true);
if (!JSLINT) { phantom.exit(1); }
Expand Down Expand Up @@ -147,6 +154,22 @@ PhantomLint = {
var currPath = path[i];
this.log('*** currPath: ' + currPath);

if (this.exclusions) {
this.log('Checking exclusion paths...');

var j = 0;
var exclude = false;

for (j; j < this.exclusions.length; j++) {
if (currPath === this.exclusions[j]) { exclude = true; }
}

if (exclude) {
this.log('Excluding path: ' + currPath);
continue;
}
}

var list = this.getFiles(currPath);
var x = 0;

Expand Down Expand Up @@ -240,7 +263,7 @@ PhantomLint = {
*
*/
logToFile : function(errorList) {
this.log('\nWriting ' + errorList.length + ' errors to log file.', true);
this.log('\nWriting ' + (errorList.length / 6) + ' errors to log file.', true);
filesystem.touch(this.logFile);

var stream = filesystem.open(this.logFile, 'w');
Expand Down
6 changes: 5 additions & 1 deletion README
Expand Up @@ -4,7 +4,10 @@ An example shell script (test.sh) is provided.

CONFIG OPTIONS:
- filepaths (Array)
An array of relative filepaths to the directories containing JS files
REQUIRED. An array of relative filepaths to the directories containing JS files

- exclusions (Array)
An array of relative filepaths to the directories containing JS files that should be ignored

- jsLint (String)
A relative filepath to the local JSLint file to use
Expand All @@ -21,6 +24,7 @@ CONFIG OPTIONS:

- logFile (String)
A relative filepath to where the output error log should go.
(defaults to ./error_log.txt)


NOTES:
Expand Down

0 comments on commit 1d00986

Please sign in to comment.