mapado / prettier-plugin-gherkin

This prettier plugin format your gherkin (`.feature` files) documents.
MIT License
18 stars 5 forks source link

Issue with handling comments in the same line as tag #26

Closed illyakurochkin closed 4 months ago

illyakurochkin commented 4 months ago

If the .feature includes a comment in the same line with a tag, prettier --write removes the comment.

Example input:

@wip # this test will be resolved as part of ABC-123 ticket

Example output:

@wip

If the comment is places in a separate line, it's not getting removed.

jdeniau commented 4 months ago

Hi,

After checking at the spec, it does sais that

Comments are only permitted at the start of a new line, anywhere in the feature file.

I tried to make it work nevertheless, but the gherkin parser filter. Using the following file

@test # comment on tag
Feature: test

the parser does give me this :

{
  uri: undefined,
  feature: TypedFeature {
    location: { line: 2, column: 1 },
    tags: [ [
      TypedTag {
        location: [ { line: 1, column: 1 } ],
        name: '@test',
        id: 'c8da8ee6-006f-477d-9288-09535e33fe0d'
      }
    ] ],
    language: 'en',
    keyword: 'Feature',
    name: 'test',
    description: '',
    children: []
  }
}

It does "work" when you set the comment elsewhere (ex: Feature: test # comment), because the comment is included in the text (the feature name would be test # comment)

The comments is filtered by the parser, so I can not anything about it, but I think that you should respect the spec and not set a comment on new lines only.