npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prettier-plugin-gherkin

v3.1.0

Published

This prettier plugin format your gherkin (`.feature` files) documents.

Downloads

148,843

Readme

prettier-plugin-gherkin

This prettier plugin format your gherkin (.feature files) documents.

Example of changes:

@accountability @accountability-json
Feature: accountability
    accounts should always be good
    @truncateTables
    Scenario: Check accountability
        # Insert fixtures
        Given the following fixtures files are loaded:
            | 10.contracts.yml            |
            | 20.wallet.yml               |
            | 30.tax.yml |

        Given I inject the header "authorization" with value 'Bearer some-token'

        And I inject the header "accept" with value "application/json"

# I will create an order here
        Given I create an order
            Then the response status code should be 200
            When I pay the latest order
        And I refund the last payment and transaction list with transactions:
                """
            [{"name": "card",
                    "credit": 5000
                }
            ]
            """

Will be formatted to:

@accountability
@accountability-json
Feature: accountability
    accounts should always be good

    @truncateTables
    Scenario: Check accountability
        # Insert fixtures
        Given the following fixtures files are loaded:
            | 10.contracts.yml |
            | 20.wallet.yml    |
            | 30.tax.yml       |

        Given I inject the header "authorization" with value 'Bearer some-token'
        And I inject the header "accept" with value "application/json"

        # I will create an order here
        Given I create an order
        Then the response status code should be 200

        When I pay the latest order
        And I refund the last payment and transaction list with transactions:
            """
            [{ "name": "card", "credit": 5000 }]
            """

Versions

This version is compatible with prettier 3. If you still use prettier 2, you should use the 1.1.1 version of this plugin.

Installation

Install prettier if you don't have already.

npm install --save prettier-plugin-gherkin

// or with yarn
yarn add prettier-plugin-gherkin

Activate the plugin in your prettier configuration file:

.prettierrc

  {
+     "plugins": ["prettier-plugin-gherkin"]
  }

You can then configure your git precommit, IDE, etc. to format the .features file with prettier.

Example with VSCode

https://user-images.githubusercontent.com/1398469/201128147-ad2ecba8-253d-4c70-9133-ae28d178ed2b.mp4

Options

This plugin has the following options:

forceNewlineBetweenStepBlocks (default: false)

Do force a blank linesbetween steps block:

Given the following block:

Given some context
And some other context
When I do something
Then I should have a result

The default output will be the same as the input (no blank lines).

If you set this option to true, it will force a blank line between the context block and the action block:

Given some context
And some other context

When I do something
Then I should have a result

If you already have a blank line in your input, it will be kept as-is (event with this option set to false). If you have more than one blank line, it will be reduced to a single blank line.

escapeBackslashes

default to false

If false, all escaped backslash will be transformed to simple backslash : \\\ If true, all backslash will be espaced : \\\

This option may be due to the parser (see issue) and is here because of an inconsistence between the gherkin reference, that said that:

if you need a \, you can escape that with \\.

and the tooling that accept unescaped \, including the cucumber parser used under the hood.

You may want to check your code base and be consistent : if you use simple backslash, keep the default option, if you escape all backslash, then set this option to true.

Documentation

Prettier plugin documentation

Gherkin AST schema

Gherkin AST schema

Useful resources on Gherkin language

Contributing to this plugin

Clone the repository and install dependencies:

git clone [email protected]:mapado/prettier-plugin-gherkin.git
cd prettier-plugin-gherkin
yarn install

Several commands are available:

yarn example # print the example file with the plugin. You can change de content of the example file as you need
yarn test # run the tests suites : all features are tested
yarn lint # the plugin is writter in TypeScript, this command will help you detect typescript issue

Test datas

Test datas can be found here : https://github.com/cucumber/gherkin-utils/tree/c35857189c2da3a9b84796ad585d25e70f7bf3b8/testdata