How to use the jshint/src/cli.loadConfig 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 FGRibreau / check-build / src / interface / jshint.js View on Github external
return function (options, f) {
    options = options || {};

    options.config = jshintcli.loadConfig(p.resolve(process.cwd(), './.jshintrc'));
    options.args = grunt.file.expand(options.args);

    options.reporter = function (results, data, options) {
      // @todo implement fixmyfs
      // if (checkBuildOptions.checkbuild.enable.indexOf('fixmyjs') !== -1) {
      //   results.forEach(function (file) {
      //     console.log(fixmyjs.fix(shjs.cat(file.file), {}));
      //   });
      // }

      // use jshint-stylish by default
      var stylish = require('jshint-stylish').reporter(results, data, options);
      return stylish;
    };

    var hadErrors = !jshintcli.run(options);
github STRML / JSXHint / utils.js View on Github external
copyConfig: function copyConfig(dir, file){
    var filePath = path.resolve(dir, file);
    if (checkedSupportFiles[filePath]) return;
    // Indicate that this is copied already to prevent unnecessary file operations.
    checkedSupportFiles[filePath] = true;

    if (fs.existsSync(filePath)) {
      var destination = path.join(utils.tmpdir, utils.getCleanAbsolutePath(filePath));
      debug("Copying support file from %s to temp directory at %s.", filePath, destination);
      if (file === '.jshintrc') {
        try {
          var jshintrc = jshintcli.loadConfig(filePath);
          fs.writeJSONSync(destination, utils.ensureJshintrcOverrides(jshintrc));
        } catch(e) {
          console.error('Unable to parse .jshintrc file at %s. It must be valid JSON. Error: %s', filePath, e.message);
          return;
        }
      } else {
        fs.copySync(filePath, destination);
      }
    }
    // Not found, keep looking up the root.
    else {
      var parent = path.resolve(dir, '..');
      // Return null at the root, which is also when dir and its parent are the same.
      if (dir === parent) return;
      return copyConfig(parent, file);
    }
github gruntjs / grunt-contrib-jshint / tasks / lib / jshint.js View on Github external
// Select a reporter to use
    var reporter = exports.selectReporter(options);

    // Remove bad options that may have came in from the cli
    ['reporter', 'reporterOutputRelative', 'jslint-reporter', 'checkstyle-reporter', 'show-non-errors'].forEach(function(opt) {
      if (options.hasOwnProperty(opt)) {
        delete options[opt];
      }
    });

    if (options.jshintrc === true) {
      // let jshint find the options itself
      delete cliOptions.config;
    } else if (options.jshintrc) {
      // Read JSHint options from a specified jshintrc file.
      cliOptions.config = jshintcli.loadConfig(options.jshintrc);
    } else {
      // Enable/disable debugging if option explicitly set.
      if (grunt.option('debug') !== undefined) {
        options.devel = options.debug = grunt.option('debug');
        // Tweak a few things.
        if (grunt.option('debug')) {
          options.maxerr = Infinity;
        }
      }
      // pass all of the remaining options directly to jshint
      cliOptions.config = options;
    }

    // Run JSHint on all file and collect results/data
    var allResults = [];
    var allData = [];
github sindresorhus / atom-jshint / load-config.js View on Github external
const loadConfigIfValid = filename => {
	const strip = require('strip-json-comments');
	try {
		JSON.parse(strip(fs.readFileSync(filename, 'utf8')));
		return cli.loadConfig(filename);
	} catch (e) {
	}
	return {};
};
github groupe-sii / sonar-web-frontend-reporters / build / reporters / jshint.reporter.js View on Github external
value: function launch(done) {
      var _this2 = this;

      this.options.jshint = jshintcli.loadConfig(this.options.rulesFile);
      delete this.options.jshint.dirname;
      this.options.globals = this.options.jshint.globals;
      delete this.options.jshint.globals;

      glob(this.options.src, function (er, files) {
        _this2.processFiles(files, _this2.options);
        _this2.closeReporter(_this2.options.report);

        if (typeof done === 'function') {
          done();
        }
      });
    }
  }, {
github danawoodman / starter / node_modules / gulp-jshint / src / lint.js View on Github external
loader: function (path) {
      var cfg = jshintcli.loadConfig(path);
      delete cfg.dirname;
      return cfg;
    }
  });
github groupe-sii / sonar-web-frontend-reporters / lib / reporters / jshint.reporter.js View on Github external
launch (done) {
    this.options.jshint = jshintcli.loadConfig(this.options.rulesFile);
    delete this.options.jshint.dirname;
    this.options.globals = this.options.jshint.globals;
    delete this.options.jshint.globals;

    glob(this.options.src, (er, files) => {
      this.processFiles(files, this.options);
      this.closeReporter(this.options.report);

      if (typeof done === 'function') {
        done();
      }
    });
  }
github Robdel12 / DropKick / node_modules / gulp-jshint / src / lint.js View on Github external
loader: function (path) {
      var cfg = jshintcli.loadConfig(path);
      delete cfg.dirname;
      return cfg;
    }
  });