ecmarkup
Version:
Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.
26 lines (25 loc) • 896 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ruleId = 'for-each-element';
/*
Checks that "For each" loops name a type or say "element" before the variable.
*/
function default_1(report) {
return {
enter(node) {
if (node.name !== 'ordered-list-item' || node.contents.length < 2) {
return;
}
const [first, second] = node.contents;
if (first.name === 'text' && first.contents === 'For each ' && second.name === 'underscore') {
report({
ruleId,
line: second.location.start.line,
column: second.location.start.column,
message: 'expected "for each" to have a type name or "element" before the loop variable',
});
}
},
};
}
exports.default = default_1;