Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
prettier-plugin-gherkin
Advanced tools
This prettier plugin format your gherkin (`.feature` files) documents.
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 }]
"""
This version is compatible with prettier 3. If you still use prettier 2, you should use the 1.1.1 version of this plugin.
Install prettier if you don't have already.
npm install --save prettier-plugin-gherkin
// or with yarn
yarn add prettier-plugin-gherkin
That's all ! the plugin will be automatically detected by prettier.
You can then configure your git precommit, IDE, etc. to format the .features
file with prettier.
https://user-images.githubusercontent.com/1398469/201128147-ad2ecba8-253d-4c70-9133-ae28d178ed2b.mp4
This plugin has a single options:
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 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
.
Gherkin AST schema
Clone the repository and install dependencies:
git clone git@github.com: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 can be found here : https://github.com/cucumber/gherkin-utils/tree/main/testdata
[2.0.0] - 2023-08-31
Handle prettier 3. Prettier 2 is not compatible with this version as the plugin API did change totally.
Prettier 3 remove plugin auto-detection, so you now need to active the plugin explicitly:
package.json
- "prettier": "^2.0.0",
- "prettier-plugin-gherkin": "^1.0.0",
+ "prettier": "^3.0.0",
+ "prettier-plugin-gherkin": "^2.0.0",
.prettierrc
{
+ "plugins": ["prettier-plugin-gherkin"]
}
(maybe) drop support for node 14: prettier 3 does still support node 14, but it is unmaintained, and the tests does not pass on node 14 only. If you are willing to spend some time on this, feel free to open a PR, but I suggest you to migrate to a more recent version of node. #9 by @jdeniau
FAQs
This prettier plugin format your gherkin (`.feature` files) documents.
The npm package prettier-plugin-gherkin receives a total of 33,227 weekly downloads. As such, prettier-plugin-gherkin popularity was classified as popular.
We found that prettier-plugin-gherkin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.