eslint-plugin-bdd
raw JSON → 2.1.1 verified Sat Apr 25 auth: no javascript
This ESLint plugin provides rules to enforce best practices and prevent common mistakes in BDD-style test suites, such as accidentally leaving focused tests (fit, fdescribe, etc.) or excluded tests (xit, xdescribe). Version 2.1.1 is the current stable release, with a lightweight peer dependency on ESLint >=0.8.0. Unlike similar plugins targeting specific frameworks (mocha, jasmine), this plugin covers multiple BDD frameworks with generic rules.
Common errors
error Error: Cannot find module 'eslint-plugin-bdd' ↓
cause Package not installed or not in node_modules.
fix
Run npm install eslint-plugin-bdd --save-dev
error Configuration for rule "bdd/focus" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error ↓
cause Invalid severity value in ESLint config.
fix
Use 0, 1, 2 or 'off', 'warn', 'error' (as string) for rule severity.
error ESLint couldn't find the plugin "eslint-plugin-bdd". ↓
cause Plugin not listed in plugins array or package not installed.
fix
Add "bdd" to plugins array in .eslintrc and ensure package is installed.
Warnings
gotcha The plugin only provides two rules (focus and exclude). It does not cover all BDD anti-patterns or framework-specific features. ↓
fix Consider supplementing with framework-specific plugins for more comprehensive coverage.
gotcha The focus rule may produce false positives for legitimate test names containing 'fit' or 'fdescribe' as substrings. ↓
fix Use ESLint comment overrides or configure rule options if available. Check docs for regex options.
gotcha The exclude rule treats 'xit', 'xdescribe', etc. as errors, but these are sometimes intentionally used during development. ↓
fix Set rule severity to 'warn' or disable it during development.
Install
npm install eslint-plugin-bdd yarn add eslint-plugin-bdd pnpm add eslint-plugin-bdd Imports
- Plugin object
import plugin from 'eslint-plugin-bdd' // or const plugin = require('eslint-plugin-bdd') - Rules wrong
rules: { 'focus': 2 } // Missing plugin prefixcorrect// Configure rules in .eslintrc: rules: { 'bdd/focus': 2, 'bdd/exclude': 1 }
Quickstart
// .eslintrc.json
{
"plugins": ["bdd"],
"rules": {
"bdd/focus": "error",
"bdd/exclude": "warn"
}
}
// Example test file that will be flagged:
describe('suite', () => {
it('test', () => { /* ... */ });
fit('focused test', () => { /* ... */ }); // Error: focused test
});