mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
move JSHint testing to Gruntfile
This commit is contained in:
parent
5fe72b308c
commit
db737e75ff
14
Gruntfile.js
14
Gruntfile.js
@ -37,6 +37,18 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
files: ['package.json']
|
files: ['package.json']
|
||||||
},
|
},
|
||||||
|
jshint: {
|
||||||
|
all: [
|
||||||
|
'*.js',
|
||||||
|
'lib/**/*.js',
|
||||||
|
'plugins/**/*.js',
|
||||||
|
'templates/**/*.js'
|
||||||
|
],
|
||||||
|
options: {
|
||||||
|
ignores: ['templates/default/static/scripts/prettify/*'],
|
||||||
|
jshintrc: '.jshintrc'
|
||||||
|
}
|
||||||
|
},
|
||||||
shell: {
|
shell: {
|
||||||
'coverage': {
|
'coverage': {
|
||||||
command: './node_modules/.bin/istanbul cover <%= nodeBin %> -- -T',
|
command: './node_modules/.bin/istanbul cover <%= nodeBin %> -- -T',
|
||||||
@ -78,7 +90,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.registerTask('test-rhino', ['shell:test-rhino']);
|
grunt.registerTask('test-rhino', ['shell:test-rhino']);
|
||||||
grunt.registerTask('test-rhino-esprima', ['shell:test-rhino-esprima']);
|
grunt.registerTask('test-rhino-esprima', ['shell:test-rhino-esprima']);
|
||||||
grunt.registerTask('test-node', ['shell:test-node']);
|
grunt.registerTask('test-node', ['shell:test-node']);
|
||||||
grunt.registerTask('test', ['test-rhino', 'test-rhino-esprima', 'test-node']);
|
grunt.registerTask('test', ['test-rhino', 'test-rhino-esprima', 'test-node', 'jshint']);
|
||||||
|
|
||||||
grunt.registerTask('default', ['test']);
|
grunt.registerTask('default', ['test']);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,9 +30,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.2",
|
"grunt": "~0.4.2",
|
||||||
"grunt-bumpup": "~0.4.2",
|
"grunt-bumpup": "~0.4.2",
|
||||||
|
"grunt-contrib-jshint": "~0.8.0",
|
||||||
"grunt-shell": "~0.6.1",
|
"grunt-shell": "~0.6.1",
|
||||||
"istanbul": "~0.2.1",
|
"istanbul": "~0.2.1",
|
||||||
"jshint": "~2.3.0",
|
|
||||||
"load-grunt-tasks": "~0.2.1",
|
"load-grunt-tasks": "~0.2.1",
|
||||||
"tv4": "git+https://github.com/hegemonic/tv4.git#own-properties"
|
"tv4": "git+https://github.com/hegemonic/tv4.git#own-properties"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
/*global document */
|
||||||
(function() {
|
(function() {
|
||||||
var source = document.getElementsByClassName('prettyprint source linenums');
|
var source = document.getElementsByClassName('prettyprint source linenums');
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|||||||
@ -1,80 +0,0 @@
|
|||||||
/*global app: true, beforeEach: true, describe: true, env: true, expect: true, it: true */
|
|
||||||
var async = require('async');
|
|
||||||
var fs = require('jsdoc/fs');
|
|
||||||
var path = require('jsdoc/path');
|
|
||||||
|
|
||||||
var config = JSON.parse( fs.readFileSync( path.join(env.dirname, '.jshintrc'), 'utf8' ) );
|
|
||||||
|
|
||||||
var jsHintCheck;
|
|
||||||
|
|
||||||
describe('jshint-clean', function() {
|
|
||||||
// Only run JSHint on Node.js, because a) we only need to lint everything once and b) the
|
|
||||||
// current version of JSHint is really slow on Rhino
|
|
||||||
if ( !require('jsdoc/util/runtime').isNode() ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jsHintCheck = function(filename, callback) {
|
|
||||||
var JSHINT = require('jshint').JSHINT;
|
|
||||||
var jsHintErrors;
|
|
||||||
|
|
||||||
fs.readFile(filename, 'utf8', function(err, data) {
|
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
} else {
|
|
||||||
JSHINT(data, config);
|
|
||||||
if (JSHINT.errors.length) {
|
|
||||||
jsHintErrors = filename + ' is not JSHint clean: ' + JSON.stringify(JSHINT.errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(null, jsHintErrors);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should generate JSHint errors for bad code', function(done) {
|
|
||||||
var file = path.join(env.dirname, 'test', 'fixtures', 'jshint', 'badfile.js');
|
|
||||||
|
|
||||||
jsHintCheck(file, function(err, jsHintErrors) {
|
|
||||||
expect(err).toBeFalsy();
|
|
||||||
expect(jsHintErrors).toBeDefined();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not generate JSHint errors for good code', function(done) {
|
|
||||||
var file = path.join(env.dirname, 'test', 'fixtures', 'jshint', 'goodfile.js');
|
|
||||||
|
|
||||||
jsHintCheck(file, function(err, jsHintErrors) {
|
|
||||||
expect(err).toBeFalsy();
|
|
||||||
expect(jsHintErrors).toBeUndefined();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not find JSHint errors in JSDoc', function(done) {
|
|
||||||
var files,
|
|
||||||
filter,
|
|
||||||
source;
|
|
||||||
|
|
||||||
// check all .js files unless they're tests; rhino shim files that probably can't be
|
|
||||||
// delinted; or third-party modules
|
|
||||||
source = {
|
|
||||||
includePattern: '.+[\\|/]lib[\\|/].+\\.js$|.+[\\|/]plugins[\\|/]\\w+\\.js$',
|
|
||||||
excludePattern: '.+[\\|/]test[\\|/].+|.+[\\|/]node_modules[\\|/].+|.+[\\|/]Jake[\\|/].+'
|
|
||||||
};
|
|
||||||
filter = new (require('jsdoc/src/filter').Filter)(source);
|
|
||||||
|
|
||||||
files = app.jsdoc.scanner.scan([env.dirname], 10, filter);
|
|
||||||
|
|
||||||
async.forEach(files, function(file, cb) {
|
|
||||||
jsHintCheck(file, function(err, jsHintErrors) {
|
|
||||||
expect(jsHintErrors).toBeUndefined();
|
|
||||||
cb(err);
|
|
||||||
});
|
|
||||||
}, function(err) {
|
|
||||||
expect(err).toBeFalsy();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
x
Reference in New Issue
Block a user