Commit Graph

17 Commits (f059d7a31bf6db6f82877b00767e43667e195268)

Author SHA1 Message Date
Shinigami f059d7a31b JSDoc type added in `src/common/util.js` (#6788)
* JSDoc type added in `src/common/util.js`

* skip can return false

* Add TBD for false - 1 not allowed

* Define typedef SkipOptions

* Use method generic for node param

* Define node param for setLocStart and setLocEnd

* Copy idx param to local variable

* Add @returns false

* Update Utility functions docs

* hasNewline param index: allow only number

* Add condition

* Add function keyword to docs

* Add prettier-ignore

* Improve condition

* Remove TBD comment

* Use single quotes

* Add type to oldIndex

* Use singleline JSDocs
2019-11-05 13:28:44 +02:00
Georgii Dolzhykov 977b828666 Get rid of TSParenthesizedType nodes before proceeding with formatting (#6605)
* get rid of TSParenthesizedType nodes before proceeding with formatting

* fix parens for TSIndexedAccessType, TSFunctionType, TSConditionalType

fixes #6603

* workaround edge cases with one-item unions and intersections

* fix parens for TSInferType

* fix parens for rest elements in tuple types

* refactoring

* fix function types in conditional types

* move tests for rest and optional tuple elements

* fix comment issues

* tests for unions and intersections

* add parens around multiline unions in tuple

* move the parens check for TS nodes closer to the one for Flow nodes

* update CHANGELOG.unreleased.md

* remove dead code

* fix parens for TSConstructorType

* better wording in CHANGELOG.unreleased.md
2019-10-14 15:00:21 +03:00
Warren Seine 3a9006659e Fix trailing comment output when the printer returns a doc instead of a string. (#5930)
Previously, Prettier printed `[Object object]` in that situation.
2019-03-03 11:15:08 -08:00
Wei-Wei Wu 91c20f7fbe Rename "babylon" with "babel" (#5647) 2018-12-27 21:05:19 +08:00
Ika 5e8a4a115a
feat: support HTML/Vue/Angular (#5259) 2018-11-04 23:03:07 +08:00
Prashant Andani 12cb8a9688 Use destructuring for readability and optimzations at 'for' loop length property… (#4842)
* Use destructuring for readability and optimzations at for loop length property

* Destructure variables for easy maintainability of code

* PR review fix

* refactor: fix linting
2018-07-16 22:39:41 +08:00
Lucas Azzola b0cb63a7bb
Use destructuring for imports (#4554)
* Use destructuring for imports

* Clean up integration tests

* Use moduleNameMapper for require_prettier
2018-05-27 21:36:12 +10:00
Paco bcdb6936ba Remove unused text parameter from Comments#getSortedChildNodes (#4481) 2018-05-14 14:32:18 -03:00
David Sheldrick d77f5e9c3a Fix cursor offset tracking (#4397)
* handle cusor position relative to comments correctly

* use more robust method of cursor offset tracking

* add support for cursorOffset with rangeStart/End

* add tests for cursorOffset

* use old JS syntax for node4

* add another cursor offset test case

* remove trailing whitespace in cursor tests

* fix null findNodeAtOffset handling

* remove dead code

* add more test cases

* use indexOf for node4

* revert comments.js

* add more comment tests

* change tests infra

* Fix AST_COMPARE

* move CURSOR to top level of file

* mutate result

* use es6 property shorthand

* simplify diff offset calculation

* put remaining test cases in individual files
2018-05-01 09:42:59 -03:00
Ika 317f3a3c56
feat: split out JSON5 (#4367)
* feat: split out JSON5

* test: update snapshots

* test: update debug-check tests

* feat(playground): use JSON's code sample for JSON5

* fix: add missing trailing newline
2018-04-25 22:10:22 +08:00
Mike Grip 4c464133ac feat: adding plugin ability for isBlockComment (#4347)
* adding plugin ability for isBlockComment

* refactor to remove private util def

* remove old fn def
2018-04-19 13:31:08 -07:00
Mike Grip d9ee183f5b feat: enable plugin-specific comment functionality (#4182)
* feat: enable plugin-specific comment functionality

This change enables language plugins to provide their own "handleComment" function. To do so, we're exposing the addLeadingComment, addTrailingComment, and addDangling comment functions which attach comment nodes correctly in the ast which will get handled by prettier core when printing.

* moving js comment functionality to plugin
2018-03-20 18:39:28 -07:00
Christian Zosel fac08034e7 Split out location extraction into plugin config (#3777)
* Split out location extraction into plugin config

* Reduce set of exported function, rebase to current master

* Pass custom locStart/locEnd fn's directly to affected methods

* (wip) always use locStart/locEnd from plugin

* Convert graphql implementation

* Convert HTML implementation

* (wip) convert JS implementation

* Remove unused variables

* Continue conversion of JS implementation

* Replace "util.locStart" with direct call to "options.locStart"

* Remove util closure

* Add unit test for structure of shared util

* Fix linting error, simplify locStart/End implementations
2018-02-09 23:17:48 +11:00
Thorben von Hacht 1a1de60491 Prettier extends and implements when not fitting in same line (#3689)
* Added prettier layout for class extends and implements

* Added prettier layout for class extends and implements, fix with keeping it in online if it fits

* Added prettier layout for class extends and implements, fixed tests as a side change

* Extends implements comments in same line fix

* Extends implements comments in same line without ugly workaround

* added empty line to test typescript_class/extends_implements.ts

* If only one extends keep old behaviour

* Removed console logs
2018-01-13 16:31:51 +11:00
Marcel Jackwerth 6260629f18 [Plugins] Allow custom getCommentChildNodes (#3639)
* [Plugins] Allow plugins to specify their own getChildNodes for comment printing

* Rename getChildNodes -> getCommentChildNodes
2018-01-03 23:58:53 +11:00
Lucas Azzola ee148bfded
Split up comment printing (#3575)
* Split up comment printing

* Refactor plugin handling

* Allow multiparser to use options normalization

* Rename to canAttachComment

* Add inline comment

* Format code

* Use prettier.__debug to get AST
2017-12-27 00:04:09 +11:00
Lucas Azzola 4c9d4061da
Prettier Plugin API (#3536)
* Move files around in preparation for refactor

* Update paths in build script

* Extract generic printing logic from the JavaScript printer

* Conform printer API

* Fixup decorator handling

* Fix multiparser

* Create plugin entry for markdown

* Create plugin entry for javascript/typescript

* Create plugin entry for html

* Create plugin entry for graphql

* Create plugin entry for css/less/scss

* Move JSON to JS plugin entry

* Integrate plugins into getSupportInfo()

* Move astFormat to parser definition

* Move util to common

* Implement parser loading

* remark -> mdast

* Rename cli/cli -> cli/index

* Rename builder -> doc package, fix printer resolution

* Fix doc shape assumption in CSS-in-JS logic

* Fix third-party.js prod resolution

* Fixup build-docs script

* Distribute multiparser code

* Remove requirement to forward options

* Flatten closure

* Remove debug directory

* Expose doc

* Add external plugins

* Pass options to loadPlugins

* Export getParsers

* Pin resolve version

* Use getSupportInfo in Markdown embed

* Document plugin API

* Update build-docs

* Add CLI for plugins

* Lint docs

* Fixup build.js

* Add vue language

* Fixup multiparser for vue

* Upgrade rollup and rollup-plugin-commonjs

* Fixup third-party build

* Change AST format in docs
2017-12-26 12:23:50 +11:00