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

Should we use Prettier? #7

Open
segayuu opened this issue Apr 20, 2018 · 13 comments
Open

Should we use Prettier? #7

segayuu opened this issue Apr 20, 2018 · 13 comments
Assignees

Comments

@segayuu
Copy link
Contributor

segayuu commented Apr 20, 2018

eslint has nearly 90 rules even for category Stylistic Issues alone.
It is very difficult to handle all these correctly.

Because eslint understands that, if you activate only recommended settings, required items in most projects will be set. However, Stylistic Issues often depends on individuality, the recommended config is no-mixed-spaces-and-tabs only.

By using Prettier it is certain that almost all of those settings will be unified.
However, that is a tradeoff with fewer things we can explicitly control.
In fact, the multi-line option of the curly rule will be disabled with Prettier!

@segayuu
Copy link
Contributor Author

segayuu commented Apr 20, 2018

I talked a little while ago about this issue.
hexojs/hexo#2846

@JLHwung
Copy link
Contributor

JLHwung commented Apr 21, 2018

I prefer to take a full prettier format on the existing code.

However, it is pretty tedious and error-prone to add different versions of prettier/husky/lint-staged to the existing projects. Actually we have suffered from outdated eslint config on less frequently updated package.

It comes to me that lerna can reduce these maintenance nightmare if we switch to monorepo so that all hexo packages shares eslint/babel/prettier/lint-staged settings.

@segayuu
Copy link
Contributor Author

segayuu commented Apr 21, 2018

If you do monorepo and organize the registry, you should also consider using npm scoped package.
I think that should not be done at the same time.

When doing them, at least we should inform this to all Hexo maintainers.

@JLHwung
Copy link
Contributor

JLHwung commented Apr 21, 2018

The npm scoped package is definitely nice to have but it is breaking change for users. As we have separated hexo packages in the very early days, from the users perspective, it is not persuading to change hexo-* to @hexo/* without a stronger reason, like performance boost/less bugs/major rewrite.

Additionally, the monorepo and scoped npm package is independent.

When doing them, at least we should inform this to all Hexo maintainers.

Good idea, could you raise a discussion on the main repo?

@segayuu
Copy link
Contributor Author

segayuu commented Apr 21, 2018

ok, For each member of @hexojs/core, we set up a discussion thread.

@thom4parisot
Copy link
Member

It can be quite a nice move to find the right setup of prettier on this repo first before even trying to scale it to a larger amount of repos.

Prettier has some nice commits hooks where it can only be applied to changed lines.

That can be replicated bit by bit to other repos and see how much pain/benefits it generates before thinking to move to monorepo (this brings its own bagage of discussions/painpoints without solving the prettier problem).

@segayuu
Copy link
Contributor Author

segayuu commented Apr 21, 2018

@oncletom Is the hook you are talking about precise-commits? (Since there are multiple hooks, I will confirm it just in case.)

@thom4parisot
Copy link
Member

@segayuu yes exactly. I have tried this one and the plain git command.

But the latter is not cross-compatible between OSes.

@tcrowe
Copy link

tcrowe commented Jul 19, 2018

Yes please use prettier 👍

@tcrowe
Copy link

tcrowe commented Jul 19, 2018

@demurgos
Copy link

demurgos commented Jul 19, 2018

I don't have any strong opinion about the actual linter, as long as the style used is uniform across the project. (You can keep eslint or switch to prettier, as long as the same rules are enforce everywhere).

I'm not comfortable with lerna and monorepos for JS (seems to be at odds with Node's way of doing things). To help with maintaining dependencies up to date, you can look into integrating "Greenkeeper". I'm only an occasional maintainer so I have no strong opinions on this either.

@tcrowe
Copy link

tcrowe commented Jul 19, 2018

@demurgos Prettier integrates into ESLint so ESLint parses and validates it while the Prettier plugin does the formatting.

I would like to see this happen and most of the rules having to do with formatting can be removed.

@segayuu If you want to do some experiments we can work on a branch together and then run these rules on various hexo repos and see what would change, if anything.

@segayuu
Copy link
Contributor Author

segayuu commented Jul 20, 2018

In #10 we added eslint-plugin-prettier.

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

6 participants