Commit Graph

34 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
Zhongliang Wang 2cfd8fb518 Support TypeScript 3.7 (and drop Node 6 support for direct inst… (#6657)
* WIP: Support TypeScript 3.7

* Add support for `asserts` keyword; Update snapshots

* Update typescript-estree to v2.5.0 to remove the dependency on chokidar

* Update TypeScript

* Update CHANGELOG.unreleased.md

* Add examples for TypeScript 3.7

* Update TypeScript 3.7 to latest dev version

* Correct wording

* Support `declare` keyword on class members (TypeScript 3.7 feature)

* Update Changelog and downgrade TypeScript from 3.8.0-dev to 3.7.1-rc

* Add a note regarding to dropping Node 6 support for direct installation

* tweak build config to repair build

* update CHANGELOG.unreleased.md

* TSTypePredicate microrefactoring

* fix formatting

* clean up tests

* fix parens for optional chaining inside computed properties

* update CHANGELOG.unreleased.md

* unify output across parsers for template literals

* enable more tests with optional chaining

* fix unneeded parens inside computed key of OptionalMemberExpression

* fix paren issues for OptionalCallExpression

* more fixes for OptionalCallExpression

* @typescript-eslint/typescript-estree 2.5.1-alpha.4

* fix lint

* revert build hacks

* fix one more parens issue

* @typescript-eslint/typescript-estree 2.5.1-alpha.5, remove loggerFn override

* drop node 6 for direct installing from github

* fix another parens issue, disable some tests for flow

* workaround for flow bug

* fix issues with comments


Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2019-10-28 17:53:57 +01:00
Christopher Chedeau 43d03209d2
Update ?? precedence to match stage 3 proposal (#6404)
The spec was updated ( https://tc39.es/proposal-nullish-coalescing/ ) with the following two changes:
- ?? has lower precedence than ||. (previously equal)
- ?? cannot immediately contain, or be contained within, an && or || operation. (parens are now required)

The safe way to upgrade is to run prettier with just this change so that parenthesis are properly added. Then to upgrade the parser (only flow supports the new precendence in the next release, babel hasn't been updated yet) in prettier so that the new precedence is being used. Failure to do so will result in parse errors because of missing parenthesis so we will not have silent errors.

There was only 44 callsites mixing || and ?? in a confusing way in the Facebook codebase so it shouldn't be a huge deal in practice.
2019-08-20 14:26:21 -07:00
Georgii Dolzhykov e4f0df5bed fix: nested embeds (JS in HTML in JS) (#6038) 2019-05-27 14:42:13 -03:00
Mykola Bilochub c95b81dd3d fix(markdown): correctly determine count of backticks in inline code (#6110) 2019-05-14 12:51:31 -03:00
fisker Cheung 9352331f1a Remove duplicated getLast (#5889) 2019-02-21 12:03:35 -03:00
Nathan Totten a093bb3f7b Adds LWC Parser to support unquoted interop attributes (#5800)
This pull requests adds a new parser option `lwc`. This is the same as the HTML parser, but it adds support for unquoted HTML attributes per the needs of LWC. See: #5627
2019-02-01 13:58:50 +08:00
mattia richetto 031f6e860f Update string-width to support emoji natively (#5646)
the `string-width` package v3 now supports emoji width https://github.com/sindresorhus/string-width/pull/17
2018-12-18 08:13:12 +08:00
Ika 952bc0cc03
fix: get rid of CRLF (#5494) 2018-12-08 18:28:29 +08:00
Ika e0f74cb94d
fix(javascript): do not attach to block if it's not behind right func paren (#5435) 2018-11-11 00:10:19 +08:00
Ika 514b6d3741 Bump Prettier dependency to 1.15.0 2018-11-07 09:12:25 +08:00
Stefan Mirea e17512adcd Add an option to print single quotes in JSX (#4798)
* feat(option-singleQuote-jsx): Added jsSingleQuote

* feat(option-singleQuote-jsx): Refactored to use a simple jsxSingleQuote flag

* feat(option-singleQuote-jsx): Fixed borked rebase

* feat(option-singleQuote-jsx): Updated snapshots

* feat(option-singleQuote-jsx): Resolved pending comments

* feat(option-singleQuote-jsx): Removed assert

* Fixed merge conflicts

* Updated snapshots after merge conflicts
2018-11-04 16:36:00 -05:00
Ika 5e8a4a115a
feat: support HTML/Vue/Angular (#5259) 2018-11-04 23:03:07 +08:00
Evilebot Tnawi 023a8b78df feat: more shared utils for plugins (#5254) 2018-10-17 07:53:38 -07:00
Kevin Gibbons cbcd24a5b2 Correct parentheses for mixed exp/mod (#5243)
Fixes #5238.

cc @duailibe for the [original change](https://github.com/prettier/prettier/pull/4413). I basically undid that PR because it didn't look to me like `shouldFlatten` made sense as the place to introduce the behavior it was going for, but I might have misunderstood something.
2018-10-12 12:33:47 -04:00
James Henry 81cf08118e
Drop-in replacement: typescript-estree for typescript-eslint-parser (#5139) 2018-09-25 15:44:21 -04:00
Ika 91206891cd
fix(markdown): do not add whitespaces between Latin and Hangul (#5040)
Based on https://github.com/prettier/prettier/issues/5028#issuecomment-417825085, it seems Korean text uses conventional space so we're not going to add whitespaces between Latin and Hangul.
2018-09-02 16:20:22 +08:00
Suchipi 3bfaf6626c
Never inline decorators, unless they're lone parameter decorators (#4830)
Fixes #2613.
2018-07-20 13:48:37 -06:00
Ivan Babak 95cc2c97b5 fix(perf): shortcut getStringWidth for ASCII-only strings (#4776) (#4790) 2018-07-01 19:47:55 -07:00
Lucas Duailibe cb1c52ad08
Break JSX in arrow functions in JSX expressions (#4601) 2018-06-08 15:15:50 -03:00
Lucas Duailibe 9da80415f4 Bump own prettier dependency 2018-05-27 15:22:34 -03:00
Lucas Duailibe 52a2a46b3c
New build system (#4449) 2018-05-24 15:30:45 -03:00
Ika a9eb68296c
fix(markdown): do not merge continuous cjk if proseWrap=preserve (#4504)
* test: add tests

* fix(markdown): do not merge continuous cjk if proseWrap=preserve

* fix: remove trailing comma for node4
2018-05-19 13:53:34 +08:00
Brian Ng 857c55bd61
Keep parens around do-expressions inside ExpressionStatement (#4479) 2018-05-15 11:41:17 -05:00
Lucas Duailibe bafa76f613
Wrap modulo operation in parens inside additive operation (#4413) 2018-05-03 12:28:37 -03:00
Lucas Duailibe e3223fe9af Prevent flattening multiplicative operations (#4407) 2018-05-02 23:48:40 +02:00
Lucas Duailibe 67f1c4877e
Refactoring: better boundaries for different parts of the project (#4364) 2018-04-25 13:29:35 -03: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
Ika 1f84880fb1
refactor: remove duplicate mapDoc (#4310) 2018-04-15 00:07:03 +08:00
Suchipi Izumi bdc5e0073d Bump own prettier dependency to 1.12.0 2018-04-11 22:39:13 -06: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
Ika 6c0dd74518 feat(support-info): add `options` field (#3433)
* refactor: rename supportTable with supportLanguages

* refactor: use `dedent`

* test: reduce unnecessary data

* feat(support-info): add `options` field

* add `showDeprecated` option
* add `showUnreleased` option

* test: snapshot diff

* fix(support): add missing `since`

* fix: add missing `category`

* refactor: use template tag

* fix: `trailingComma:true` should redirect to `trailingComma:es5`

* refactor: reorder parser

* refactor: fix linting

* refactor: move options

* refactor: move options to printers
2017-12-31 15:34:37 +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