Update prettier from 1.6.1 to 1.7.0 #57
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
prettier has been updated to 1.7.0 by dependencies.io
1.7.0
!image
This release features some bugfixes and tweaks around JSX, TypeScript, CSS, and JavaScript formatting, as well as a couple new features.
Highlights
JSX Changes
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:Before this was added, prettier only formatted ternaries with one consistent style:
In 1.6.0, we used the following heuristic to decide when to use the new "JSX mode ternaries":
However, this heuristic caused some unexpected formatting:
!Github Diff showing a ternary containing internationalization strings appearing inside a JSX element being converted to use JSX-mode style ternaries
So, in 1.7.0, we have revised our heuristic to just be:
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.
CSS Letter Case Consistency
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
.Don't worry, though – Prettier won't touch your
$scss-variables
,@less-variables
, orFunctionNames()
. Preprocess on!Pragma Support
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:or
This was ajhyndman's idea and it was implemented by @wbinnssmith.
Other Changes
TypeScript
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:Also, Prettier 1.6.1 was incorrectly removing the
declare
keyword fromenum
declarations in*.d.ts
files:Both of these issues have been fixed. Thanks to JamesHenry and @existentialism for these fixes which support our TypeScript community!
Configuration
Configurable Config Precedence
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 filefile-override
- Config file take precedence over CLI optionsprefer-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.PRs merged in this release
.sync()
method by ikatyangresolveConfigFile.sync()
by ikatyangcross-spawn
by ikatyangfiles:
overtypes:
in pre-commit configuration by asottilequery
) by azz?:
instead of?\!
by ikatyangIssues resolved in this release
declare
modifier fromenum
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!