eslint-plugin-cucumber
raw JSON → 2.0.0 verified Sat Apr 25 auth: no javascript
ESLint plugin providing rules for Cucumber step definitions and hooks. The latest stable version is 2.0.0, which updates no-arrow-functions for ESLint 7 compatibility. Released as a major version bump for safety, though the change is backward compatible. Earlier versions (1.x) added features like async-then, expression-type, no-restricted-tags, and no-arrow-functions rules. It supports Cucumber v2+ syntax and is designed to enforce best practices in Cucumber test files. Minimal dependencies, lightweight, and focused on linting step definitions.
Common errors
error ESLint couldn't find the plugin "eslint-plugin-cucumber". ↓
cause Plugin not installed or not in node_modules.
fix
Run npm install eslint-plugin-cucumber --save-dev
error Configuration for rule "cucumber/async-then" is invalid: Value "2" is not a valid severity. ↓
cause Incorrect rule configuration format.
fix
Use numeric severity or string: "cucumber/async-then": 2 or "cucumber/async-then": "error"
error Parsing error: The keyword 'Given' is not defined. ↓
cause ESLint is parsing step definitions as regular code without Cucumber globals.
fix
Add an environment or use a global define for step keywords.
Warnings
breaking v2.0.0 updates no-arrow-functions rule for ESLint 7 compatibility, may break if using older ESLint version. ↓
fix Update ESLint to version 7 or later.
gotcha Plugin must be installed locally if ESLint is installed globally. ↓
fix Install plugin globally if ESLint is global: npm install -g eslint-plugin-cucumber
gotcha Rule 'no-arrow-functions' restricts arrow functions on step definitions; may conflict with async/await usage. ↓
fix Prefer regular functions for step definitions.
Install
npm install eslint-plugin-cucumber yarn add eslint-plugin-cucumber pnpm add eslint-plugin-cucumber Imports
- cucumber wrong
require('eslint-plugin-cucumber')correctAdd 'cucumber' to plugins in .eslintrc - async-then wrong
"cucumber/async-then": "error"correct"cucumber/async-then": 2 - expression-type wrong
"cucumber/expression-type": 2correct"cucumber/expression-type": [2, "CucumberExpression"]
Quickstart
// .eslintrc.json
{
"plugins": ["cucumber"],
"rules": {
"cucumber/async-then": 2,
"cucumber/expression-type": [2, "CucumberExpression"],
"cucumber/no-restricted-tags": [2, "wip", "broken"],
"cucumber/no-arrow-functions": 2
}
}