Mobx is the only popular JavaScript library that I know about which uses decorators. They put things on the same line so we should follow their conventions.
The logic implemented here is the following: if there is one decorator, it's on the same line. If there is more than one, they are each on their own line.
Fixes#325
This was introduced by #314 where `line` should have been `softline`. By the way, I was going to propose renaming `line` to `line_or_space` and `softline` to `line_or_nothing` which should make it more explicit what is going on.
Fixes#461
* 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