var Issue = require('../issue');

module.exports = {
  name: 'line-length',
  on: ['line']
};

module.exports.lint = function (line, opts) {
  var maxLength = opts[this.name];
  var ignoreRegExpString = opts[this.name + '-ignore-regex'];
  var lineText;
  var len;
  var pos;

  if (!maxLength) {
    return [];
  }

  lineText = line.line;

  if (ignoreRegExpString && (new RegExp(ignoreRegExpString, 'g')).test(lineText)) {
    return [];
  }

  len = lineText.length - 1;

  if (len <= maxLength) {
    return [];
  }

  pos = [line.row, len + 1];

  return new Issue('E040', pos, { maxlength: maxLength, length: len });
};

var Issue = require('../issue');

module.exports = {
  name: 'line-length',
  on: ['line']
};

module.exports.lint = function (line, opts) {
  var maxLength = opts[this.name];
  var ignoreRegExpString = opts[this.name + '-ignore-regex'];
  var lineText;
  var len;
  var pos;

  if (!maxLength) {
    return [];
  }

  lineText = line.line;

  if (ignoreRegExpString && (new RegExp(ignoreRegExpString, 'g')).test(lineText)) {
    return [];
  }

  len = lineText.length;

  if (len <= maxLength) {
    return [];
  }

  pos = [line.row, len];

  return new Issue('E040', pos, { maxlength: maxLength, length: len });
};

Fix off-by-one error for line lengths
Fix off-by-one error for line lengths
