UNPKG

gherkin-lint-ts

Version:

Gherkin features linter written in Typescript

38 lines 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.availableConfigs = exports.name = void 0; const chalk_1 = __importDefault(require("chalk")); const path = require("path"); const _ = require("lodash"); exports.name = "file-name"; exports.availableConfigs = { "style": "PascalCase", }; const checkers = { "PascalCase": filename => _.startCase(filename).replace(/ /g, ""), "Title Case": filename => _.startCase(filename), "camelCase": filename => _.camelCase(filename), "kebab-case": filename => _.kebabCase(filename), "snake_case": filename => _.snakeCase(filename), }; function run(feature, file, configuration) { const { style } = _.merge(exports.availableConfigs, configuration); const filename = path.basename(file.relativePath, ".feature"); if (!checkers[style]) { throw new Error(`style "${style}" not supported for file-name rule`); } const expected = checkers[style](filename); if (filename === expected) { return []; } return [{ message: `File names should be written in ${style} e.g. "${chalk_1.default.cyan(`${expected}.feature`)}"`, rule: exports.name, line: 0, }]; } exports.run = run; //# sourceMappingURL=file-name.js.map