gherkin-lint-ts
Version:
Gherkin features linter written in Typescript
46 lines • 1.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.name = void 0;
const chalk_1 = __importDefault(require("chalk"));
const _ = require("lodash");
exports.name = "one-space-between-tags";
function run(feature) {
var _a;
if (!feature) {
return [];
}
const errors = [];
testTags(feature, errors);
(_a = feature.children) === null || _a === void 0 ? void 0 : _a.forEach(child => {
var _a;
if (child.scenario) {
testTags(child.scenario, errors);
(_a = child.scenario.examples) === null || _a === void 0 ? void 0 : _a.forEach(example => {
testTags(example, errors);
});
}
});
return errors;
}
exports.run = run;
function testTags(node, errors) {
_(node.tags)
.groupBy("location.line")
.sortBy("location.column")
.forEach(tags => {
_.range(tags.length - 1)
.map(i => {
if (tags[i].location.column + tags[i].name.length < tags[i + 1].location.column - 1) {
errors.push({
line: tags[i].location.line,
rule: exports.name,
message: `There is more than one space between the tags ${chalk_1.default.yellow(tags[i].name)} and ${chalk_1.default.yellow(tags[i + 1].name)}`,
});
}
});
});
}
//# sourceMappingURL=one-space-between-tags.js.map