BDD Lint VS Code Extension
A minimal VS Code extension that runs the bdd-lint CLI on the currently open .feature file and shows results in an output channel.
About bdd-lint
bdd-lint is a linter for Behave BDD scenarios, enforcing grammar and best practices. It supports all major rules from gherkin-lint, custom configuration, user-defined rules, and flexible output formats.
Key Features
- Runs
bdd-lint on open .feature files in VS Code.
- Highlights grammar and best-practice issues directly in your editor.
- Supports all major rules from gherkin-lint:
- Past, present, and future tense checks for Given/When/Then.
- Scenario structure and naming rules.
- Duplicate and consistency checks.
- Tag and keyword formatting.
- Custom rule support.
- Custom configuration via
.bdd-lint.yml and CLI options.
How the Extension Works
- The extension calls the
bdd-lint console script.
- Make sure
bdd-lint is available in your PATH or workspace Python environment (e.g., install with pip install bdd-lint).
- The command registered is
bdd-lint.run, which you can execute from the command palette or bind to a key.
Usage
- Install
bdd-lint in your Python environment:
pip install bdd-lint
- Open a
.feature file in VS Code.
- Run the command
bdd-lint: Run on feature file from the command palette (Ctrl+Shift+P).
The extension will display lint results in a dedicated output channel.
Supported Rules
Some example rules enforced by bdd-lint:
- GivenPastTenseRule, WhenPresentTenseRule, ThenFutureTenseRule
- OneWhenThenRule, ThirdPersonRule, TenseConsistencyRule
- NoEmptyScenariosRule, NoUnnamedFeaturesRule, NoDuplicateScenariosRule, etc.
- See the bdd-lint documentation for the full list.
Configuration
To customize which rules are enabled and their options, add a .bdd-lint.yml file to your project root:
rules:
GivenPastTenseRule: true
MaxScenariosPerFileRule: true
options:
MaxScenariosPerFileRule:
max_scenarios: 5
You can also run the CLI with a custom config:
bdd-lint path/to/feature_file.feature --config custom_config.yml
Custom Rules
Create your own rule Python files in the custom_rules/ directory of your project.
Example rule:
from bdd_lint.rules.base_rule import BaseRule
class MyCustomRule(BaseRule):
def check(self, scenario):
# Custom logic
return []
Extension Development & Publishing
- Install
vsce (VS Code packaging/publishing tool):
npm install -g vsce
- Update
package.json (publisher and version).
- Package the extension:
vsce package
- Publish to the Marketplace:
vsce publish
License
MIT
For more details on rules, configuration, and custom rules, see the main bdd-lint documentation.