-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[core] Simplify Prettier Scripts #13571
Conversation
That looks much tidier. 👍 |
I don't know why, but when I run prettier, it changes some files. It isn't to do with this PR though - it does it anyway. |
Could you add some time measurements for the old and new command? If I recall correctly this should be much slower because of prettier/prettier#4989. |
@eps1lon I did notice it was slow - thought it was just my machine, but a benchmark would be a good idea. |
Sadly my benchmark won't be a true representation as prettier is formatting the ignored files. If I run the |
What do you mean by different output? |
Prints material-ui-icons/src , node_modules and more. The yarn command behaves the same
Doesn't print node_modules but prints material-ui-icons/src and .next files etc.
Will print node_modules again and all the other files. |
For performance checks on my machine: Current Solution: Shortened Solution: Using CLI arguments: If I can get the find + grep combo working, I think that will be the best way forward as for the last benchmark I had to glob-ify the .eslintignore entries |
Although this isn't simpler real 0m42.088s |
@joshwooding $ time yarn prettier
...
real 0m22.638s
user 0m30.348s
sys 0m1.976s while 2f011dc produces: $ time yarn prettier
real 0m53.090s
user 0m49.044s
sys 0m14.468s And looking at the console output it seemingly freezes at some points which is most likely when prettier traverses the directories that are ignored. This was explained in #12564. I guess this is not much of an issue for CI since we only run on changed anyway but I wouldn't trade perf for "clean code" concerning DX. |
@eps1lon On Windows the current solution on master doesn't ignore the correct files for me. I should have mentioned that earlier, I was talking to @oliviertassinari about it on Gitter |
@eps1lon Can you tell me what |
$ cat .eslintignore | tr '\r\n' ' ' | tr -s ' ' ',' | xargs printf -- '!**/{%s}/**' | xargs node_modules/.bin/prettier --write "**/*.{js,d.ts,tsx}"
[error] No matching files. Patterns tried: **/*.{js,d.ts,tsx} !**/{/.git,/.next,/coverage,/docs/export,/examples/create-react-app*/src/serviceWorker.js,/examples/create-react-app-with-flow/flow,/examples/create-react-app-with-flow/flow-typed,/examples/gatsby/public,/flow,/flow-typed,/packages/material-ui-codemod/lib,/packages/material-ui-codemod/src/*/*.test,/packages/material-ui-codemod/src/*/*.test.js,/packages/material-ui-icons/src,/packages/material-ui-icons/fixtures,/packages/material-ui-icons/templateSvgIcon.js,/tmp,build,node_modules,}/** !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**
|
@eps1lon Can you delete the last empty line in .eslintignore and try again please |
I guess at this point it's better to use a glob library and programmatically run prettier instead of piping it through all sorts of cli tools. This would improve cross platform DX quite a bit I guess. |
I thought about programmatically running prettier, I can definitely take a look |
I believe the React project is programmatically running Prettier. |
They have their own script that runs prettier programmatically and is able to run on changed files only which is definitely something we might want to add. Not very good DX that you have to format the hole codebase when you're working on a feature branch. |
Superseded by #13621 |
I was having some issues with the prettier scripts printing errors to my console, so I simplified them and fixed the errors.