UNPKG

@coffeelint/cli

Version:
45 lines (37 loc) 1.22 kB
(function() { var NoTabs, indentationRegex, indexOf = [].indexOf; indentationRegex = /\S/; module.exports = NoTabs = (function() { class NoTabs { lintLine(line, lineApi) { var indentation; // Only check lines that have compiled tokens. This helps // us ignore tabs in the middle of multi line strings, heredocs, etc. // since they are all reduced to a single token whose line number // is the start of the expression. indentation = line.split(indentationRegex)[0]; if (lineApi.lineHasToken() && indexOf.call(indentation, '\t') >= 0) { return { columnNumber: indentation.indexOf('\t') }; } else if (lineApi.lineHasToken() && line.match(/\t *$/)) { return { columnNumber: indentation.indexOf('\t') }; } else { return null; } } }; NoTabs.prototype.rule = { type: 'style', name: 'no_tabs', level: 'error', message: 'Line contains tab indentation', description: `This rule forbids tabs in indentation. Enough said. It is enabled by default.` }; return NoTabs; }).call(this); }).call(this);