Commit Graph

1393 Commits (26842e4d696dac4400075b40d64602223d1f3c41)

Author SHA1 Message Date
Yang Su 26842e4d69 Handle closure compiler type cast syntax correctly (#2484)
* Handle closure compiler type cast syntax correctly

Fixes https://github.com/prettier/prettier/issues/1445

* Move closure type cast detection to needParens in fast-path.js

* every => some and added additional check for leading comment
2017-07-25 11:21:25 +10:00
Lucas Azzola a666a29aa3 Print semi after DeclareFunction, fixes #2534 (#2536) 2017-07-24 21:55:16 +10:00
Joseph Frazier a78d1389f6 Use babylon.parseExpression for JSON (#2476)
* 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
2017-07-24 11:43:49 +10:00
Adam Hawkins 781ba9580a Fix variable name in git precommit example (#2529)
echo "jsfiles" will not work. The example references a variable, not a static string. This commit makes the example functionally correct.
2017-07-21 08:54:51 -07:00
Lucas Azzola 4a0e9475df Print parens around type assertion as LHS in assignment, fixes #2521 (#2525) 2017-07-20 23:16:15 +10:00
James Henry 1c9962df67 Update tsep and account for TSTypeReference change (#2520)
* Update tsep and account for TSTypeReference change

* Check TSTypeReference in shouldHugType
2017-07-20 12:54:43 +02:00
Lucas Azzola ffbdff4bc2 prettier 2017-07-20 14:26:55 +10:00
Lucas Azzola 8d9022db54 Fix /users/ link 2017-07-20 13:26:54 +10:00
Mitermayer Reis 38fdb6f851 Update vim-prettier location (#2518) 2017-07-20 11:06:54 +10:00
Jared Anderson 2d97f0d0cc Add graphql to parser options in help output (#2519) 2017-07-19 18:33:39 +02:00
Lucas Azzola e8425a4899 Comment out configuration file docs 2017-07-19 08:53:44 +10:00
Lucas Azzola 02639da9a9 Improve coverage and remove some dead code (#2504)
* Improve test coverage

* Clean up some un-used code

* Lower patch requirements on codecov
2017-07-17 23:31:42 +10:00
Lucas Azzola d62d1c5c56 Preserve parens with keyof, enforce parens with arrows with type params (#2503)
* Force parens around argument of simple arrow function if type annotation is present

* Preserve parens inside keyof operator
2017-07-17 13:32:33 +02:00
Lucas Azzola b3a4785cec Add Codecov badge to README 2017-07-17 00:03:51 +10:00
Lucas Azzola 71b2004391 Cleanup unused nodes, and turn on importMeta babylon plugin (#2498)
* Cleanup unused AST nodes

* Add tests for JSXNamespacedName

* Turn on importMeta babylon plugin

* Add tests for DeclareTypeAlias

* Add back TS*Keyword nodes, fix TS optional destructuring
2017-07-16 23:59:49 +10:00
Lucas Azzola b7fa01af17 Enable code coverage in CI (#2497)
* Enable code coverage in CI

* Disable codecov comment

* Ignore some statements from coverage reports
2017-07-16 21:49:37 +10:00
Lucas Azzola 188c466cd5 Don't call shouldHugType for function arguments, fixes #2458 (#2496) 2017-07-16 11:53:01 +02:00
Lucas Azzola 028d9e0ea7 Improve bind expression formatting (#2493)
* Improve bind expression formatting, fixes #1400

* Fix parenthesis with bind expressions, fixes #1446
2017-07-16 11:47:06 +02:00
Lucas Azzola 00d9aa208e Trim trailing whitespace from comments, closes #2422 (#2494) 2017-07-16 17:45:27 +10:00
Lucas Azzola 123d350524 Don't mask TypeScript errors without position information, #2361 (#2495) 2017-07-16 16:38:13 +10:00
Lucas Azzola bac9658687 Flatten x & y & z, and x ^ y ^ z, fixes #2445 (#2490) 2017-07-15 12:54:33 +02:00
Lucas Azzola b9b3da6ee9 Implement prettier-ignore inside JSX (#2487)
* Implement prettier-ignore inside JSX, closes #2467

* Re-enable babylon and typescript verification
2017-07-15 20:21:43 +10:00
Lucas Azzola acab856b96 Integrate 1.5.3 hotfix (#2489) 2017-07-15 20:16:41 +10:00
Alex Rattray f0e207280a Merge pull request #2398 from suchipi/improve_jsx_formatting
Improve JSX Formatting
2017-07-13 23:46:06 -07:00
Stephen Scott 3ed2bae1b4 Improve JSX ternary formatting
* Now JSX-mode ternaries only break if they need to. 
* Only the outermost ternary in a chain of JSX-mode ternaries will become a group.
* We don't wrap null in parens when breaking JSX-mode ternaries.

This commit also improves the test coverage and explanation in tests/jsx/conditional-expression.js.
2017-07-13 10:21:58 -06:00
Stephen Scott 757037948a Improve JSX Formatting
* Arrow Function Expressions returning JSX will now add parens when the JSX breaks
* Conditional expressions within (or containing) JSX are formatted in a more natural way (for JSX), especiall when chained
* JSX in logical expressions (|| or &&) is always wrapped in parens

Fixes #2208
2017-07-13 10:20:42 -06:00
John Backus 1691b85322 Fix <this.Component /> (#2472)
This is a workaround while waiting on
https://github.com/eslint/typescript-eslint-parser/issues/337.

Fixes #2471
2017-07-13 17:21:46 +10:00
Alex Rattray ef91e28434 Merge pull request #2442 from karl/jsx-inline-single-expression
Allow single expressions in JSX to be inline
2017-07-12 21:32:48 -07:00
Lucas Azzola 41318937d2 Add link to JSON schema in README 2017-07-12 21:29:57 +10:00
Evilebot Tnawi c1874c70ea refactor(cli): simplify ignore logic (#2455) 2017-07-12 00:36:16 +10:00
Blaine Kasten 438d5f0fe3 Add Hudl as a Prettier User (#2454)
* Add Hudl as a Prettier User

* Add Hudl logo
2017-07-12 00:16:01 +10:00
Lucas Azzola 1c806f81b2 Rename --resolve-config to --find-config-path (#2453) 2017-07-11 23:57:26 +10:00
Evilebot Tnawi 469059dc20 CLI: Support .ignore files (#2412)
Closes #2294
2017-07-11 23:33:46 +10:00
Lucas Azzola 34b0709bf0 Add documentation for configuration (#2452)
* Add documentation for configuration files

* Add CLI docs for configuration

* Support --no-config
2017-07-11 14:21:29 +02:00
Lucas Azzola 3136907a15 Expose clearCache function (#2451) 2017-07-11 20:40:51 +10:00
Lucas Azzola 25a5e3ffe3 Fix ignore unknown --no-semi, fixes #2448 (#2450) 2017-07-11 19:52:47 +10:00
James Henry ee822f99b9 Update tsep and add test for destructuring assignment (#2443)
Fixes #2229
2017-07-11 09:11:18 +10:00
Karl O'Keeffe 5e76ea7bdd Allow single expressions in JSX to be inline 2017-07-10 20:02:30 +01:00
Zac Colley b201c953f2 Make "print width" documentation clearer (#2383) [skip ci]
* Update print width documentation

* Update README.md

* Update README.md

Tried to improve first two sentences.
Moved explanation above table.

* Improve print width based on feedback

* Update README.md

* Update print width explanation
2017-07-11 00:07:32 +10:00
Lucas Azzola b25935d7a3 TypeScript: allow type assertions to hug (#2439)
* TypeScript: allow type assertions to hug, fixes #2437

* Update snapshots
2017-07-10 22:37:43 +10:00
Lucas Azzola dcccfed366 Implement cosmiconfig for workspace configuration (#2434)
* Implement cosmiconfig

* Add resolveOptions API and extname support

* Add --resolve-config and --config, rename resolveOptions to resolveConfig

* Move color to top-level CLI options

* Fix unknown param warning

* Change from {} to null when no config is found

* Change override API to emulate eslint

* Add test for eslint-style overrides

* Delete overrides from resolveConfig
2017-07-10 22:26:36 +10:00
Daniel Lo Nigro 3728749d92 Clean up "not needed anymore" sentence in README (#2435)
* "not needed anymore" → "redundant"

* Update based on feedback
2017-07-08 17:13:31 -04:00
Joseph Frazier 1e5ae50eba Update prettier_d description to mention configuration files 2017-07-08 15:10:22 -04:00
Joseph Frazier 0fb332b2f9 lint: Add yoda rule with range exception (#2433)
This required a small refactoring, but the code is less nested as a result.
See discussion at https://github.com/prettier/prettier/pull/2401#discussion_r125750068

http://eslint.org/docs/rules/yoda#exceptrange
2017-07-09 00:53:00 +10:00
Simen Bekkhus 1b4846b67d Format prettier with newer prettier (#2431) 2017-07-08 14:07:39 +02:00
Simen Bekkhus 3e184d8f37 Upgrade chalk (#2432) 2017-07-08 14:07:03 +02:00
Lucas Azzola 073a02bf1f Add missing $ in bash script 2017-07-08 17:48:21 +10:00
Lucas Azzola 324fc86618 Sync usage.md from main README 2017-07-08 17:45:52 +10:00
Lucas Azzola 4a320a9332 Add supervisory parens for bitwise operations (#2429)
* Add supervisory parens for bitwise operations, fixes #2424

* Flatten x | y | z
2017-07-08 17:31:28 +10:00
Lucas Azzola 7e96e01fba Add more supervisory parens, closes #187 (#2423) 2017-07-07 15:57:17 +02:00