@sasjs/lint
Version:
Linting and formatting for SAS code
46 lines • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.maxLineLength = void 0;
const LintRuleType_1 = require("../../types/LintRuleType");
const Severity_1 = require("../../types/Severity");
const utils_1 = require("../../utils");
const name = 'maxLineLength';
const description = 'Restrict lines to the specified length.';
const message = 'Line exceeds maximum length';
const test = (value, lineNumber, config, options) => {
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
let maxLineLength = utils_1.DefaultLintConfiguration.maxLineLength;
if (config) {
if (options === null || options === void 0 ? void 0 : options.isHeaderLine) {
maxLineLength = Math.max(config.maxLineLength, config.maxHeaderLineLength);
}
else if (options === null || options === void 0 ? void 0 : options.isDataLine) {
maxLineLength = Math.max(config.maxLineLength, config.maxDataLineLength);
}
else {
maxLineLength = config.maxLineLength;
}
}
if (value.length <= maxLineLength)
return [];
return [
{
message: `${message} by ${value.length - maxLineLength} characters`,
lineNumber,
startColumnNumber: 1,
endColumnNumber: 1,
severity
}
];
};
/**
* Lint rule that checks if a line has exceeded the configured maximum length.
*/
exports.maxLineLength = {
type: LintRuleType_1.LintRuleType.Line,
name,
description,
message,
test
};
//# sourceMappingURL=maxLineLength.js.map