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:

35 lines (22 loc) 877 B
const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype'); const ruleId = require('path').basename(__filename).slice(0, -3); const description = 'Avoid using importPackage()'; const occurrenceText = 'importPackage'; 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('importPackage('), 0) + 1; }; Rule.getFirstOccurrence = function(line) { let result = null; if (this.isBroken(line)) { const matchPos = line.indexOf(occurrenceText); result = { globalPos : matchPos, length : occurrenceText.length }; } return result; }; module.exports = Rule;