Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A missing prettier formatter is silently ignored #111

Closed
sschuberth opened this issue May 12, 2024 · 6 comments
Closed

A missing prettier formatter is silently ignored #111

sschuberth opened this issue May 12, 2024 · 6 comments

Comments

@sschuberth
Copy link

Describe the bug

Generated files under "requests" have tabs instead of spaces although prettier is configured otherwise.

To Reproduce

I have a .prettierrc with

{
    "useTabs": false
}

and run openapi-rq -i http://localhost:8080/swagger-ui/api.json -o src/api --format prettier.

The generated *.ts files have tabs instead of spaces.

OpenAPI spec file

n/a

Expected behavior

Spaces instead of tabs should be used according to the prettier configuration.

Additional context

  • OS: Fedora Linux 40
  • Version 1.3.0
@sschuberth
Copy link
Author

sschuberth commented May 12, 2024

Ok, seems like the problem simply was that prettier was not installed. Manually installing it and rerunning openapi-rq fixes the problem.

Would it be possible to either:

  • install prettier automatically if configured as a formatter but not present yet on the system, or
  • warn / error out if prettier is configured but not present?

Same for Biome, I guess.

@sschuberth sschuberth changed the title Using prettier as a formatter seems to have no effect A missing prettier formatter is silently ignored May 12, 2024
@seriouslag
Copy link
Collaborator

This you for opening an issue.

This library passes the values provided to @hey-api/openapi-ts to run the formatting.

It would/could become a maintenance burden to add the checks in this library, opening a ticket in @hey-api/openapi-ts package may be helpful.

I personal do not believe a cli command should install a package automatically.

A console warning would be good.

@seriouslag
Copy link
Collaborator

I am starting to believe we should remove the options for consumers to interface with the format and linter options as this library's generated code will be covered. And change in the underlying service generators formatted would have to maintained in this libraries. Feels hard to maintain. Would be consistent for the consumer to run their own linter and formatted after generating the files.

@7nohe
Copy link
Owner

7nohe commented May 18, 2024

I am starting to believe we should remove the options for consumers to interface with the format and linter options as this library's generated code will be covered. And change in the underlying service generators formatted would have to maintained in this libraries. Feels hard to maintain. Would be consistent for the consumer to run their own linter and formatted after generating the files.

I completely agree with you.
I think it will also be challenging to keep up with future changes in both Prettier and Biome.

@sschuberth
Copy link
Author

sschuberth commented May 18, 2024

I completely agree with you.

For the record, I agree as well, and we have already switched from using the --format to running prettier as a post-processing step.

@sschuberth
Copy link
Author

So, given that I believe no work is planned to address this as instead the --format option is going to be removed, let me close this.

@sschuberth sschuberth closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants