-
Notifications
You must be signed in to change notification settings - Fork 122
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
Pretty printed code #507
Pretty printed code #507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I just was thinking, should we make what you recommend (make the format command run as pre-commit) part of this PR?
@matteofigus yes, just wanted to make sure we all liked prettier output first :) TODO:
|
@mattiaerre @matteofigus one thing that we should also remove is running eslint before testing now, as we will automatically run it with --fix together with prettier. Thoughts? |
eslint in CI checks with a clean npm install, which is something I can't guarantee the user has when doing the commit. I think we should leave it here, as it's cheap and free to use. |
2b34e7a
to
bd60b56
Compare
bd60b56
to
aa7a9a8
Compare
Ideal workflow:
The user shouldn't worry to much about formatting the code according to your opinions, and you want to be sure that everything is commited as you wanted. As you are running eslint --fix, testing against it shouldn't be necessary anymore. That's why I think we could remove it from the grunt test task. @kentcdodds am I missing something or does this make sense ? I'm trying to understand how we could add prettier in our workflow here... |
Sounds right to me. Important to note that if you want to do a partial commit of a file you'll want to run that with |
Indeed! thank you so much for the feedback and for |
Hey sorry for the delay, I've been out these days. Answering what @nickbalestra asked when opening the PR, of course it can be reduced. Remember that I used the eslint generator for that first step and, as I said then, many of the rules should be verified. Specially now that you're adding prettier, as many of that rules where related to coding style. Moreover, eslint rules can extend other rules. So, another way to significantly reduce the eslint file size could be search for a configuration that fits our needs (or the majority of them) and extend from it. |
Thank you for the input @elboletaire! Feel free to suggest any thing you might consider we want to clean from them as w moving forward with this. |
Once this land in master, would be nice to add OpenTable to this -> prettier/prettier#1351 |
grunt.registerTask('sauce', [ | ||
'karma:sauce-linux', | ||
'karma:sauce-osx', | ||
'karma:sauce-windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd encourage to add the dangling comma, as it's a good practice when using source control (adding it won't show a modified line every time we add a line to an array/object).
But this is something should be discussed, I guess (that's why I'm not setting this as a review comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was already like that, so didn't want to modify any of our rules with this PR.
But totally, we could definitely discuss all of those one-by-one so please feel free to lead the effort with issues/pr in this direction so that we can discuss each of those improvements. Thanks for that!
"load-grunt-tasks": "^3.5.2", | ||
"mocha": "^3.0.2", | ||
"phantomjs-prebuilt": "^2.1.12", | ||
"prettier-eslint-cli": "^4.0.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nickbalestra now that we have prettier-eslint-cli and removed eslint directly from the grunt task, shouldn't we remove grunt-eslint as dev dependency, including its own /tasks file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we want to leave it as utility for development
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think make sense to remove it (also help a little toward moving to a gruntless world).
You could now run prettier-eslint
instead if you want for developement
@matteofigus @elboletaire should be good to go now. |
Initial PR to check out prettier.
The following PR use prettier-eslint to pipe code through prettier->eslint--fix to format code. Meaning that eslint will be run last allowing for a final override of the prettier output.
I see we have quite a big eslintrc file, I guess it could be a bit more minimal perhaps? What do you think @elboletaire ?
Following steps could be:
lint-staged
together withhusky
for a totally invisible/painless workflow. I've been using it with prettier as suggested and its pretty awesome.@MicheleBertoli would love to hear your thoughts in hooking prettier with eslint in here
cc @mattiaerre @matteofigus