eed53fc29a36a0d045a3768e1aba2f61cb5b593a
* Add additional binary expression comment tests Refs #3806 These cover a few edge cases I encountered while maintaining `@btmills/prettier` over the last few years. I'm adding them up front to demonstrate that the `experimentalOperatorPosition` changes in a later commit have no effect on this formatting when the flag is not enabled. * Define experimentalOperatorPosition flag Refs #3806 This merely defines the flag. A future commit will use it in updated logic. * Add experimentalOperatorPosition default tests Right now, this flag isn't implemented, so these tests duplicate the existing behavior. I'm adding them now so that when I implement the flag's logic in a future commit, the changed formatting will be obvious in the diff and easier to review. * Implement experimentalOperatorPosition flag Fixes #3806 as requested in https://github.com/prettier/prettier/pull/7111#issuecomment-2252623779 The flag's tests were already added in a previous commit, so the test changes you see in this commit are specifically due to the new flag's implementation. * Document experimentalOperatorPosition flag * Change operator position option start|end In response to https://github.com/prettier/prettier/pull/7111#discussion_r1729382119 * Add TS intersection line wrapping tests This clones TypeScript's type union operator tests in `union-parens.ts` and swaps the operators (& <-> |) to test the the type interesection operator. It also runs intersection tests with the new `experimentalOperatorPosition: "start"` flag. This does _not_ yet update the implementation to consider the flag; to ease review, I'll make that change in the next commit to isolate the impact of the change. * Apply experimentalOperatorPosition: start to type intersections The type union operator was already formatted at the beginning of lines by default, so that logic didn't need to be updated. * Update 7111.md * Update tests after rebasing I rebased from1dfe28f85toc7066780eto fix test failures related to https://github.com/prettier/prettier/pull/16601. The rebase applied cleanly, and this was the only change to tests. Since the PR has already been approved, I'll keep this as a separate commit rather than squashing into the prior commits. --------- Co-authored-by: fisker Cheung <lionkay@gmail.com> Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>
Opinionated Code Formatter
JavaScript
· TypeScript
· Flow
· JSX
· JSON
CSS
· SCSS
· Less
HTML
· Vue
· Angular
GraphQL
· Markdown
· YAML
Your favorite language?
Intro
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
Input
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
Output
foo(
reallyLongArg(),
omgSoManyParameters(),
IShouldRefactorThis(),
isThereSeriouslyAnotherOne(),
);
Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!
Badge
Show the world you're using Prettier →
[](https://github.com/prettier/prettier)
Contributing
See CONTRIBUTING.md.
Languages
JavaScript
98.6%
CSS
0.9%
Vue
0.2%
HTML
0.2%
MDX
0.1%