Closed greenkeeper[bot] closed 7 years ago
After pinning to 1.5.3 your tests are passing again. Downgrade this dependency π.
Your tests are still failing with this version. Compare the changes π¨
Need to create the proper config and ignore files for prettier
to upgrade.
Your tests are still failing with this version. Compare the changes π¨
This release features some bugfixes and tweaks around JSX, TypeScript, CSS, and JavaScript formatting, as well as a couple new features.
We received a lot of community feedback about the changes we made to JSX formatting in the 1.6.0 release, and have made changes to bring formatting closer to community standards and expectations.
In 1.6.0, we added a second style for ternaries (conditional expressions, a ? b : c
), based on a format popular in the community where parentheses are used to demarcate JSX content:
const DinnerOptions = ({ willEatMeat, willEatEggs, willEatVegetables }) => (
<div>
<div>Let's get some dinner...</div>
{willEatMeat ? (
<FullMenu />
) : willEatEggs ? (
<VegetarianMenu />
) : willEatVegetables ? (
<VeganMenu />
) : (
<BackupMenu />
)}
</div>
);
Before this was added, prettier only formatted ternaries with one consistent style:
willEatMeat
? "Full Menu"
: willEatEggs
? "Vegetarian Menu"
: willEatVegetables ? "Vegan Menu" : "Backup Menu";
In 1.6.0, we used the following heuristic to decide when to use the new "JSX mode ternaries":
We should print a ternary using JSX mode if:
* The ternary contains some JSX in it
OR
* The ternary appears inside of some JSX
However, this heuristic caused some unexpected formatting:
So, in 1.7.0, we have revised our heuristic to just be:
We should print a ternary using JSX mode if:
* The ternary contains some JSX in it
We hope that this change will result in fewer surprising ternaries.
A big thanks goes out to @duailibe who implemented this change in addition to several other JSX-related formatting issues that were reported.
We spent some time this release polishing our CSS formatting, and as part of that, @lydell did some work to normalize letter case.
So now, almost everything in CSS will print using lower case
.
/* Before */
DIV.Foo {
HEIGHT: 12PX;
}
/* After */
div.Foo {
height: 12px;
}
Don't worry, though β Prettier won't touch your $scss-variables
, @less-variables
, or FunctionNames()
. Preprocess on!
There is a new option called --require-pragma
(requirePragma
via the API) which will change prettier's behavior so that it only reformats a file if it has a special "pragma" comment at the top of it, that looks like this:
/**
* @prettier
*/
or
/**
* @format
*/
This was @ajhyndman's idea and it was implemented by @wbinnssmith.
There was a bug in Prettier 1.6.1 where an error would be thrown while parsing any TypeScript using the never
type, for example:
Observable.empty<never>();
Also, Prettier 1.6.1 was incorrectly removing the declare
keyword from enum
declarations in *.d.ts
files:
// In
declare const enum Foo {}
// Out
const enum Foo {}
Both of these issues have been fixed. Thanks to @JamesHenry and @existentialism for these fixes which support our TypeScript community!
There is a new CLI option --config-precedence
which configures how prettier should prioritize config sources. Valid values are:
cli-override
(default) - CLI options take precedence over config file
file-override
- Config file take precedence over CLI options
prefer-file
- If a config file is found will evaluate it and ignore other CLI options. If no config file is found CLI options will evaluate as normal.
This option adds support to editor integrations where users define their default configuration but want to respect project specific configuration.
prettier.resolveConfig.sync
Previously, there was no way via the API to resolve configuration for a source file synchronously. Thanks to some new additions to cosmiconfig
by @sudo-suhas, @ikatyang was able to add support for this to the prettier API.
.sync()
method by @ikatyangresolveConfigFile.sync()
by @ikatyangcross-spawn
by @ikatyangfiles:
over types:
in pre-commit configuration by @asottilequery
) by @azz?:
instead of ?!
by @ikatyangdeclare
modifier from enum
reported by @mariusschulzThank you to everyone who contributed to this release, be it through issue creation, code contribution, code review, or general commenting and feedback. Prettier is a community-run project and is able to continue to exist thanks to people like you. Thank you!
Your tests are still failing with this version. Compare the changes π¨
Your tests are still failing with this version. Compare the changes π¨
Your tests are still failing with this version. Compare the changes π¨
Your tests are still failing with this version. Compare the changes π¨
Version 1.6.0 of prettier just got published.
This version is covered by your current version range and after updating it in your project the build failed.
As prettier is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this :muscle:
Status Details
- β **continuous-integration/travis-ci/push** The Travis CI build could not complete due to an error [Details](https://travis-ci.org/HiFaraz/identity-desk/builds/269257629?utm_source=github_status&utm_medium=notification)Release Notes
1.6.0: Config File, JSXI want to give a special shout out to @azz who has been maintaining the repository and implementing a bunch of the changes in this release as I had less time to devote to prettier due to vacation and switching team :)
Highlights
Configuration
Implement cosmiconfig for workspace configuration (#2434) by @azz
Since the very first release of prettier, people have asked for a
.prettierrc
file. We've been trying to have as few options as possible and tried to avoid being one more.dotfile
that you have to have when starting a new project.But, the truth is, we need to have some way to configure prettier that can be kept in sync with all the integrations. By not having one, we pushed the problem to them and saw a bunch of incompatible ways of handling the problem. So now, it's handled by prettier itself.
For more information on configuration file support, see the README.
Support .prettierignore files (#2412) by @evilebottnawi
Along with telling what configuration to use, you can write a file
.prettierignore
to tell which files not to convert.JSX
Improve JSX Formatting (#2398) by @suchipi
The last big friction point from people trying to adopt prettier was around how JSX was being printed. We went through all the issues that were raised and made a bunch of changes:
Hopefully this is going to be more in line with how the majority of the community is writing JSX and we can have prettier be used in more place ;)
Inline single expressions in JSX (#2442) by @karl
With JSX, we started by respecting a lot of line breaks that were in the original source. This had the advantage of doing fewer changes to your codebase but chipped away the value of a consistent pretty printer as the same semantic code could be written in two ways.
During each new release we've tightened this and made decisions around how to always print a piece of code. The latest of those is what happens if there's a single child in a JSX object, we're now always going to inline it.
Ensure there is a line break after leading JSX white space (#2348) by @karl
Leading JSX empty spaces are now on their own line. It looked weird to have them before a tag as it "indented" it differently compared to the rest.
Other Changes
JSON
Use babylon.parseExpression for JSON (#2476) by @josephfrazier
We used to use a strict JSON parser that would throw if there was a comment or a trailing comma. This was inconvenient as many JSON files in practice are parsed using JavaScript or json5 that are not as strict. Now, we have relaxed this and are using the JavaScript parser to parse and print JSON. This means that comments will be maintained if there were some.
Note that this is purely additive, if your original file was JSON compliant, it will keep printing a valid JSON.
JavaScript
Add more supervisory parens (#2423) by @azz
Parenthesis are a hot topic because they are not part of the AST, so prettier ignores all the ones you are putting and re-creating them from scratch. We went through all the things that people reported and came up with a few edge cases that were very confusing when comparisons were chained and
%
was mixed with*
or/
.One thing that we are not changing is the fact that we remove extra parenthesis around combinations of basic arithmetic operators:
+-*/
.Implement prettier-ignore inside JSX (#2487) by @azz
It's useful to be able to ignore pieces of JSX, it's now possible to add a comment inside of a JSX expression to ignore the formatting of the next element.
Do not swallow prettier-ignore comments (#2664)
In order to support some edge cases, in the internals, we have the ability to avoid printing comments in a generic way and print them in the call site instead. It turns out that when we used
prettier-ignore
, we didn't print the comments at all! This is now fixed.Fix indentation of a do-while condition (#2359) by @jsnajdr
It took 6 months for someone to report that do-while were broken when the while condition is multi-line, it confirms my hunch that this construct is not widely used in practice.
Break sequence expressions (#2388) by @bakkot
Another underused feature of JavaScript is sequence expressions. We used to do a bad job at printing them when they would go multi-line, this has been corrected :)
Trim trailing whitespace from comments (#2494) by @azz
We took the stance with prettier to remove all the trailing whitespaces. We used to not touch comments because it's user generated, but that doesn't mean that they should have whitespace :)
Fix interleaved comments in class decorators (#2660, #2661)
Our handling for comments inside of the class declaration was very naive, we would just move all the comments to the top. We now are more precise and respect the comments that are interleaved inside of decorators and around
extends
.Improve bind expression formatting (#2493) by @azz
Bind expressions are being discussed at TC39 and we figured we could print it with prettier. We used to be very naive about it and just chain it. Now, we use the same logic as we have for method chaining with the
.
operator for it. We also fixed some edge cases where it would output invalid code.Add support for printing optional catch binding (#2570) by @existentialism
It's being discussed at TC39 to be able to make the argument of a
catch(e)
optional. Let's make sure we can support it in prettier if people use it.Add support for printing optional chaining syntax (#2572) by @azz
Another new proposal being discussed at TC39 is an optional chaining syntax. This is currently a stage 1 proposal, so the syntax may change at any time.
Handle Closure Compiler type cast syntax correctly (#2484) by @yangsu
Comments are tricky to get right, but especially when they have meaning based on where they are positioned. We're now special casing the way we deal with comments used as type cast for Closure Compiler such that they keep having the same semantics.
Inline first computed property lookup in member chain (#2670) by @azz
It looks kind of odd to have a computed property lookup on the next line, so we added a special case to inline it.
Flow
Support opaque types and export star (#2543, #2542) by @existentialism
The flow team introduced two very exciting features under a new syntax. We now support them in prettier. I've personally been waiting for opaque types for a veerrryyyy long time!
Strip away unnecessary quotes in keys in type objects and interfaces (#2643)
We've been doing this on JavaScript objects since the early days of prettier but forgot to apply the same thing to Flow and TypeScript types.
Print TypeParameter even when unary function type (#2406) by @danwang
Oopsy, we were dropping the generic in this very specific case.
Keep parens around FunctionTypeAnnotation inside ArrayTypeAnnotation (#2561) by @azz
Parenthesis... someday we'll get all of them fixed :)
TypeScript
Support TypeScript 2.5 RC (#2672) by @azz
TypeScript 2.5 RC was recently announced, allowing you to use the upcoming "optional catch binding" syntax in TypeScript, too.π
Don't add namespace keyword to global declaration (#2329) by @azz
Fix <this.Component /> (#2472) by @backus
Thanks to the untyped and permissive nature of JavaScript, we've been able to concat undefined to a string and get some interesting code as a result. Now fixed for this case :)
Allow type assertions to hug (#2439) by @azz
We want to make sure that all the special cases that we added for JavaScript and Flow also work for TypeScript constructs. In this case, objects should also hug if they are wrapped in a
as
operator.Remove parens for type assertions in binary expressions (#2419) by @azz
Most of the time we add parenthesis for correctness but in this case, we added them for nothing, so we can just get rid of them and have a cleaner code :)
Print parens around type assertion as LHS in assignment (#2525) by @azz
Yet another case of missing parenthesis. Thankfully we're getting very few of them nowadays and they are for extremely rare edge cases.
Print declare for TSInterfaceDeclaration (#2574) by @existentialism
The
declare
keyword doesn't do anything forinterface
so we never put it there. However, it felt weird if you were in a declaration file and seeing everything havedeclare
before it except for interfaces. So now we reprintdeclare
if it was there in the first place.CSS
Normalize quotes in CSS (#2624) by @lydell
In order to get a first version of CSS to ship, we kept string quotes as is. We are now respecting the
singleQuote
option of prettier. The difficulty here was to make sure that we output correct code for all the crazy escapes, unicode characters, emoji, special rules like charset which only work with double quotes...Normalize numbers in CSS (#2627) by @lydell
Another place where we can reuse the logic we've done for JavaScript to improve CSS printing.
Quote unquoted CSS attribute values in selectors (#2644) by @lydell
I can never quite remember the rules behind quotes around attributes so we're now always putting quotes there.
Add support for css keyword (#2337) by @zanza00
Support styled-components with existing component (#2552, #2619) by @azz
styled-components has a lot of different variants for tagging template literals as CSS. It's not ideal that we've got to encode all those ways inside of prettier but since we started, might as well do it for real.
Trim whitespace in descendant combinator (#2411) by @azz
The CSS parsers we use do not give us a 100% semantic tree: in many occasions they bail and just give us what is being entered. It's up to us to make sure we clean this up while maintaining correctness. In this case, we just printed spaces between selectors as is but we know it's correct to always replace it by a single space.
Strip BOM before parsing (#2373) by @azz
I still have nightmares from dealing with BOM in a previous life. Thankfully, in 2017 it's no longer a big issue as most tooling is now aware of it. Thanks @azz for fixing an edge cases related to CSS parsing.
GraphQL
Add support for range-formatting GraphQL (#2319) by @josephfrazier
If you tried to use the range formatting feature in a GraphQL file, it would throw an exception, now it properly worked again and only reformats the piece you selected.
Add
.gql
file extension to be parsed as GraphQL (#2357) by @rrdelaneyAt Facebook, we use
.graphql
extension but it looks like it's common to have.gql
as well, doesn't cost a lot to support it in the heuristic that figures out what parser to use.CLI
Support multiple patterns with ignore pattern (#2356) by @evilebottnawi
It was already possible to have multiple glob patterns but they would be additive, with this change, you can add a glob pattern to ignore some files. It should be very handy to ignore folders that are deeply nested.
Make --list-different to work with --stdin (#2393) by @josephfrazier
This is a handy way of knowing if prettier would print a piece of code in a different way. We already had all the concepts in place, we just needed to wire them up correctly.
Not sure how things should work exactly?
There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html) and of course you may always [ask my humans](https://github.com/greenkeeperio/greenkeeper/issues/new).Your Greenkeeper Bot :palm_tree: