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

[core] Make prettier run programmatically #13621

Merged

Conversation

joshwooding
Copy link
Member

@joshwooding joshwooding commented Nov 17, 2018

Continuation of #13571

Not sure where the scripts should live, looking to receive guidance :)

@joshwooding joshwooding changed the title [core] Make prettier run programmatically [WIP [core] Make prettier run programmatically [WIP] Nov 17, 2018
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks simpler :)

@oliviertassinari oliviertassinari changed the title [core] Make prettier run programmatically [WIP] [core] Make prettier run programmatically Nov 17, 2018
Copy link
Member

@eps1lon eps1lon left a 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.

const listChangedFiles = () => {
const mergeBase = execGitCmd(['merge-base', 'HEAD', 'master']);
return new Set([
...execGitCmd(['diff', '--name-only', '--diff-filter=ACMRTUB', mergeBase]),
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

.readFileSync('.eslintignore', 'utf-8')
.split(os.EOL)
.filter(notEmpty => notEmpty)
.map(file => `**/${file}/**`);
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

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

@joshwooding joshwooding force-pushed the programmatically-run-prettier branch from 595a9f6 to 2074ae8 Compare November 20, 2018 00:31
@oliviertassinari oliviertassinari force-pushed the programmatically-run-prettier branch from 4c19e3f to 757c590 Compare November 20, 2018 21:40
@oliviertassinari oliviertassinari merged commit 55c4c90 into mui:master Nov 20, 2018
@oliviertassinari
Copy link
Member

@eps1lon Well done with the review! It's even better than what the React team did :). @joshwooding 👌

@joshwooding
Copy link
Member Author

@eps1lon Thanks for your assistance 🥇

@joshwooding joshwooding deleted the programmatically-run-prettier branch November 20, 2018 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants