Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbose to options #274

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"devDependencies": {
"grunt": "^1.0.0",
"grunt-contrib-internal": "^1.2.3",
"grunt-contrib-nodeunit": "^1.0.0"
"grunt-contrib-nodeunit": "^1.0.0",
"jshint-stylish": "^2.2.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be added.

},
"peerDependencies": {
"grunt": ">=0.4.0"
Expand Down
8 changes: 6 additions & 2 deletions tasks/lib/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ exports.init = function(grunt) {
// Run JSHint on the given files with the given options
exports.lint = function(files, options, done) {
var cliOptions = {
verbose: grunt.option('verbose'),
verbose: grunt.option('verbose') || !!options.verbose,
extensions: ''
};

Expand Down Expand Up @@ -189,7 +189,11 @@ exports.init = function(grunt) {
}
}
// pass all of the remaining options directly to jshint
cliOptions.config = options;
var extend = require('util')._extend;
cliOptions.config = extend({},options);
//options is passed to the reporter hence we need to leave verbose on options
//but verbose is an in valid option for jshint, therefore remove it from config.
delete cliOptions.config.verbose;
}

// Run JSHint on all file and collect results/data
Expand Down
32 changes: 32 additions & 0 deletions test/jshint_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,38 @@ exports.jshint = {
test.done();
});
},
alternateReporterVerboseTrue: function(test) {
test.expect(2);
var files = [path.join(fixtures, 'nodemodule.js')];
var options = {
reporter: require('jshint-stylish'),
verbose: true
};
stdoutEqual(function() {
jshint.lint(files, options, function() {});
}, function(result) {
var reg = /line.*\((W\d*)\)/g;
test.ok(jshint.usingGruntReporter === false, 'Should NOT be using the default grunt reporter.');
test.ok(reg.test(result) === true, 'Should have reported errors with with verbose option');
test.done();
});
},
alternateReporterVerboseFalse: function(test) {
test.expect(2);
var files = [path.join(fixtures, 'nodemodule.js')];
var options = {
reporter: require('jshint-stylish'),
verbose: false
};
stdoutEqual(function() {
jshint.lint(files, options, function() {});
}, function(result) {
var reg = /line.*\((W\d*)\)/g;
test.ok(jshint.usingGruntReporter === false, 'Should NOT be using the default grunt reporter.');
test.ok(reg.test(result) === false, 'Should have reported errors with without verbose option');
test.done();
});
},
reporterOutput: function(test) {
test.expect(1);
var result = grunt.file.read(path.join('tmp', 'report.xml'));
Expand Down