max-keywords
Allow to limit the amount of steps of the specified keywords. The keywords And, But, or * counts as the previous keyword.
Configuration
| Name | Type | Description | Default |
|---|---|---|---|
given | number | Max allowed steps for Given. 0 means is not allowed and a negative value (or undefined) means unlimited. | -1 |
when | number | Max allowed steps for When. 0 means is not allowed and a negative value (or undefined) means unlimited. | -1 |
then | number | Max allowed steps for Then. 0 means is not allowed and a negative value (or undefined) means unlimited. | -1 |
onlyContiguous | boolean | If true, only counts contiguous steps, resetting the limit if another keyword is used. | false |
ignoreConjunctions | boolean | If true, only counts the main keywords, ignoring conjunctions (And, But, *). | false |
Examples
Limit When to 1 occurrence
Whenis limited to one occurrence.GivenandThenare not defined, which means there are no limit for them.
{
"max-keywords": [
"error",
{
"when": 1
}
]
}
Limit When to 3 occurrence, and Given to 1
Givenis limited to one occurrence, andWhenis limited to three occurrences.Thenis not defined, which means there is no limit for it.
{
"max-keywords": [
"error",
{
"given": 1,
"when": 3
}
]
}
Forbid the use of Given step
Do not allow to use the step
Given.
{
"max-keywords": [
"error",
{
"given": 0
}
]
}
Limit When to 1 when are put together.
Limit
Whento 1, but only if there are not other keywords between.
{
"max-keywords": [
"error",
{
"when": 1,
"onlyContiguous": true
}
]
}