eslint-plugin-cucumber-flat
v1.0.0
Published
ESLint plugin for Cucumber.js - ESLint 9 flat config compatible
Maintainers
Readme
eslint-plugin-cucumber-flat
ESLint 9 flat config compatible plugin for linting Cucumber.js feature files and step definitions.
Based on eslint-plugin-cucumber by Darrin Holst, adapted for ESLint 9 flat config.
Installation
npm install --save-dev eslint-plugin-cucumber-flat
# or with yarn
yarn add -D eslint-plugin-cucumber-flatRequirements:
- ESLint 9.0.0 or higher
- Node.js 20.0.0 or higher
Rules
- async-then: Ensure async step implementations
- expression-type: Enforce expression type for step definitions (Cucumber Expressions vs RegExp)
- no-arrow-functions: Disallow arrow functions in step definitions
- no-restricted-tags: Disallow specific Cucumber tags
Usage
This plugin is designed for ESLint 9+ with flat config format.
// Import the plugin
import cucumberPlugin from "eslint-plugin-cucumber-flat";
export default [
// For .feature files (uses processor to extract tags)
{
files: ["**/*.feature"],
plugins: {
cucumber: cucumberPlugin,
},
processor: cucumberPlugin.processors[".feature"],
rules: {
"cucumber/no-restricted-tags": ["error", "@skip", "@wip"],
},
},
// For step definition files (no processor needed)
{
files: ["**/*step*.js", "**/*.steps.js", "**/step-definitions/**/*.js"],
plugins: {
cucumber: cucumberPlugin,
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"cucumber/async-then": "error",
"cucumber/expression-type": ["error", "Cucumber"],
"cucumber/no-arrow-functions": "error",
},
},
];Rules Documentation
For detailed information about each rule, see the individual rule documentation:
- async-then - Ensure async step implementations
- expression-type - Enforce expression type for step definitions (Cucumber Expressions vs RegExp)
- no-arrow-functions - Disallow arrow functions in step definitions (prevents
thisbinding issues) - no-restricted-tags - Disallow specific Cucumber tags in feature files
Testing
The plugin includes a comprehensive test suite to validate all rules work correctly.
Run Tests
npm test
# or
node test/run-tests.mjsTest Coverage
- ✅ Feature file tag validation
- ✅ Step definition async patterns
- ✅ Arrow function detection
- ✅ Expression type enforcement
See test/README.md for details.
License
MIT (based on original eslint-plugin-cucumber)
