Skip to content

Remove trailing whitespace from comments #3922

Open
@LinusU

Description

@LinusU

Describe the bug

A recent version of the code generator started adding comments to the fields, this is great!

However, if the comment contained a blank line, the generator will add a single space at the end of that line. This is probably because every line is indented by a single space.

This leads to the following warnings when adding the file with git:

<stdin>:201: trailing whitespace.
   * 
<stdin>:221: trailing whitespace.
   * 
<stdin>:224: trailing whitespace.
   * 
warning: 3 lines add whitespace errors.

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:
type Foo {
    """
    This is the first line of the documentation, it will be followed by an empty line.

    Here is the last line, there is an empty line in between.
    """
    bar: String
}
  1. My GraphQL operations:
n/a
  1. My codegen.yml config file:
overwrite: true
schema: http://localhost:4000/graphql
generates:
  src/types.ts:
    plugins:
      - "typescript"

Expected behavior

I expected there to not be a trailing space on those lines.

Environment:

  • OS: macOS 10.15.4
  • @graphql-codegen/...:
    "@graphql-codegen/cli": "^1.13.3",
    "@graphql-codegen/typescript": "^1.13.3",
    "@graphql-codegen/typescript-resolvers": "^1.13.3",
  • NodeJS: v12.12.0

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions