Issue #2008 - Add jshint
This commit is contained in:
		
							parent
							
								
									1a1c5abca6
								
							
						
					
					
						commit
						19dbeaa23e
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -4,3 +4,4 @@ build/
 | 
			
		||||
tags
 | 
			
		||||
.DS_Store
 | 
			
		||||
Makefile
 | 
			
		||||
node_modules/
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										19
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
{
 | 
			
		||||
  // Environments
 | 
			
		||||
  "browser": true,
 | 
			
		||||
  "devel": true,
 | 
			
		||||
  "es5": true,
 | 
			
		||||
  "worker": true,
 | 
			
		||||
 | 
			
		||||
  // Enforcing
 | 
			
		||||
 | 
			
		||||
  // Relaxing
 | 
			
		||||
  "boss": true,
 | 
			
		||||
  "funcscope": true,
 | 
			
		||||
  "globalstrict": true,
 | 
			
		||||
  "loopfunc": true,
 | 
			
		||||
  "maxerr": 1000,
 | 
			
		||||
  "nonstandard": true,
 | 
			
		||||
  "sub": true,
 | 
			
		||||
  "validthis": true
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								make.js
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								make.js
									
									
									
									
									
								
							@ -971,6 +971,29 @@ target.lint = function() {
 | 
			
		||||
  crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// make jshint
 | 
			
		||||
//
 | 
			
		||||
target.jshint = function() {
 | 
			
		||||
  cd(ROOT_DIR);
 | 
			
		||||
  echo();
 | 
			
		||||
  echo('### Linting JS files (this can take a while!)');
 | 
			
		||||
 | 
			
		||||
  var LINT_FILES = [//'make.js',
 | 
			
		||||
                    //'external/builder/*.js',
 | 
			
		||||
                    //'external/crlfchecker/*.js',
 | 
			
		||||
                    'src/',
 | 
			
		||||
                    //'web/*.js',
 | 
			
		||||
                    //'test/*.js',
 | 
			
		||||
                    //'test/unit/*.js',
 | 
			
		||||
                    //'extensions/firefox/*.js',
 | 
			
		||||
                    //'extensions/firefox/components/*.js',
 | 
			
		||||
                    //'extensions/chrome/*.js'
 | 
			
		||||
                    ];
 | 
			
		||||
 | 
			
		||||
  exec('jshint --reporter test/reporter.js ' + LINT_FILES.join(' '));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// make clean
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								test/reporter.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								test/reporter.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  reporter: function (res) {
 | 
			
		||||
    var len = 0;
 | 
			
		||||
    var str = "";
 | 
			
		||||
 | 
			
		||||
    res.forEach(function (r) {
 | 
			
		||||
      var file = r.file;
 | 
			
		||||
      var err = r.error;
 | 
			
		||||
 | 
			
		||||
      switch(err.code) {
 | 
			
		||||
        case 'W004': // variable is already defined
 | 
			
		||||
        case 'W018': // confusing use of !
 | 
			
		||||
          break;
 | 
			
		||||
        default:
 | 
			
		||||
          len++;
 | 
			
		||||
          str += file + ": line " + err.line + ", col " +
 | 
			
		||||
            err.character + ", " + err.reason + "\n";
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (str) {
 | 
			
		||||
      process.stdout.write(str + "\n" + len + " error" +
 | 
			
		||||
        ((len === 1) ? "" : "s") + "\n");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user