gplint
Version:
A Gherkin linter/validator written in Javascript.
36 lines • 1.01 kB
JavaScript
import { featureSpread } from './utils/gherkin.js';
export const name = 'no-empty-background';
export function run({ feature }) {
if (!feature) {
return [];
}
const errors = [];
const { children } = featureSpread(feature);
children.forEach(child => {
if (child.background) {
if (child.background.steps.length === 0) {
errors.push(createError(child.background));
}
}
});
return errors;
}
function createError(background) {
return {
message: 'Empty backgrounds are not allowed.',
rule: name,
line: background.location.line,
column: background.location.column,
};
}
export const documentation = {
description: 'Disallows features with backgrounds without steps.',
examples: [{
title: 'Example',
description: 'Enable rule',
config: {
[name]: 'error',
}
}],
};
//# sourceMappingURL=no-empty-background.js.map