How to use the jshint.JSHINT.data function in jshint

To help you get started, we’ve selected a few jshint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rwaldron / mediagroup.js / Jakefile.js View on Github external
},

		dataProps = {
			unuseds: true,
			implieds: true,
			globals: true
		},
		props;

		jshint( src, hint );

		errors = jshint.errors;

		if ( hint.data ) {

			data = jshint.data();

			Object.keys( dataProps ).forEach(function( prop ) {
				if ( data[ prop ] ) {
					console.log( prop, data[ prop ] );
				}
			});
		}

		for ( var i = 0; i < errors.length; i++ ) {
			warning = errors[i];

			// If a warning exists for this error
			if ( warning &&
					// If the warning has evidence and the evidence is NOT a single line comment
					( warning.evidence && !/^\/\//.test( warning.evidence.trim() ) )
				) {
github es-analysis / plato / lib / reporters / jshint / index.js View on Github external
function lint(source, config, globals) {
  config = config || {};

  var results = [];
  var data = [];

  // Remove potential Unicode BOM.
  source = source.replace(/^\uFEFF/, "");
  if (!JSHINT(source, config, globals)) {
    JSHINT.errors.forEach(function (err) {
      if (err) results.push({ error: err });
    });
  }

  var lintData = JSHINT.data();
  if (lintData) data.push(lintData);

  return {
    results : results,
    data : data
  };
}
github nraboy / cordova-hooks / before_prepare / 02_jshint.js View on Github external
function lintFile(file) {
    console.log("Linting " + file);
    var fileData = fs.readFileSync(file);
    if(jshint(fileData.toString(), jshintConfig)) {
        console.log("File " + file + " has no errors.");
        console.log("-----------------------------------------");
        return 0;
    } else {
        console.log("Errors in file " + file);
        var out = jshint.data(),
        errors = out.errors;
        for(var j = 0; j < errors.length; j++) {
            console.log(errors[j].line + ":" + errors[j].character + " -> " + errors[j].reason + " -> " + errors[j].evidence);
        }
        console.log("-----------------------------------------");
        return 1;
    }
}
github addyosmani / sublime-fixmyjs / fixmyjs.js View on Github external
stdin(function (data) {
	var opts = JSON.parse(process.argv[2]);

	try {
		if (opts.legacy) {
			jshint(data, opts);
			var js = fixmyjs(jshint.data(), data, opts).run();
		} else {
			var js = fixmyjs.fix(data, opts);
		}
		process.stdout.write(js);
	} catch (err) {
		throw err;
	}
});
github pillarsjs / pillars / lib / textualization.js View on Github external
function load(path,source){
		if(!source || source===path){
			cache[path]={};
			for(var l in langs){
				var lang = langs[l];
				try {
					var source = fs.readFileSync(path+'/'+lang+'.js','utf8');
					source = "cache[path][lang] = {"+source+"};";
					if(!jshint(source)){
						var checkfail = jshint.data().errors;
						var error = new Error("Sheet sintax error");
						error.stack = [];
						for(var e in checkfail){
							error.stack.push((checkfail[e].reason+" in line "+checkfail[e].line));
						}
						throw error;
					}
					eval(source);
					if(cache[path][lang]){
						if(!heap[lang]){heap[lang]={};}
						for(var i in cache[path][lang]){
							if(heap[lang][i]){logger.info('heap-rewrite',{path:path,lang:lang,element:i});}
							heap[lang][i]=cache[path][lang][i];
						}
					}
					logger.info('load-ok',{path:path,lang:lang,count:Object.keys(cache[path][lang]).length});
github Robdel12 / DropKick / node_modules / gulp-jshint / src / lint.js View on Github external
var reportErrors = function (file, out, cfg) {
    var filePath = (file.path || 'stdin');

    out.results = jshint.errors.map(function (err) {
      if (!err) return;
      return { file: filePath, error: err };
    }).filter(Boolean);

    out.opt = cfg;
    out.data = [jshint.data()];
    out.data[0].file = filePath;
  };
github ecomfe / edp / lib / jshint.js View on Github external
function detectJS( file, startDir, conf, result ) {
    conf = conf || require( './jshint/conf' );

    var data = {};
    result.push( data );
    data.file = path.relative( startDir, file );

    var jshint = require( 'jshint' ).JSHINT;
    var source = fs.readFileSync( file );

    data.success = jshint( source.toString( 'UTF-8' ), conf );
    if ( !data.success ) {
        data.errors = jshint.errors;
        data.data = jshint.data();
    }
}