* new_tests
* move_all_clobbered_tests
* remove all the tests that no longer exist
* re-run flow tests
* Move all the flow tests to tests/flow and prettier to tests/
* Move prettier tests to their own folders
* Add jsfmt files
* run prettier snapshot tests
Given the discussion on #296, it seems like there's debate between spaces around `{}` but no one puts spaces around `[]`. So changing the behavior to respect this.
The original intent of it was for `if then else` and `try catch` as they aren't likely to be empty, but it accidentally caught function bodys, which have many valid reasons to be empty. Let's special case those out.
- Introduce findInDocs that avoids some annoying boilerplate when you want to get a value while traversing the docs
- Implement a hasStopped function that stops the traversal when you found the value you needed
* Validate user-provided config with jest-validate
* Don't use object shorthand
* Update jest-validate to 18.2
* Fix Node4 destructuring from require
* Make use of jest-validate for deprecation message
* Remove chalk reference
If you use the `--write` option, the files will end with a single
newline as expected. But if you let prettier print to stdout instead and
redirect that into a file, it will contain _two_ newlines at the end.
Demonstration of the correct `--write` behavior:
```
$ cat tmp.js
function test() {
return "hello";
}
$ wc -l tmp.js
3 tmp.js
$ ./bin/prettier.js tmp.js --write
tmp.js
$ cat tmp.js
function test() {
return "hello";
}
$ wc -l tmp.js
3 tmp.js
```
Notice how an extra line is added when redirecting stdout:
```
$ ./bin/prettier.js tmp.js > tmp2.js
$ cat tmp2.js
function test() {
return "hello";
}
$ wc -l tmp2.js
4 tmp2.js
```
With this commit things work as expected:
```
$ ./bin/prettier.js tmp.js > tmp2.js
$ cat tmp2.js
function test() {
return "hello";
}
$ wc -l tmp2.js
3 tmp2.js
```
Fixes#377.
* [WIP] Add rationale document
I think it would be great to have such a document. This way we don't have to explain the same things over and over again on the issues and it helps users and contributors know what they are getting into.
This is a very rough draft with a lot of empty content but I think it shows the idea.
* Improve Rationale.md
- Fix typos.
- Consistently use "prettier does x" instead of "prettier is going to do
x" or "prettier will do x"-
- Simplify language.
* Add bit about correctness
* Use babel-code-frame for syntax errors
* Support the `--color` option more explicitly
* Update rollup config to handle babel-code-frame
* Use exact dependencies
This one is really weird
```js
if (() => {} ? 1 : 0) {}
```
parses fine but
```js
if (() => {
} ? 1 : 0) {}
```
is a syntax error. Let's always add a parenthesis.
Note that no one is every going to write this in practice, this is really useless :p
We actually need this `;` for EmptyStatement, otherwise it applies to the next block of code. (Creating a label with an empty statement is completely useless, but it triggers a lot in the fuzz testing tool)
Fixes#376
We avoid adding a `;` for a variable declaration in for loop but this is only meant if the var declaration is inside of the `()` part of the for loop. Not if the body part.
Fixes#385