Commit Graph

76 Commits (master)

Author SHA1 Message Date
Paco bcdb6936ba Remove unused text parameter from Comments#getSortedChildNodes (#4481) 2018-05-14 14:32:18 -03:00
Ika 1062f2a889
feat: support JSON.stringify formatting (#4450)
* test: move tests

* feat: support legacy JSON formatting

* fix: add missing assertion

* test: fix coverage

* fix: same output as JSON.stringify

* refactor: fix linting

* refactor: rename to json-stringify

* refactor: fix linting

* fix: should fix the production build

* docs: remove outdated name

* fix(playgound): add lib/parser-json-stringify.js

* feat(playgound): add example for json-stringify

* fix: no error on singleQuote string

* fix(playground): correctly load json-stringify

* fix: identifier is only allowed in ObjectProperty.key

* refactor: clearer
2018-05-14 09:12:25 +08:00
Ika 0f02940de2
refactor(javascript): move loc util (#4443) 2018-05-10 02:23:40 +08:00
Alexander Kachkaev cc734753fc Implement prettier.getFileInfo() method and --file-info CLI option (#4341)
* Implement prettier.getFileInfo() method and --file-info CLI option

* Add empty line between functions in index.js

* Support --plugin-search-dirs / pluginSearchDirs() in --file-info / getFileInfo()

* Address review comments by @ikatyang
2018-05-10 00:53:44 +08:00
Alexander Kachkaev 7345a38e64 Fix plugin API in globally installed Prettier and introduce optional --plugin-search-dir (#4192)
* Fix plugin API in globally installed Prettier and introduce optional --plugin-search-dir

* Use find-parent-dir instead of find-up and test autoloading (with mocked fn)

* Add two test cases where --plugin-search-dir is not .

* Do not mutate pluginSearchDirs argument in load-plugins.js

* Do not test automatic plugin resolution as mocking of "find-parent-dir" does not work due to rollup

* Document --plugin-search-dir / pluginSearchDirs and improve spacing

* Address @ikatyang's review comments

* Fix require path for third-party

* Undo alphabetic sorting of third-party scripts
2018-05-09 19:17:12 +08:00
Ika df3eb0cf68
refactor(massageAst): move target props to corresponding plugins (#4430) 2018-05-08 10:48:29 +08: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
Lucas Duailibe 8015e417c0
Separate entry for web bundle (#4386) 2018-04-26 13:38:57 -03:00
Lucas Duailibe 67f1c4877e
Refactoring: better boundaries for different parts of the project (#4364) 2018-04-25 13:29:35 -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
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
Ika 0ce4ce3138
fix(api): no regression for deprecated parser (#4072) 2018-03-01 00:14:30 +08:00
Christian Zosel d05a29da05 Allow plugins to override default options (#3991)
* refactor(cli): defer default value applying

* Allow plugins to override default options

* Move "defaultOptions" to top level of plugin

* Simplify implementation

* Attach plugin name

* Add pluginOptions to cli help

* Update snapshots

* Code review (immutable style)

* Add test for help output

* Use snapshot test, fix Object.assign

* Refactor to immutable style

* Add test case for automatic plugin resolution

* Add tests for applying and overriding default opts

* Remove "since" option

* Only set defaults for CLI args when no pluginDefaults are present

* Revert workaround, rebase to #4045

* Add basic documentation for `options` and `defaultOptions`
2018-02-28 00:20:02 +11:00
Lucas Azzola a0668129da
Do not require plugins to set 'since' field (#4038)
* Do not require plugins to set 'since' field

* Refactor
2018-02-24 19:00:51 +11: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 84c603623d
feat: support external options (#3775)
* refactor: wrap

* refactor: replace

* refactor: replace

* refactor: replace

* refactor: extract

* refactor: logger

* refactor

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* feat(support): add `showInternal` option

* refactor: use internal

* refactor

* refactor: extract

* refactor: extract

* refactor

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: reorder

* refactor: remove unnecessary

* refactor: reorder

* refactor: move

* refactor

* refactor

* refactor

* refactor: remove unnecessary

* feat: external options from CLI

* refactor: push/pop plugins

* feat: external options from config file

* refactor: remove unnecessary

* refactor

* refactor

* refactor

* fix: use `json-stable-stringify`

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: move

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: extract

* refactor: move

* refactor: extract

* docs: add comments

* refactor: sort

* refactor: sort

* refactor: rename

* refactor: remove unnecessary

* style: remove trailing whitespace
2018-01-28 00:24:25 +08:00
Ika dc26445e51
refactor(options): use supportOptions to generate CLI options (#3622)
* refactor(cli-constant): use supportOptions

* refactor(options): use supportOptions

* refactor(cli-util): use supportOptions

* fix: do not infer parser in multiparser

* chore: remove unnecessary package

* chore: trigger another travis build

* test: add kebab-case test to ensure no regression

* test: update snapshots
2018-01-18 15:26:27 +08: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 a27d19b2c1 Allow Plugins to preprocess text (#3664)
* Allow Plugins to preprocess text

* Actually pull up text

* Always expect the preprocessor to set the text

* Add tests for preprocessing

* Remove unused variable
2018-01-10 00:27:26 +11:00
Lucas Azzola e5d6a4704f
Automatically load plugins from package.json (#3624)
* Automatically load plugins from package.json

* Fix build by adding json extension

* Fixup misuse of options argument

* Rewire graceful-fs to fs

* Document graceful-fs issue

* Alias graceful-fs to fs in Rollup
2018-01-05 21:09: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
Jimmy Jia b63c669ed9 Support plugins field in config (#3584)
* Actually support plugins field in config

* Resolve plugin parsers

* Fix default from CLI for "plugins"
2017-12-28 20:08:58 +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