-
-
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] Make prettier run programmatically #13621
[core] Make prettier run programmatically #13621
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.
This looks simpler :)
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 really like this. CLI usage becomes very unwieldy with advanced usage patterns.
scripts/listChangedFiles.js
Outdated
const listChangedFiles = () => { | ||
const mergeBase = execGitCmd(['merge-base', 'HEAD', 'master']); | ||
return new Set([ | ||
...execGitCmd(['diff', '--name-only', '--diff-filter=ACMRTUB', mergeBase]), |
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.
We need to use the rev-parse
approach that was used in the CI script or else this script won't be able to pick up changed files.
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.
This works for me? the rev-parse
approach and the approach above produce the same results. I've changed it to rev-parse
just for consistency purposes
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.
To be more specific it won't be able to pick up changes in CI as you can see in previous builds on this branch. CircleCI is doing some weird reset --hard stuff that they never explained when asked about so a simple diff against master won't work.
Although it's picking up additional files (probably because the branch is not up to date with master). Might need some further investigation.
scripts/prettier.js
Outdated
.readFileSync('.eslintignore', 'utf-8') | ||
.split(os.EOL) | ||
.filter(notEmpty => notEmpty) | ||
.map(file => `**/${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.
Why do we need this? I would prefer if eslintignore behaves the same for eslint and prettier.
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.
Glob doesn't work with file paths but I've made the code a bit smarter here it checks to see if it needs to add anything rather than just blanket appending a prefix and suffix
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.
According to https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories it is using node-ignore
. I think we should use that also to be consistent
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’ll have a look at using glob-gitignore
595a9f6
to
2074ae8
Compare
59dda20
to
4c19e3f
Compare
4c19e3f
to
757c590
Compare
@eps1lon Well done with the review! It's even better than what the React team did :). @joshwooding 👌 |
@eps1lon Thanks for your assistance 🥇 |
Continuation of #13571
Not sure where the scripts should live, looking to receive guidance :)