GherLint, a tool for checking patterns on Gherkin files.
Using npm:
npm install -D @gherlint/gherlintUsing yarn:
yarn add -D @gherlint/gherlintnpx gherlint features/Apply fix with --fix option.
npx gherlint --fix features/GherLint supports configuring rules and other options via a config file. We support the following config file formats:
NOTE: Priority is given to the config file in the following order:
.gherlintrc
.gherlintrc.js
.gherlintrc.json
See Configuration for defaults.
All rules can be switched to one of these levels: off, warn, error.
e.g. to make the linter fail on indentation problems, show only a warning for grammar issues and ignore the lowercase titles rule set:
{
"rules": {
"indentation": "error",
"grammar_check": "warn"
"lowercase_title": "off",
...
}
}
Some rules can take extra parameters as options. For that the value in the setting object needs to become an array. The first item in the array is always the level (off, warn, error) and the following items are other options.
Please note that the order in that array matters. Every option has to be in the right place.
These rules can take extra options:
indentation
- level
string - required spaces for every indent step
int
e.g. "indentation": ["error", 4]
newline_before_scenario
- level
string - required new lines before each scenario
int - count tag and comment as newline
boolean
e.g. "newline_before_scenario": ["error", 4, false]
grammar_check
- level
string - dialect
stringAmerican | British | Australian | Canadian - words to import into the dictionary
string[] - rules to switch on or off
objectwith the name of the rule as key andfalse|trueas value - strings to replace
string[][]where the inner array has two items, first being the search value and the second the replacement value.
e.g.
"grammar_check": [
"warn",
"American",
["JankariTech", "GmbH"],
{
"ExpandMinimum": false,
"ExpandTimeShorthands": false,
},
[
[ "\\n", " " ],
[ "~", "" ]
]
words_to_avoid
- level
string - strings to avoid
string[][]where the inner array has two items, first being the string to avaoid and the second optionally a custom error message.
e.g.
"words_to_avoid": [
"error",
[
["click"],
["clicks"],
["clicked"],
["see", "Describe the behavior of the app, not what the user sees."],
["sees", "Describe the behavior of the app, not what the user sees."],
["seen", "Describe the behavior of the app, not what the user sees."]
]
]
GherLint adheres to this Code of Conduct.
Please make sure to read our Contributing Guide before making a pull request.
Please make sure to follow the issue templates when opening an issue.
For a feature request, use this template: Feature Request.
For a bug report, use this template: Bug Report.
If you want to contribute by adding a new rule, please follow the Adding New Rule guide.
Gherlint can be run using Docker without installing dependencies locally.
docker build -t gherlint .
docker run --rm \
-v /path/to/project:/project \
gherlint \
/project/features \
-c /project/.gherlintrc.json
docker run --rm \
-v /path/to/project:/project \
gherlint \
--fix \
/project/features \
-c /project/.gherlintrc.json
The Docker container runs the Gherlint CLI, uses mounted project files as input, reports lint errors, and applies available fixes with --fix.