Skip to content

Treat define calls like require#3830

Merged
j-f1 merged 4 commits intoprettier:masterfrom
salemhilal:require-define-same-line
Jan 29, 2018
Merged

Treat define calls like require#3830
j-f1 merged 4 commits intoprettier:masterfrom
salemhilal:require-define-same-line

Conversation

@salemhilal
Copy link
Contributor

See issue #3829. This commit keeps define calls as a unit when possible,
to prevent an extra indent in the body of an AMD-style define.

Rather than adding the "define" check in the same case as the existing
"require" check, I added a separate condition to explicitly call out the
fact that this checks for both AMD and CommonJS modules.

yarn test -u yields no changes, and yarn lint passes successfully.

See issue #3829. This commit keeps define calls as a unit when possible,
to prevent an extra indent in the body of an AMD-style define.

Rather than adding the "define" check in the same case as the existing
"require" check, I added a separate condition to explicitly call out the
fact that this checks for both AMD and CommonJS modules.

`yarn test -u` yields no changes, and `yarn lint` passes successfully.
Copy link
Member

@j-f1 j-f1 left a comment

Choose a reason for hiding this comment

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

Thanks for contributing to Prettier! Just one small question.

// e.g. `define(["some/lib", (lib) => {`
(!isNew &&
n.callee.type === "Identifier" &&
n.callee.name === "define") ||
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about moving this to the previous test?

(!isNew &&
  n.callee.type === "Identifier" &&
  (n.callee.name === "require" ||
    n.callee.name === "define"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that at first; I'm ambivalent there honestly. I ended up with this approach because it allows for a more obvious way to diverge CommonJs calls from AMD calls in the future. Lemme know and I'm down to move it to the previous test.

Copy link
Member

Choose a reason for hiding this comment

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

Let's move it into the previous test

@lydell
Copy link
Member

lydell commented Jan 26, 2018

Could you add your input from #3829 as a test?

This tests the solution for issue #3829.
@salemhilal
Copy link
Contributor Author

^ tests added

@@ -0,0 +1 @@
run_spec(__dirname, ["flow", "typescript"]);
Copy link
Member

Choose a reason for hiding this comment

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

Can you add babylon here?

@salemhilal
Copy link
Contributor Author

^ added babylon parser to the test.

@j-f1 j-f1 merged commit 8c79212 into prettier:master Jan 29, 2018
@j-f1
Copy link
Member

j-f1 commented Jan 29, 2018

Thanks for contributing to Prettier! 🎉

@salemhilal
Copy link
Contributor Author

Woo! Thank you.

@salemhilal salemhilal deleted the require-define-same-line branch January 29, 2018 22:01
@salemhilal
Copy link
Contributor Author

Hey, what's the release schedule like for prettier? I'm curious when this patch will be live (without having to checkout master).

@suchipi
Copy link
Member

suchipi commented Feb 8, 2018

We usually do a patch release every month or so, so it's around that time that we should do a new one.

@suchipi suchipi mentioned this pull request Feb 8, 2018
24 tasks
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants