UNPKG

@sasjs/lint

Version:

Linting and formatting for SAS code

41 lines 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.indentationMultiple = void 0; const LintRuleType_1 = require("../../types/LintRuleType"); const Severity_1 = require("../../types/Severity"); const name = 'indentationMultiple'; const description = 'Ensure indentation by a multiple of the configured number.'; const message = 'Line has incorrect indentation'; const test = (value, lineNumber, config) => { if (!value.startsWith(' ')) return []; const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning; const indentationMultiple = isNaN(config === null || config === void 0 ? void 0 : config.indentationMultiple) ? 2 : config.indentationMultiple; if (indentationMultiple === 0) return []; const numberOfSpaces = value.search(/\S|$/); if (numberOfSpaces % indentationMultiple === 0) return []; return [ { message: `${message} - ${numberOfSpaces} ${numberOfSpaces === 1 ? 'space' : 'spaces'}`, lineNumber, startColumnNumber: 1, endColumnNumber: 1, severity } ]; }; /** * Lint rule that checks if a line is indented by a multiple of the configured indentation multiple. */ exports.indentationMultiple = { type: LintRuleType_1.LintRuleType.Line, name, description, message, test }; //# sourceMappingURL=indentationMultiple.js.map