Skip to content

gherkin-lint

gherkin-lint documentation

gherkin-lint - GitHub

Configuration in Mega-Linter

Variable Description Default value
GHERKIN_GHERKIN_LINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
GHERKIN_GHERKIN_LINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
GHERKIN_GHERKIN_LINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
GHERKIN_GHERKIN_LINT_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
{linter.cli_lint_mode}
GHERKIN_GHERKIN_LINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".feature"]
GHERKIN_GHERKIN_LINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
GHERKIN_GHERKIN_LINT_PRE_COMMANDS List of bash commands to run before the linter None
GHERKIN_GHERKIN_LINT_POST_COMMANDS List of bash commands to run after the linter None
GHERKIN_GHERKIN_LINT_CONFIG_FILE gherkin-lint configuration file name
Use LINTER_DEFAULT to let the linter find it
.gherkin-lintrc
GHERKIN_GHERKIN_LINT_RULES_PATH Path where to find linter configuration file Workspace folder, then Mega-Linter default rules
GHERKIN_GHERKIN_LINT_DISABLE_ERRORS Run linter but consider errors as warnings false
GHERKIN_GHERKIN_LINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0

Mega-Linter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default Mega-Linter Flavor 94 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .feature

How the linting is performed

  • gherkin-lint is called one time by identified file

Example calls

gherkin-lint myfile.feature
gherkin-lint -c .gherkin-lintrc myfile.feature

Help content

Usage: gherkin-lint [options] <feature-files>

Options:
  -f, --format [format]  output format. Possible values: json, stylish, xunit.
                         Defaults to stylish
  -i, --ignore <...>     comma seperated list of files/glob patterns that the
                         linter should ignore, overrides .gherkin-lintignore
                         file
  -c, --config [config]  configuration file, defaults to .gherkin-lintrc
  -r, --rulesdir <...>   additional rule directories (default: [])
  -h, --help             display help for command

Installation on mega-linter Docker image

Example success log

Results of gherkin-lint linter (version 0.0.0)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/gherkin_gherkin_lint/
-----------------------------------------------

[SUCCESS] .automation/test/gherkin/gherkin_good_01.feature


Example error log

Results of gherkin-lint linter (version 0.0.0)
See documentation on https://nvuillam.github.io/mega-linter/descriptors/gherkin_gherkin_lint/
-----------------------------------------------

[ERROR] .automation/test/gherkin/gherkin_bad_01.feature
    .automation/test/gherkin/gherkin_bad_01.feature
      8     Scenario name is already used in: .automation/test/gherkin/gherkin_bad_01.feature:4    no-dupe-scenario-names
      11    Trailing spaces are not allowed                                                                  no-trailing-spaces
      12    Multiple empty lines are not allowed                                                             no-multiple-empty-lines