* Update README.md to add a notice about a limitation using lint-staged
The lint-staged example under pre-commit hooks has a limitation where if you use the [Github Desktop](https://desktop.github.com/) app to commit specific lines, this approach will stage the whole file after regardless. See this [issue](https://github.com/okonet/lint-staged/issues/62) for more info.
* Add back removed empty line
* Remove Github Desktop app reference
* Add comments showing parser arguments
Since this is how they are invoked, the comments make it easier to maintain.
* Use babylon.parseExpression for JSON
See https://github.com/prettier/prettier/issues/2378#issuecomment-314600778
Note that this doesn't yet print comments:
echo '{/*comment*/"K":"V"}' | ./bin/prettier.js --parser json
* Remove parser-json.js
This reduces duplicate code in the built package.
See https://github.com/prettier/prettier/pull/2476#pullrequestreview-50181398
* Add test with block comment in JSON
* Fix test with block comment in JSON
* Add test with line comment in JSON
* Don't build now-redundant parser-json.js
* Explode the options table
The options table in README was getting a bit unwieldy. This commit moves the options to a top-level section, and makes each setting hyperlink-able.
The `cursorOffset` setting has been moved from the list to the documentation for `formatWithCursor`.
* Fix typos/punctuation
* Fix --trailing-comma formatting
* feat(api): add custom parser API
* test(api): add integration test for parser resolution
* chore(api): fix build after resolving conflicts
* docs(api): document custom parser API
* docs(api): fix typo
* chore(build): add parse5 to build and support yarn test --prod
* Adding --stdin-filepath option in order to enable filetype inference from
stdin
* Creating vim editor integration docs
- Moving vim editor integration into editors directory
- Adding information about vim-prettier
* Refer to "line length" instead of "line width"
- It's consistent with what it has been called in the section so far.
* Add missing punctuation
* Remove needless "just"s
- It's less condescending to a reader who doesn't know how to
"just" do these things.
* Add `formatWithCursor` API with `cursorOffset` option
This addresses https://github.com/prettier/prettier/issues/93 by
adding a new option, `cursorOffset`, that tells prettier to determine
the location of the cursor after the code has been formatted. This is
accessible through the API via a new function, `formatWithCursor`, which
returns a `{formatted: string, cursorOffset: ?number}`.
Here's a usage example:
```js
require("prettier").formatWithCursor(" 1", { cursorOffset: 2 });
// -> { formatted: '1;\n', cursorOffset: 1 }
```
* Add `--cursor-offset` CLI option
It will print out the offset instead of the formatted output. This
makes it easier to test. For example:
echo ' 1' | prettier --stdin --cursor-offset 2
# prints 1
* Add basic test of cursor translation
* Document `cursorOffset` option and `formatWithCursor()`
* Print translated cursor offset to stderr when --cursor-offset is given
This lets us continue to print the formatted code, while also
communicating the updated cursor position.
See https://github.com/prettier/prettier/pull/1637#discussion_r119735496
* doc-print cursor placeholder in comments.printComments()
See https://github.com/prettier/prettier/pull/1637#discussion_r119735149
* Compare array index to -1 instead of >= 0 to determine element presence
See https://github.com/prettier/prettier/pull/1637#discussion_r119736623
* Return {formatted, cursor} from printDocToString() instead of mutating options
See https://github.com/prettier/prettier/pull/1637#discussion_r119737354
* Adding --stdin-filepath option in order to enable filetype inference from stdin to allow chosing css parser
* Adding readme information on the filepath option
* Also including support for typescript parser inference.
* Running linter