Skip to content

Conversation

@chentsulin
Copy link
Contributor

Introduction

Use prettier and husky + lint-staged precommit hook to auto format all of js, json files

Proposed solution

Follow @tgriesser's .prettierrc config and npm scripts in knex/knex#2697

@ricardograca
Copy link
Member

Nice work. I'll check it out ASAP and report back.

Copy link
Member

@crunchtime-ali crunchtime-ali left a comment

Choose a reason for hiding this comment

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

ok, thank you for clarifying.
Besides that the PR LGTM.

Copy link
Member

@ricardograca ricardograca left a comment

Choose a reason for hiding this comment

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

Finally, if you could change bracketSpacing to false I think it would help to cut down the number of lines touched by this PR.

Still, I'm not entirely convinced I prefer this over Standard.js, so can you explain its advantages and what the development workflow looks like with this? Do I have to install any IDE plugins? Run a script before committing?

.prettierrc Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer if this was set to "none". Also, can you set semi: false?

Copy link
Member

Choose a reason for hiding this comment

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

Wow. I really hate how the function arguments are split into individual lines like this. Makes no sense for such a small number of arguments. Is it possible to avoid this?

Copy link
Member

Choose a reason for hiding this comment

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

This is weird. Splitting a single line fat arrow function into multiple lines makes its intention a bit ambiguous: e.g. was it supposed to be returning something or was it supposed to return undefined? Did the author made a mistake?

Copy link
Member

Choose a reason for hiding this comment

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

This is definitely super weird 😕 Why is the options.patch in a single line by itself? Is there like a 80 column max line length limit or something?

Copy link
Member

@crunchtime-ali crunchtime-ali Sep 4, 2018

Choose a reason for hiding this comment

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

Yes, it wraps per default at 80 columns however you can set it via printWidth to a more reasonable amount. I suggest 120 columns. This should fix most of your aforementioned problems. How many columns do you suggest @ricardograca

Copy link
Member

Choose a reason for hiding this comment

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

👍 120 sounds good to me as well. 80 is definitely too narrow.

Copy link
Member

Choose a reason for hiding this comment

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

@chentsulin Can you please set printWidth: 120 and run prettier on the codebase again?

@chentsulin chentsulin force-pushed the prettier branch 2 times, most recently from c66d786 to e17aea3 Compare September 17, 2018 16:07
@chentsulin
Copy link
Contributor Author

Added those config:

"bracketSpacing": false,
"semi": false,
"printWidth": 120

@ricardograca
Copy link
Member

@chentsulin Can you address the last remaining comment above? I can do that after merging this, but I'd like to avoid several multi-thousand lines PRs if possible.

@chentsulin
Copy link
Contributor Author

@ricardograca

I set trailingComma to none, semi to true, those changes save ~4000 line changes.

Before:

2018-10-19 12 17 12

After

2018-10-19 12 22 09

@ricardograca
Copy link
Member

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants