UNPKG

isml-linter

Version:

ISML Linter is a tool for examining if your project's templates follow a specified set of rules defined by your dev team. The available rules can be roughly grouped into:

37 lines (24 loc) 988 B
const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype'); const ruleId = require('path').basename(__filename).slice(0, -3); const description = 'Avoid using <br/> tags, use css instead'; const occurrenceText = '<br'; const Rule = Object.create(SingleLineRulePrototype); Rule.init(ruleId, description); Rule.isBroken = function(line) { return line.indexOf(occurrenceText) >= 0; }; Rule.getColumnNumber = function(line) { return Math.max(line.indexOf('<br'), 0) + 1; }; Rule.getFirstOccurrence = function(line) { let result = null; if (this.isBroken(line)) { const matchPos = line.indexOf(occurrenceText); const temp = line.substring(line.indexOf(occurrenceText)); const matchLength = temp.indexOf('>') + 1; result = { globalPos : matchPos, length : matchLength }; } return result; }; module.exports = Rule;