Commit Graph

1100 Commits (2ef169eb67c7efa25a5cb5371c12eb1c90de5e08)

Author SHA1 Message Date
Lucas Azzola 2ef169eb67 fix(typescript): print semi with inline interfaces/types, fixes #1930 (#1936) 2017-06-03 05:18:59 -07:00
Christopher Chedeau f56f9e5e8f 1.4.1
This fixes all the TypeScript problems reported and a few regressions from 1.4.0.
2017-06-02 16:25:57 -07:00
Christopher Chedeau 3d175cc305 Remove eval for npm release (#1925)
Fixes #1895
2017-06-02 16:19:26 -07:00
Christopher Chedeau 2b6c1cd27e Update typescript-eslint (#1924)
This applies https://github.com/eslint/typescript-eslint-parser/pull/308 and https://github.com/eslint/typescript-eslint-parser/pull/303 to fix issues on prettier.

Fixes #1870
2017-06-02 16:19:15 -07:00
Christopher Chedeau dae7203be6 Fix As parenthesis for real (#1923)
Instead of doing it inside of object, we need to have them use the existing mechanism that checks if the left-most character is a paren.
2017-06-02 16:08:45 -07:00
Christopher Chedeau 3264da9cab Fix leading comment (#1920)
It turns out that leading comment is attached to the CallExpression which is the last one and not the first one if they fit in a single line, so we want to not check that one.

Fixes #1892
2017-06-02 15:50:43 -07:00
Joseph Frazier 3580aac6e0 Say "group" instead of "multilineGroup" in commands.md (#1921)
`multilineGroup` was removed in commit 3aa267d (https://github.com/prettier/prettier/pull/450)
2017-06-02 15:49:08 -07:00
Christopher Chedeau db0be7fd5b fix conflict 2017-06-02 15:44:50 -07:00
Christopher Chedeau 323d64fb84 Port intersection inlining logic to TypeScript (#1919)
Fixes #1880
2017-06-02 15:40:33 -07:00
Christopher Chedeau 0d239477cb Use semi-colon for object separator (#1918)
Looks like the convention for typescript separator is `;` whereas for flow it's `,`. Let's migrate to that.

Fixes #1896
Fixes #1879
Fixes #1874
2017-06-02 15:32:51 -07:00
Joseph Frazier 451f4aaad5 Add regression test for --debug-check (#1917)
See https://github.com/prettier/prettier/pull/1916
2017-06-02 15:30:39 -07:00
Christopher Chedeau 620119d9d4 Fix --debug-check (#1916)
This got broken with the cursor commit.

cc @josephfrazier, would be nice to add some end to end test here :)
2017-06-02 15:10:08 -07:00
Christopher Chedeau 74f0d3979b Add parenthesis for yield and await inside of `as` (#1915)
Fixes #1913
2017-06-02 15:10:02 -07:00
Christopher Chedeau 2f9ea794db Always expand enums (#1914)
We do the same for classes, and it's usually written that way even if it fits in one line, even in the TS docs: https://www.typescriptlang.org/docs/handbook/enums.html

Fixes #1873
2017-06-02 15:09:55 -07:00
Christopher Chedeau a255977009 Do not make variable multilines inside of for loop (#1912)
Fixes #1876
2017-06-02 15:00:16 -07:00
Christopher Chedeau e58dd2bf0b Add semi for ts function declarations without body (#1911)
Fixes #1891
2017-06-02 14:49:37 -07:00
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