prettier-plugin-gherkin

raw JSON →
3.1.3 verified Sat Apr 25 auth: no javascript

A Prettier plugin that formats Gherkin (.feature) files used by Cucumber and BDD frameworks. The current stable version is 3.1.3, compatible with Prettier 3 (use 1.1.1 for Prettier 2). It enforces consistent indentation, table cell alignment, and spacing in feature files. Differentiators include options like `forceNewlineBetweenStepBlocks` and `escapeBackslashes`, and it integrates seamlessly with Prettier's existing configuration and editor plugins.

error Cannot find module 'prettier-plugin-gherkin'
cause The plugin is not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-gherkin.
error TypeError: Cannot read properties of undefined (reading 'format')
cause Trying to import the plugin directly instead of using it via Prettier's plugins array.
fix
Do not import the plugin in code. Add it to your Prettier configuration's 'plugins' array.
error prettier-plugin-gherkin: Plugin `prettier-plugin-gherkin` could not be loaded.
cause Version mismatch (plugin requires Prettier 3, but Prettier 2 is installed).
fix
Upgrade Prettier to 3: npm install --save-dev prettier@^3.0.0 or install plugin version 1.1.1.
breaking Version 2.x dropped support for Prettier 2; plugin requires Prettier 3.
fix Use plugin version 1.1.1 if still on Prettier 2, or upgrade Prettier to 3.
gotcha The plugin does not handle all Gherkin dialects/extensions; custom tags or keywords may be reformatted unexpectedly.
fix Test formatting on your feature files and disable the plugin for files with non-standard syntax.
gotcha Options `forceNewlineBetweenStepBlocks` and `escapeBackslashes` only apply if set; defaults may not match team conventions.
fix Explicitly configure these options in .prettierrc to avoid surprises.
deprecated No deprecation warnings known yet.
npm install prettier-plugin-gherkin
yarn add prettier-plugin-gherkin
pnpm add prettier-plugin-gherkin

Shows installation via npm and minimal Prettier configuration to activate the plugin and set options.

// Install: npm install --save-dev prettier prettier-plugin-gherkin
// .prettierrc
{
  "plugins": ["prettier-plugin-gherkin"],
  "forceNewlineBetweenStepBlocks": true,
  "escapeBackslashes": false
}