Permalink
Browse files

Implement JS file linting. See `.jshintrc` for JSHint config.

Run with `npm test` or `grunt` or `grunt jshint` or `grunt jshint:<sub_task>`.
  • Loading branch information...
1 parent aa6c5da commit 332799f7fe674453a07b0a4f3780862838b2760a @0xazure 0xazure committed Oct 13, 2014
Showing with 68 additions and 1 deletion.
  1. +28 −0 .jshintrc
  2. +35 −1 Gruntfile.js
  3. +5 −0 package.json
View
@@ -0,0 +1,28 @@
+{
+ "forin" : false,
+ "quotmark" : false,
+ "laxcomma" : true,
+ "sub" : true,
+ "browser" : true,
+ "devel" : true,
+ "jquery" : true,
+ "nonstandard" : true,
+ "-W002" : true,
+ "-W009" : true,
+ "-W010" : true,
+ "globals": {
+ "jQuery" : true,
+ "$" : true,
+ "XKit" : true,
+ "Tumblr" : true,
+ "GM_flushStorage" : true,
+ "GM_deleteAllValues" : true,
+ "GM_getValue" : true,
+ "GM_deleteValue" : true,
+ "GM_setValue" : true,
+ "GM_log" : true,
+ "GM_openInTab" : true,
+ "GM_listValues" : true,
+ "GM_xmlhttpRequest" : true
+ }
+}
View
@@ -36,6 +36,7 @@ module.exports = function(grunt) {
browserList = parseBuildBrowsers(browsers);
browserList.forEach( function(browser) {
+ gruntTaskList.push('jshint:' + browser);
gruntTaskList.push('copy:' + browser);
if(/firefox/.test(browser)) {
gruntTaskList.push('compress:firefox');
@@ -65,6 +66,37 @@ module.exports = function(grunt) {
modules: ['node_modules'],
},
+ // grunt-contrib-jshint task
+ jshint: {
+ options: {
+ jshintrc: ".jshintrc",
+ },
+ gruntfile: {
+ src: 'Gruntfile.js',
+ },
+ extensions: {
+ src: [
+ 'Extensions/**/*.js',
+ '!Extensions/**/*.icon.js',
+ ],
+ },
+ chrome: {
+ src: [
+ 'Chrome/**/*.js',
+ ],
+ },
+ firefox: {
+ src: [
+ 'Firefox/**/*.js',
+ ],
+ },
+ safari: {
+ src: [
+ 'Safari/**/*.js',
+ ],
+ },
+ },
+
// grunt-contrib-copy task
copy: {
chrome: {
@@ -107,9 +139,11 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+
// Default task
- grunt.registerTask('default', ['build']);
+ grunt.registerTask('default', ['jshint']);
// Browser extension build task
grunt.registerTask('build', function(browsers) {
View
@@ -28,11 +28,16 @@
"interface",
"tweaks"
],
+ "scripts": {
+ "test": "grunt jshint"
+ },
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compress": "^0.12.0",
"grunt-contrib-copy": "^0.6.0",
+ "grunt-contrib-jshint": "~0.10.0",
+ "grunt-contrib-watch": "~0.6.1",
"underscore": "^1.7.0"
}
}

0 comments on commit 332799f

Please sign in to comment.