UNPKG

gherkin-lint-ts

Version:

Gherkin features linter written in Typescript

33 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.name = void 0; exports.name = "no-background-only-scenario"; function run(feature) { var _a; if (!feature) { return []; } const errors = []; (_a = feature.children) === null || _a === void 0 ? void 0 : _a.forEach(child => { if (child.background) { // @ts-ignore if (feature.children.length <= 2) { // as just one background is allowed, if there is a background in the feature, // there must be at least, three elements in the feature to have, more than // one scenario errors.push(createError(child.background)); } } }); return errors; } exports.run = run; function createError(background) { var _a; return { message: "Backgrounds are not allowed when there is just one scenario.", rule: exports.name, line: ((_a = background.location) === null || _a === void 0 ? void 0 : _a.line) || 0, }; } //# sourceMappingURL=no-background-only-scenario.js.map