ecmarkup
Version:
Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.
28 lines (27 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ruleId = 'algorithm-step-labels';
/*
Checks that step labels all start with `step-`.
*/
function default_1(report, node, algorithmSource) {
return {
enter(node) {
if (node.name !== 'ordered-list-item') {
return;
}
const idAttr = node.attrs.find(({ key }) => key === 'id');
if (idAttr != null && !/^step-/.test(idAttr.value)) {
const itemSource = algorithmSource.slice(node.location.start.offset, node.location.end.offset);
const offset = itemSource.match(/^\s*\d+\. \[ *id *= *"/)[0].length;
report({
ruleId,
line: node.location.start.line,
column: node.location.start.column + offset,
message: `step labels should start with "step-"`,
});
}
},
};
}
exports.default = default_1;