UNPKG

@coffeelint/cli

Version:
49 lines (42 loc) 1.31 kB
(function() { var LineEndings; module.exports = LineEndings = (function() { class LineEndings { lintLine(line, lineApi) { var ending, lastChar, ref, valid; ending = (ref = lineApi.config[this.rule.name]) != null ? ref.value : void 0; if (!ending || lineApi.isLastLine() || !line) { return null; } lastChar = line[line.length - 1]; valid = (function() { if (ending === 'windows') { return lastChar === '\r'; } else if (ending === 'unix') { return lastChar !== '\r'; } else { throw new Error(`unknown line ending type: ${ending}`); } })(); if (!valid) { return { columnNumber: line.length, context: `Expected ${ending}` }; } else { return null; } } }; LineEndings.prototype.rule = { type: 'problem', name: 'line_endings', level: 'ignore', value: 'unix', // or 'windows' message: 'Line contains incorrect line endings', description: `This rule ensures your project uses only <tt>windows</tt> or <tt>unix</tt> line endings. This rule is disabled by default.` }; return LineEndings; }).call(this); }).call(this);