<commit_before>var util = Npm.require('util');
var Future = Npm.require('fibers/future');
var path = Npm.require('path');
var jshint = Npm.require('jshint').JSHINT;

Plugin.registerLinter({
  extensions: ["jshintrc", "js"],
}, function () {
  var linter = new JsHintLinter();
  return linter;
});

function JsHintLinter () {};

JsHintLinter.prototype.processFilesForTarget = function (files) {
  var conf = {
    undef: true,
    unused: true
  };

  files.forEach(function (file) {
    // find the config file
    if (file.getBasename() === '.jshintrc') {
      var confStr = file.getContentsAsString();
      try {
        conf = JSON.parse(confStr);
      } catch (err) {
        file.error("Failed to parse .jshint file, not a valid JSON: " + err.message);
      }
      return;
    }
    // require configuration file to be called '.jshintrc'
    if (path.extname(file.getBasename()) !== 'js') {
      file.error("Unrecognized configuration file name. Configuration file should be called .jshintrc");
      return;
    }
  });

  files.forEach(function (file) {
    if (file.getBasename() === '.jshintrc')
      return;
    if (! jshint(file.getContentsAsString(), conf, file.getPackageImports())) {
      jshint.errors.forEach(function (error) {
        file.error({
          message: error.reason,
          line: error.line,
          col: error.character
        });
      });
    }
  });
};


<commit_msg>Fix bugs in the jshint package<commit_after>var util = Npm.require('util');
var Future = Npm.require('fibers/future');
var path = Npm.require('path');
var jshint = Npm.require('jshint').JSHINT;

Plugin.registerLinter({
  extensions: ["jshintrc", "js"],
}, function () {
  var linter = new JsHintLinter();
  return linter;
});

function JsHintLinter () {};

JsHintLinter.prototype.processFilesForTarget = function (files) {
  var conf = {
    undef: true,
    unused: true
  };

  files.forEach(function (file) {
    // find the config file
    if (file.getBasename() === '.jshintrc') {
      var confStr = file.getContentsAsString();
      try {
        conf = JSON.parse(confStr);
      } catch (err) {
        file.error({ message: "Failed to parse .jshint file, not a valid JSON: " + err.message });
      }
      return;
    }
    // require configuration file to be called '.jshintrc'
    if (path.extname(file.getBasename()) !== '.js') {
      file.error({ message: "Unrecognized configuration file name. Configuration file should be called .jshintrc" });
      return;
    }
  });

  files.forEach(function (file) {
    if (file.getBasename() === '.jshintrc')
      return;
    if (! jshint(file.getContentsAsString(), conf, file.getPackageImports())) {
      jshint.errors.forEach(function (error) {
        file.error({
          message: error.reason,
          line: error.line,
          column: error.character
        });
      });
    }
  });
};



{'fraction_non_alphanumeric': 0.1524835012156999, 'fraction_numerical': 0.0, 'mean_word_length': 2.7745740498034075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '350978', 'n_tokens_mistral': 929, 'n_tokens_neox': 917, 'n_words': 213}