Skip to content

apply prettier #382

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

Merged
merged 3 commits into from
Nov 26, 2020
Merged

apply prettier #382

merged 3 commits into from
Nov 26, 2020

Conversation

jankuca
Copy link
Contributor

@jankuca jankuca commented Nov 23, 2020

I've noticed prettier is not being followed. This PR formats all JS/TS files according to the prettier config and removes YAML files from the prettier scope as it was apparently not being used for such files at all.

@drwpow
Copy link
Contributor

drwpow commented Nov 26, 2020

Thanks! I think for the expected/* files, those were actually correct before because they use the default Prettier setup. However, the internal code for this project uses a customized Prettier setup, which you did correctly identify was not being applied to jest.config.js.

I’d be OK with adding *.yaml files being ignored by Prettier, however, notice that the tests are failing—that’s because your changes to the generated files are now incorrectly formatted.

I’m in favor of this change if you revert the tests/**.ts and examples/*.ts changes. If you don’t believe me, run yarn build && ./pkg/bin/cli.js [path to YAML] -o [output] locally and you’ll see that they will be generated exactly as they were before, with the default Prettier config.

@jankuca
Copy link
Contributor Author

jankuca commented Nov 26, 2020

Since there was no .prettierignore, I think it is reasonable to expect running yarn prettier -w . would lead to the correct result; VSCode even formatted these files automatically on edit/save for me.

I think that all files which should not follow the project-specific prettier config should be listed in the .prettierignore. (I will add it, didn't really know which files to list but the YAML files seemed wrong immediately.)

It's weird though that the tests were passing locally but I guess a rebase which removed code for #381 messed it up.

@codecov
Copy link

codecov bot commented Nov 26, 2020

Codecov Report

Merging #382 (cd41e92) into main (e73e0d3) will increase coverage by 0.52%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #382      +/-   ##
==========================================
+ Coverage   92.91%   93.43%   +0.52%     
==========================================
  Files           5        5              
  Lines         268      259       -9     
  Branches       90       84       -6     
==========================================
- Hits          249      242       -7     
  Misses         13       13              
+ Partials        6        4       -2     
Impacted Files Coverage Δ
src/index.ts 81.81% <50.00%> (ø)
src/property-mapper.ts 84.21% <50.00%> (ø)
src/v2.ts 84.61% <87.50%> (+0.89%) ⬆️
src/v3.ts 96.89% <93.54%> (+0.63%) ⬆️
src/utils.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75fed40...cd41e92. Read the comment docs.

@jankuca
Copy link
Contributor Author

jankuca commented Nov 26, 2020

Ok, fixed. I've also added a yarn format script which runs prettier.

@jankuca
Copy link
Contributor Author

jankuca commented Nov 26, 2020

Now I'm thinking whether the .prettierignore affects the prettier runs which should use the default config. The tests are passing but can you check if this is alright?

tests/*/generated/**/*.ts
*.md
*.yaml
*.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thanks for adding these 👍🏻

@drwpow
Copy link
Contributor

drwpow commented Nov 26, 2020

Now I'm thinking whether the .prettierignore affects the prettier runs which should use the default config. The tests are passing but can you check if this is alright?

This is great! Thanks for doing this 🙏🏻

Now I'm thinking whether the .prettierignore affects the prettier runs which should use the default config.

To my knowledge, no, they shouldn’t be. We’re using Prettier’s Node API, so that should be theoretically not be paying attention to any config files in the filesystem, unless someone explicitly passes in --prettier-config. But if you find this is not the case please let me know!

@drwpow drwpow merged commit e8ba16f into openapi-ts:main Nov 26, 2020
@jankuca jankuca deleted the apply-prettier branch November 27, 2020 09:13
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

Successfully merging this pull request may close these issues.

2 participants