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

use prettier to format all of js,json files #1883

Merged
merged 1 commit into from Oct 19, 2018

Conversation

Projects
3 participants
@chentsulin
Copy link
Contributor

chentsulin commented Aug 21, 2018

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 tgriesser/knex#2697

@ricardograca

This comment has been minimized.

Copy link
Member

ricardograca commented Aug 21, 2018

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

@ricardograca ricardograca added this to To Do in Version 0.14.0 via automation Aug 21, 2018

@ricardograca ricardograca moved this from To Do to In progress in Version 0.14.0 Aug 21, 2018

Show resolved Hide resolved package.json
@dj-hedgehog
Copy link
Member

dj-hedgehog left a comment

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

@ricardograca
Copy link
Member

ricardograca left a comment

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
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5",

This comment has been minimized.

@ricardograca

ricardograca Sep 3, 2018

Member

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

iterator,
initialValue,
context
) {

This comment has been minimized.

@ricardograca

ricardograca Sep 3, 2018

Member

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?

Show resolved Hide resolved lib/base/collection.js
const args = Array.from(arguments);

return Promise.mapSeries(listeners, listener => listener.apply(this, args.slice(1)));
return Promise.mapSeries(listeners, (listener) =>
listener.apply(this, args.slice(1))

This comment has been minimized.

@ricardograca

ricardograca Sep 3, 2018

Member

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?

throw new TypeError(`Cannot accept incompatible options: method=insert, patch=${options.patch}`);
throw new TypeError(
`Cannot accept incompatible options: method=insert, patch=${
options.patch

This comment has been minimized.

@ricardograca

ricardograca Sep 3, 2018

Member

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?

This comment has been minimized.

@dj-hedgehog

dj-hedgehog Sep 4, 2018

Member

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

This comment has been minimized.

@ricardograca

ricardograca Sep 4, 2018

Member

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

This comment has been minimized.

@dj-hedgehog

dj-hedgehog Sep 4, 2018

Member

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

Show resolved Hide resolved lib/base/model.js
Show resolved Hide resolved lib/base/model.js Outdated
Show resolved Hide resolved lib/bookshelf.js

@chentsulin chentsulin force-pushed the chentsulin:prettier branch 2 times, most recently from c66d786 to e17aea3 Sep 17, 2018

@chentsulin

This comment has been minimized.

Copy link
Contributor

chentsulin commented Sep 17, 2018

Added those config:

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

This comment has been minimized.

Copy link
Member

ricardograca commented Oct 17, 2018

@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 chentsulin force-pushed the chentsulin:prettier branch from e17aea3 to 46cdecb Oct 19, 2018

@chentsulin

This comment has been minimized.

Copy link
Contributor

chentsulin commented Oct 19, 2018

@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

This comment has been minimized.

Copy link
Member

ricardograca commented Oct 19, 2018

Many thanks!

@ricardograca ricardograca merged commit 7a49f0e into bookshelf:master Oct 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

Version 0.14.0 automation moved this from In progress to Done Oct 19, 2018

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