Goal: to flex the execution of jshint to output results to the console (if in development) or to a file (if being released/in Jenkins).
Is it possible? I can add individual targets to my jshint settings, but all of my options are the same except for the reporter details. So it'd be nice to not duplicate those. I need to do the concatenation from "all" and use all of the global options and the specific options from the target that is called. How?
jshint.js:
module.exports = {
options: {
node: true,
browser: true,
blah: blah...
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/modules/**/*.js',
'<%= yeoman.app %>/*.js'
],
dev: {
options: {
reporter: 'checkstyle'
}
}
release: {
options: {
reporter: 'checkstyle',
reporterOutput: 'myfile.xml'
}
}
};
I ended up going the variable route but using that for the files source and then overriding the necessary options in the targets.
var files = [
'Gruntfile.js',
'<%= yeoman.app %>/modules/**/*.js',
'<%= yeoman.app %>/*.js'
];
module.exports = {
options: {
reporter: require('jshint-stylish'),
node: true, ...
},
dev: {
src: files
},
release: {
src: files,
options: {
reporter: 'checkstyle',
reporterOutput: 'myfile.xml',
reporterOutputRelative: false
}
}
}
Based on other things I had read, I didn't think the default options would work in the targets and allow overriding, and I also had encountered problems with the files, but this solved everything.