Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-gherkin

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-gherkin - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

6

CHANGELOG.md
# CHANGELOG
## 1.1.0
- handle "language" comment
- fix missing mediaType in json / xml embedded docstring
- fix missing example description
## 1.0.0
Version 1.0.0 is a complete rewrite of the [first version](https://github.com/armandabric/prettier-plugin-gherkin) by [@armandabric](https://github.com/armandabric).

11

dist/index.js

@@ -8,2 +8,4 @@ "use strict";

const DEFAULT_ESCAPE_BACKSLASH = false;
// taken from https://github.com/cucumber/gherkin-javascript/blob/e25a1be3b21133c7a92eb7735997c6e774406226/src/GherkinClassicTokenMatcher.ts#L11
const LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/;
const { literalline, hardline, join, group, trim, indent, line } = prettier_1.doc.builders;

@@ -295,3 +297,7 @@ const { hasNewline, isPreviousLineEmpty, makeString } = prettier_1.util;

else if (node instanceof GherkinAST_1.TypedFeature || node instanceof GherkinAST_1.TypedRule) {
const hasLanguageInSourceFile = !!options.originalText.match(new RegExp(LANGUAGE_PATTERN, 'm'));
return [
node instanceof GherkinAST_1.TypedFeature && hasLanguageInSourceFile
? ['# language: ' + node.language, printHardline()]
: '',
printTags(path, node),

@@ -395,3 +401,3 @@ `${node.keyword}: ${node.name}`,

return join(printHardline(), [
`${node.delimiter}${node.mediaType || ''}`,
[node.delimiter, node.mediaType || ''],
// split the string on newlines to preserve the indentation

@@ -409,2 +415,3 @@ ...escapeDelimiter(node.content).split('\n'),

printHardline(),
printDescription(path, node, false),
join(printHardline(), [

@@ -451,2 +458,3 @@ // @ts-expect-error TODO path should be recognized as an AstPath<TypedExamples>

node.delimiter,
mediaType,
printHardline(),

@@ -461,2 +469,3 @@ textToDoc(content, Object.assign(Object.assign({}, options), { parser: 'html' })),

node.delimiter,
mediaType !== null && mediaType !== void 0 ? mediaType : '',
printHardline(),

@@ -463,0 +472,0 @@ textToDoc(content, Object.assign(Object.assign({}, options), { parser: 'json' })),

2

package.json
{
"name": "prettier-plugin-gherkin",
"version": "1.0.0",
"version": "1.1.0",
"description": "This prettier plugin format your gherkin (`.feature` files) documents.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -51,2 +51,5 @@ import {

// taken from https://github.com/cucumber/gherkin-javascript/blob/e25a1be3b21133c7a92eb7735997c6e774406226/src/GherkinClassicTokenMatcher.ts#L11
const LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/;
const { literalline, hardline, join, group, trim, indent, line } = doc.builders;

@@ -470,3 +473,10 @@ const { hasNewline, isPreviousLineEmpty, makeString } = util;

} else if (node instanceof TypedFeature || node instanceof TypedRule) {
const hasLanguageInSourceFile = !!options.originalText.match(
new RegExp(LANGUAGE_PATTERN, 'm')
);
return [
node instanceof TypedFeature && hasLanguageInSourceFile
? ['# language: ' + node.language, printHardline()]
: '',
printTags(path, node),

@@ -580,3 +590,3 @@ `${node.keyword}: ${node.name}`,

return join(printHardline(), [
`${node.delimiter}${node.mediaType || ''}`,
[node.delimiter, node.mediaType || ''],
// split the string on newlines to preserve the indentation

@@ -591,7 +601,7 @@ ...escapeDelimiter(node.content).split('\n'),

printTags(path, node),
`${node.keyword}: ${node.name}`,
`${node.keyword}: ${node.name}`,
indent([
printHardline(),
printDescription(path, node, false),
join(

@@ -640,2 +650,3 @@ printHardline(),

node.delimiter,
mediaType,
printHardline(),

@@ -652,2 +663,3 @@ textToDoc(content, { ...options, parser: 'html' }),

node.delimiter,
mediaType ?? '',
printHardline(),

@@ -654,0 +666,0 @@ textToDoc(content, { ...options, parser: 'json' }),

@@ -50,2 +50,4 @@ // source: https://github.com/prettier/prettier/blob/ee2839bacbf6a52d004fa2f0373b732f6f191ccc/tests_config/run_spec.js

).toMatchSnapshot();
// expect(input.replace(/\s/g, '')).toBe(output.replace(/\s/g, ''));
});

@@ -52,0 +54,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc