Commit Graph

1284 Commits (850d51a03375dd0f2e85d94651e7560cb437e17f)

Author SHA1 Message Date
Christopher Chedeau 6933d16125 Inline decorators with no arguments (#1910)
Fixes #1898
2017-06-02 14:40:39 -07:00
Christopher Chedeau 0e35d3758a Fix <this.x /> (#1886)
Would be nice to get it properly handled in https://github.com/eslint/typescript-eslint-parser/issues/307

Fixes #1877
2017-06-02 14:27:27 -07:00
Christopher Chedeau 74f7f96fe4 Move accessibility before static (#1908)
I looked through all the places where we display accessibility and all of them now have a consistent way of printing all those modifiers.

Fixes #1877
2017-06-02 14:27:19 -07:00
Christopher Chedeau 02c48d284e Fix strictEqual throwing (#1909)
I looked at what is being called with assert and couldn't find anything but `ok` and `strictEqual`.

Fixes #1903
2017-06-02 14:27:03 -07:00
Simen Bekkhus 584bf4ecbf Upgrade babel code frame (#1902)
* Upgrade babel code frame

* Get better marker for parsing errors in postcss-values-parser
2017-06-02 14:11:05 -07:00
Simen Bekkhus 862a2d610c Used published version of uglify-es (#1897) 2017-06-02 13:46:13 -07:00
Joseph Frazier f6dabc0d27 Add regression test for CLI shebang preservation (#1901)
Following up on https://github.com/prettier/prettier/pull/1899
2017-06-02 13:42:44 -07:00
Simen Bekkhus 6a2c964b22 Include typescript and postcss in parser help (#1906) 2017-06-02 13:42:20 -07:00
Joseph Frazier 3070884b10 Add shebang comment nodes to Flow/TypeScript ASTs (#1905)
* Add shebang comment nodes to Flow/TypeScript ASTs

Now we handle actually printing the shebang in `printComment`, rather
than lopping it off beforehand and reattaching it afterward, as
suggested in https://github.com/prettier/prettier/pull/1718#issuecomment-303876792

* Dedupe AST shebang-insertion code into helper function
2017-06-02 13:38:15 -07:00
Joseph Frazier c15091bea6 Preserve shebang in CLI output (#1899)
This fixes https://github.com/prettier/prettier/issues/1890, albeit in a
quick-and-dirty way. Note also that the cursor offset may be incorrect
when there is a shebang, but that's a separate issue.
2017-06-02 12:46:20 -07:00
Joseph Frazier 26e829b987 Upgrade prettier to v1.4.0, fix lint issues (#1888) 2017-06-02 11:48:43 -07:00
Kevin Gibbons 4915e0228e Require semicolons before class props named 'in' or 'instanceof' (#1878) 2017-06-02 10:52:11 -07:00
Joseph Frazier 78b99329bf Ignore docs/index.js when searching with ag/ripgrep/sift (#1848)
* Ignore docs/index.js when searching with ag/ripgrep/sift

This makes it easier to search through the code without getting
irrelevant results.

* Ignore docs/*.js when searching with ag/ripgrep/sift

This makes it easier to search through the code without getting
irrelevant results. I couldn't get a glob (`docs/*.js`) to work with `ag
babylon -l | ag docs`, so I just listed them out instead.
2017-06-02 09:23:47 -07:00
Christopher Chedeau 7fd71fa386 1.4.0 2017-06-02 08:55:04 -07:00
Lucas Azzola 83c5253429 fix(typescript): look at source to determine export = statement (#1868) 2017-06-02 08:32:40 -07:00
Christopher Chedeau faf2ac5f9e Hack to get export default work (#1866)
Fixes #1854
2017-06-02 08:12:03 -07:00
Lucas Azzola 38eec13a03 TypeScript: temp fix for missing readonly keyword (#1865)
* fix(typescript): temp fix for missing readonly keyword, fixes #1845

* fix(typescript): use non-master commit from tsep
2017-06-02 08:09:24 -07:00
Lucas Azzola 8511e798dc feat(decorators): inline more types of decorators (#1864) 2017-06-02 07:38:44 -07:00
Lucas Azzola 9ed94c77ab fix(typescript): do not print trailing comma in TS tuple type, fixes #1858 (#1863) 2017-06-02 07:16:41 -07:00
Lucas Azzola ede078c0d3 fix(typescript): print static before accessibility, fixes #1855 (#1862) 2017-06-02 07:16:11 -07:00
Ryan Castner eb9ba74665 Update README.md (#1859) 2017-06-02 06:48:29 -07:00
Christopher Chedeau bc4075ac65 Add parenthesis around object inside of as (#1852)
Fixes #1851
2017-06-01 21:10:05 -07:00
Christopher Chedeau fdce975e5d Move all the dependencies to dev dependencies and --exact (#1850)
Since we are now bundling all the dependencies, we can have prettier be dependency-free on npm <3
2017-06-01 20:38:25 -07:00
Christopher Chedeau 3f8c4d6974 Fix yet another form of class with the same ast (#1849)
Fixes #1847
2017-06-01 19:02:15 -07:00
Joseph Frazier 4bfeb9064d Add `cursorOffset` option for cursor translation (#1637)
* 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
2017-06-01 15:52:29 -07:00
Joseph Frazier a983d30663 Use `filepath` option instead of `filename` in tests (#1846)
This silences the validation warnings like:

    Unknown option "filename" with value "/home/travis/build/prettier/prettier/tests/flow/es_declare_module/flow-typed/declares.js" was found.

See here for an example:
https://travis-ci.org/prettier/prettier/jobs/238474756#L397

Related to commit 0d9b04b (https://github.com/prettier/prettier/pull/1835)
2017-06-01 14:40:49 -07:00
Jake 5d63d34b77 Add an option to include "dot" directories. (#1844)
* Add an option to include "dot" directories.

We have some files in directories that start with a `.` that we want prettified. This PR adds the `include-dot-directories` flag to let the glob match dot directories.

* always include dot directories
2017-06-01 12:27:56 -07:00
Umidbek Karimov 595cc01acc Fix webstrom screenshot url. (#1841) 2017-06-01 17:06:34 +02:00
Johannes Nagl 491428c333 fix link to webstorm screenshot 2017-06-01 14:16:33 +02:00
Mitermayer Reis ba86d8ea65 Fix error messages (#1839)
* Adding --stdin-filepath option in order to enable filetype inference from
stdin

* Making sure error messages are 1 indexed based instead of zero indexed
2017-05-31 17:50:55 -07:00
Mitermayer Reis 8fdf398e27 Making cli infer parser based on filetype (#1837)
* Adding --stdin-filepath option in order to enable filetype inference from
stdin

* Making CLI auto infer parser based on filename passed
2017-05-31 14:42:04 -07:00
Christopher Chedeau d55640087e Fix building docs (#1838)
The hackiness continues! I'm now bundling an existing bundle again in order for it to get exported as a global variable :p There's likely a better solution, but it kind of works.

Because I have to regenerate the docs, I just tagged it as 1.4.0-beta and added typescript and postcss in there.
2017-05-31 13:37:35 -07:00
Mitermayer Reis 0d9b04bc94 Adding --stdin-filepath option in order to enable filetype inference … (#1835)
* 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
2017-05-31 12:26:22 -07:00
Christopher Chedeau f4296550db Introduce Webpack 2 to fix postcss bundling (#1836)
It turns out rollup doesn't use the same algorithm for bundling commonjs files when there are cycles as node, which breaks postcss: https://twitter.com/Rich_Harris/status/869021144191561729. Webpack works just fine with it.

This sucks to have this rollup/webpack frankenstein but I really want to be able to release and don't really want to spend yet another day or two trying to make it work well.
2017-05-31 11:59:33 -07:00
Karl O'Keeffe f4ef1c2c97 JSX whitespace on the same line as text (#1829)
This tweaks our JSX formatting to only put a JSX whitespace `{" "}` on a line by itself when it comes before or after a multiline element.

When preceding a text or single line element it appear on the same line as that element.
2017-05-31 10:16:50 -07:00
Karl O'Keeffe a680cd8534 Fix unstable JSX output by ensuring we follow `fill` rules. (#1827)
* Fix unstable JSX output by ensuring we follow `fill` rules.

This changes makes us more strict about ensuring our JSX children follow the alternating content/whitespace format expected by the `fill` primitive.

Previously there were some cases where could get out of sync which would throw out the formatting.

* Simplify whitespace wrangling

# Conflicts:
#	src/printer.js
2017-05-31 09:42:36 -07:00
Christopher Chedeau fa708d102a Remove trailing commas for generics in TypeScript (#1832)
Fixes #1820
2017-05-31 09:22:00 -07:00
Patrick Roumanoff 96b8119b4b added related projects Bookmarklet (#1824) 2017-05-30 21:50:51 -07:00
Christopher Chedeau 3097f9b2fe Do not indent nested ternaries (#1822)
This avoids making it seems like it is indented by 4 characters instead of two. The downside is that if the condition is multi-line it's not going to be properly aligned, but I feel it's a better trade-offs. If you are doing nested ternaries, you usually have small conditions.
2017-05-30 10:08:06 -07:00
Christopher Chedeau 73ff0ef9ea Add group around implements (#1821)
This shouldn't break if it fits in one line.

Fixes #1818
2017-05-30 09:45:07 -07:00
Joseph Frazier ea27846d1f Don't force line break in empty loop bodies (#1815)
This makes them consistent with empty function bodies.

Fixes https://github.com/prettier/prettier/issues/1356
2017-05-30 09:39:10 -07:00
Christopher Chedeau eeb8616e3c Add parenthesis for single arg types with generics (#1814)
Fixes #1813
2017-05-29 16:59:45 -07:00
Christopher Chedeau 2ab3d6d6ac Workaround bug with comment ending in */ (#1810)
Reported in the original repo: https://github.com/postcss/postcss-scss/issues/64
2017-05-29 13:05:20 -07:00
Christopher Chedeau 59e4e83355 Break before combinators and indent (#1809) 2017-05-29 12:55:14 -07:00
Christopher Chedeau f34492d7e5 Strip leading space for first combinators (#1807) 2017-05-29 12:49:25 -07:00
Christopher Chedeau 27df0f81f5 Preserve space before parens (#1806) 2017-05-29 12:41:04 -07:00
Roman Coedo 2e9ea8f223 Move emacs package to its own repository (#1804) 2017-05-29 11:55:58 -07:00
Christopher Chedeau dc287d32a5 Remove extra newline from empty @media (#1802) 2017-05-29 08:52:24 -07:00
Christopher Chedeau c4e32f4c78 Remove double spaces in @font-face (#1801) 2017-05-29 08:49:51 -07:00
Christopher Chedeau 873123223f Fix empty urls (#1800) 2017-05-29 08:43:19 -07:00