grunt-jslint
Advanced tools
Comparing version 1.1.1 to 1.1.2
# Release History | ||
## 1.1.2 | ||
- Removed dead code (see [#33](https://github.com/stephenmathieson/grunt-jslint/issues/33)) | ||
- Updated [JSLint to edition 2013-11-23](https://github.com/douglascrockford/JSLint/commit/bd6da6b0eb808cf9c2813d8952591898d8f580b6) | ||
## 1.1.1 | ||
@@ -4,0 +10,0 @@ |
'use strict'; | ||
var fs = require('fs'), | ||
vm = require('vm'), | ||
path = require('path'); | ||
var fs = require('fs'); | ||
var vm = require('vm'); | ||
var path = require('path'); | ||
@@ -18,5 +18,5 @@ // define public API | ||
var JSLINT = jslint.JSLINT = (function () { | ||
var file = path.join(__dirname, '..', 'jslint', 'jslint.js'), | ||
ctx = vm.createContext(), | ||
js = fs.readFileSync(file).toString(); | ||
var file = path.join(__dirname, '..', 'jslint', 'jslint.js'); | ||
var ctx = vm.createContext(); | ||
var js = fs.readFileSync(file).toString(); | ||
@@ -44,10 +44,10 @@ vm.runInContext(js, ctx); | ||
jslint.runner = function (files, opts, cb) { | ||
var pending = files.length, | ||
report = { | ||
files: {}, | ||
failures: 0, | ||
file_count: files.length, | ||
files_in_violation: 0 | ||
}, | ||
done = false; | ||
var pending = files.length; | ||
var report = { | ||
files: {}, | ||
failures: 0, | ||
file_count: files.length, | ||
files_in_violation: 0 | ||
}; | ||
var done = false; | ||
@@ -109,10 +109,5 @@ files.forEach(function (file) { | ||
var data = JSLINT.data(), | ||
violations = JSLINT.errors, | ||
res = []; | ||
var violations = JSLINT.errors; | ||
var res = []; | ||
if (!directives.unused) { | ||
violations.concat(data.unused); | ||
} | ||
violations.forEach(function (violation) { | ||
@@ -119,0 +114,0 @@ if (!violation) { |
'use strict'; | ||
var red = require('./util').color.red, | ||
standard = require('./standard'); | ||
var red = require('./util').color.red; | ||
var standard = require('./standard'); | ||
@@ -6,0 +6,0 @@ module.exports = function (report) { |
'use strict'; | ||
var util = require('./util'), | ||
path = require('path'); | ||
var util = require('./util'); | ||
var path = require('path'); | ||
@@ -14,11 +14,14 @@ module.exports = function (report) { | ||
Object.keys(report.files).forEach(function (file) { | ||
var parts = file.split(/[\\\/]/).filter(function (part) { return part; }), | ||
classname = parts.join('.').replace(/\.js$/i, '').replace(/-/g, '_'), | ||
filename = path.basename(file, '.js'), | ||
failures = report.files[file]; | ||
var parts = file.split(/[\\\/]/).filter(function (part) { return part; }); | ||
var classname = parts.join('.').replace(/\.js$/i, '').replace(/-/g, '_'); | ||
var filename = path.basename(file, '.js'); | ||
var failures = report.files[file]; | ||
if (failures.length) { | ||
failures.forEach(function (failure) { | ||
var name = filename + ':' + failure.line + | ||
':' + (failure.character || ''); | ||
var name = filename | ||
+ ':' | ||
+ failure.line | ||
+ ':' | ||
+ (failure.character || ''); | ||
@@ -25,0 +28,0 @@ xml.push([ |
'use strict'; | ||
var util = require('./util'), | ||
red = util.color.red; | ||
var util = require('./util'); | ||
var red = util.color.red; | ||
@@ -6,0 +6,0 @@ module.exports = function (report, errorsOnly) { |
{ | ||
"name": "grunt-jslint", | ||
"description": "Validates JavaScript files with JSLint", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"homepage": "https://github.com/stephenmathieson/grunt-jslint", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -33,39 +33,3 @@ # grunt-jslint | ||
### Moving to 1.x.0 | ||
grunt-jslint@1.x.0 has moved from a single-task to a multi-task, allowing you to specify different options for different groups of files. | ||
For simple migration, just wrap `all: { ... }` around your jslint configuration in your Gruntfile and replace `files:` with `src:`. | ||
For example: | ||
```js | ||
module.exports = function (grunt) { | ||
grunt.loadNpmTasks('grunt-jslint'); | ||
grunt.initConfig({ | ||
jslint: { | ||
files: [ ... ], | ||
options: { ... } | ||
} | ||
}); | ||
}; | ||
``` | ||
has become: | ||
```js | ||
module.exports = function (grunt) { | ||
grunt.loadNpmTasks('grunt-jslint'); | ||
grunt.initConfig({ | ||
jslint: { | ||
all: { | ||
src: [ ... ], | ||
options: { ... } | ||
} | ||
} | ||
}); | ||
}; | ||
``` | ||
## Example Usage | ||
@@ -72,0 +36,0 @@ |
@@ -11,4 +11,4 @@ /*! | ||
var jslint = require('..'), | ||
pkg = require('../package.json'); | ||
var jslint = require('..'); | ||
var pkg = require('../package.json'); | ||
@@ -23,4 +23,3 @@ /** | ||
grunt.registerMultiTask('jslint', 'Validate JavaScript files with JSLint', function () { | ||
var conf, | ||
next = this.async(); | ||
var next = this.async(); | ||
@@ -39,3 +38,3 @@ if (grunt.config('jslint.files') || grunt.config('jslint.options')) { | ||
conf = { | ||
var conf = { | ||
files: this.filesSrc, | ||
@@ -61,5 +60,5 @@ exclude: this.data.exclude || [], | ||
gruntJSLint.task = function (grunt, config, next) { | ||
var files = config.files, | ||
excludedFiles = config.exclude, | ||
options = config.options; | ||
var files = config.files; | ||
var excludedFiles = config.exclude; | ||
var options = config.options; | ||
@@ -66,0 +65,0 @@ if (!files || !files.length) { |
@@ -127,2 +127,3 @@ 'use strict'; | ||
}, | ||
'shebang option': { | ||
@@ -141,2 +142,22 @@ topic: function () { | ||
}, | ||
'unused option': { | ||
topic: function () { | ||
var file = path.join(__dirname, 'fixtures', 'unused.js'); | ||
validate(file, {}, this.callback); | ||
}, | ||
'should not error': function (err, report) { | ||
assert.ifError(err); | ||
}, | ||
'should report at least two violations': function (err, report) { | ||
assert(report.length >= 2); | ||
}, | ||
'should report on unused parameters': function (err, report) { | ||
assert.equal(report[0].reason, 'Unused \'c\'.'); | ||
}, | ||
'should report on unused vars': function (err, report) { | ||
assert.equal(report[1].reason, 'Unused \'b\'.'); | ||
} | ||
}, | ||
'missing file': { | ||
@@ -143,0 +164,0 @@ topic: function () { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
250690
38
5319
111