Commit Graph

202 Commits (master)

Author SHA1 Message Date
Ika 49e2f77bff
refactor: extract options-normalizer/validator (#5020)
- Uses [`vnopts`](https://github.com/ikatyang/vnopts#readme)
- This way it should be easier to support language-specific options (https://github.com/prettier/prettier/pull/4798#issuecomment-407258477) and map the common options to language-specific options using [`forward`](https://github.com/ikatyang/vnopts#forward), e.g. `singleQuote: true` -> `"javascript/singleQuote": "js"`, `singleQuote: false` -> `"javascript/singleQuote": "none"`.
2018-08-31 11:26:07 +08:00
Ika 1790211f76
feat: support MDX (#4975)
* feat: support MDX

* refactor: flip condition
2018-08-13 22:23:09 +08:00
Ika 82a12a58a8
fix(config): better error message for unsupported extension (#4969) 2018-08-11 16:35:18 +08:00
Ika 53c83f97f5
fix: guess line ending before preprocess (#4957) 2018-08-09 10:51:08 +08:00
Ika 3842cbb118
fix(typescript): use the first error when both failed (#4947) 2018-08-09 10:21:00 +08:00
Ika e72cb538f9
fix: update flow support info (#4943) 2018-08-08 23:47:49 +08:00
Jorge Gonzalez 7d78ce68ef feat(config): support TOML configuration files (#4877)
* Add initial support for TOML in configuration files

* Missed brace

* Fix snapshots

* refactor: move loadToml to utils

* Use @iarna/toml

* Add tests for loadToml

* Fix test for CI

* Remove jest-extended

* Create snapshot for load-toml

* Add feat to docs

* lint docs

* Use @iarna/toml/parse-string

* Change path string
2018-08-03 06:27:19 -04:00
Lucas Azzola a938076ae5
Ignore .git, .svn and .hg directories (#4906)
Fixes #4895
2018-07-30 00:08:51 +10:00
Ika 440ab4f60b
refactor: upgrade to cosmiconfig@5 (#4899)
* refactor: upgrade to cosmiconfig@5

* fix: use custom require
2018-07-29 16:57:36 +08:00
Ika 1fe0b01bd4
fix(yaml): no wrong loc info for CRLF (#4863)
Context: https://github.com/prettier/prettier/issues/4856#issuecomment-405982539

Workaround for eemeli/yaml#20
2018-07-19 21:50:27 +08:00
Ika 1a2c4e663e
chore: use pre-release version number on master (#4855)
* chore: use pre-release version number on master

* docs: tweak comment
2018-07-18 09:38:26 +08:00
Ika ed0ecdad18 fix(json): do not put values on a separate line from the key (#4852)
* test: add tests

* fix(json): do not put values on a separate line from the key
2018-07-17 18:08:59 -03:00
Ika 2271992446
feat(json): add jsonc to aliases and use it to find parser in markdown embed (#4734) 2018-07-07 20:46:34 +08:00
Ika 432c9d7d04
feat(yaml): support proseWrap (#4742)
- support `proseWrap` in `yaml`
- move `proseWrap` to `commonOptions`
- update to `yaml@1.0.0-rc.4` and `yaml-unist-parser@1.0.0-rc.1`
2018-07-04 00:28:47 +08:00
Ika 9bb8edf96a
feat: support .js.flow (#4777)
* feat: support .js.flow

* feat: add Flow language entry
2018-07-01 16:18:08 +08:00
Ika 0b659b898d
feat: update linguist languages (#4741)
Context: https://github.com/prettier/prettier/pull/4734#issue-196702272

Languages should be easy to maintain now.
2018-06-28 08:24:02 +08:00
Warren Seine 6c482e2e6c Expose `isPreviousLineEmpty` to plugins (#4747). (#4748) 2018-06-25 23:20:00 -06:00
Ika c38e6af301
fix(yaml): add missing `since` field (#4739) 2018-06-23 17:04:47 +08:00
Ika dcf44ffbdc
feat: support YAML (#4563)
* feat: support YAML

* fix: do not indent sequence in mappingValue

* docs: add yaml to index.md

* fix: reduce `SyntaxError: Node#parse consumed no characters`

* chore: remove old-build and new-worker.js

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* fix: no space after `<<`

* fix: add yaml to standalone test

* test: add tests

* fix: next empty line in flow collection

* fix: tabs are not allowed
http://yaml.org/spec/1.2/spec.html#space/indentation/

* fix: update parser

* feat: rewrite the mappingItem logic
* feat: indent sequence in mapping
* feat(doc): add ifBreak#groupId and group#id

* chore: fix node 4

* chore: add tools_yaml.svg

* chore: remove resolved TODO

* refactor: remove unnecessary workaround

* chore(worker): importScriptOnce

* chore(build): rename with babelPlugins

* make it rollup compatible

* feat: support singleQuote

* refactor
2018-06-21 10:29:42 +08:00
Ika 18aa527adc
feat(api): support relative paths for plugin(SearchDir)s in config files (#4667)
* feat(api): support relative paths for plugin(SearchDir)s in config files

* fix: convince appveyor
2018-06-15 04:25:03 +08:00
Ika 75e86b9e6b
fix(cli): no regression for --debug-check + --list-different (#4600) 2018-05-31 00:42:26 +08:00
Ika e9b7c7ff9b
chore: fix 2 TODOs (#4591) 2018-05-29 22:05:25 +08:00
Lucas Duailibe 1350edc5a6 Revert no parser error for API (#4587)
* Revert no parser error for API

* use warn
2018-05-28 23:43:44 -06:00
Lucas Azzola 19cdd5fde2
Get tests passing on Windows (#4579)
Closes #4564
2018-05-28 21:46:55 +10:00
Lucas Duailibe 8892b14d8a 1.13.0 2018-05-27 15:19:39 -03: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
Lucas Duailibe 5c6e0802af
Don't default parser to babylon (#4528)
* Don't default parser to babylon

* Different default values according to version

* Fix error logging

* Add tests specifically for parser inference

* Add another test case

* Add API test
2018-05-23 16:55:06 -03:00
Lucas Duailibe 1088618b35
Fix wrong test (#4507) 2018-05-18 21:43:54 -03:00
Suchipi ec45dc9a4c
(refactor): Move common options out of JS plugin (#4445)
* (refactor): Move common options out of JS plugin

* Add Common category to playground
2018-05-15 14:14:50 -06: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
Alexander Kachkaev bc78541274 Improve plugin resolution when path does not start with ./ (#4451)
* Fix plugin resolution when path does not start with ./

* Minor consistency fix: use "if (resolvedPluginSearchDir) {...}" in load-plugins

* Use more appropriate quotes in plugin-resolution.js

* Try both local paths and node modules when resolving plugins manually

* Test bespoke plugin loading by node module name

* Simplify getFileInfo() as suggested by @j-f1

https://github.com/prettier/prettier/pull/4341#discussion_r187112707
2018-05-10 10:27:41 +10: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 9cc5d4f162
fix(json): jsonc is considered JSON instead of JSON5 (#4374)
* fix(json): jsonc in consider JSON instead of JSON5

* feat: add json5 id
2018-04-27 00:09:36 +08: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
Ika 5d7b14856b
fix(schema): support array type (#4312)
* test: add test

* fix(schema): support array type

* fix: convince CI

* refactor: another way to convince CI
2018-04-15 00:06:43 +08:00
Lucas Duailibe 240f09794b
Fix printing ignored files with --debug-check (#4066) 2018-03-01 13:03:54 -03: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
Joseph Frazier 5153b15245 Respect EditorConfig when `--config` is passed (#3992)
* Respect EditorConfig when `--config` is passed

* Clarify config-resolution test file

See https://github.com/prettier/prettier/pull/3255#issuecomment-348420546

* Update test snapshots
2018-02-24 19:11:23 +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 47714f5d4b
feat(plugins): change external options to be plugin-level (#3924) 2018-02-09 00:06:38 +08: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
TheDancingCode ea5bfb44e4 Fix tests on windows (#3785) 2018-01-22 11:20:50 -07: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
Lucas Azzola dd78f31aaf
Run production tests on npm package (#3730)
* Run production tests on npm package

* Put back fast finish
2018-01-13 03:19:20 +11:00
Lucas Azzola a10418ee80
Bump Prettier to 1.10.1 (#3699)
* Bump Prettier to 1.10.1

* Fix relative paths
2018-01-11 01:13:09 +11:00
Lucas Azzola bae21cb166 1.10.0 2018-01-10 23:08:15 +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
Lucas Duailibe 2cb9498ab6 Output files as-is if ignored (#3618)
* fix --stdin-filepath

* output file as-is without --write

* return early

* use writeOutput
2017-12-31 18:08:09 +01: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
Joseph Frazier 7b211eab24 editorconfig: Only search for .editorconfig up to the VCS directory (#3559)
* editorconfig: Only search for .editorconfig up to $PWD

This addresses https://github.com/prettier/prettier/issues/3558

I'm not sure if this is the best way to find the "project root", but it
seems better than before.

* editorconfig: Search for `.editorconfig` up to the VCS directory

This uses [find-project-root] to find the nearest directory containing `.git` or `.hg`

See here for context: https://github.com/prettier/prettier/pull/3559#issuecomment-353756948

[find-project-root]: https://github.com/kirstein/find-project-root

* editorconfig: Add test for finding VCS directory

It's a little hacky in that the .hg file isn't really a Mercurial
repository, but it's enough to illustrate the intent. See here for
context: https://github.com/prettier/prettier/pull/3559#issuecomment-353857109
2017-12-26 18:16: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
Christopher Chedeau c40b061b80
[vue] Introduce proper support for Vue Single File Components (SFC) (#3563)
There's a lot of demand for vue sfc (#2097). This introduces partial support for them: all the html is printed as is, except for the script and style tags which are printed using prettier. I believe that this should cover a lot of the use cases while being simple to support and if we want we can extend to more in the future.

I copy pasted the html parser used by vue (it's just a single 400 lines file) so that we don't run the chancesof conflicts. I'm also very conservative: I only print the style and script at the top level and for the lang attributes we support.

I expect this to be landable as is and provide value, review welcome :)
2017-12-25 01:15:33 +01:00
Anatolie Rotaru d4101169e5 Fix PostCSS VS Code integration (#3454) 2017-12-19 00:05:39 +11:00
Lucas Azzola ed80d6c5bd
Make all CLI logging go through a logger (#3515)
* Make all CLI logging go through a logger

* Add --loglevel docs

* Change default loglevel to log

* Update snapshots

* Switch to YAML eslint files
2017-12-18 23:22:07 +11:00
Lucas Azzola d1c97b3622
Convert eslint config and users/languages/editors files to YAML (#3516)
* YAML all the things

* Cleanup website data files

* Update edit links
2017-12-18 21:55:10 +11:00
Georgii Dolzhykov 5c6b93a654 Add "JSON with comments" to vscodeLanguageIds (#3496) 2017-12-16 11:45:51 +11:00
Lucas Duailibe c986f45ec7 fix lint 2017-12-05 17:48:10 -02:00
Lucas Duailibe 46f657bbaa add another test case 2017-12-05 16:30:21 -02:00
Lucas Duailibe 639c523885 Skip folders in CLI pattern 2017-12-05 16:07:27 -02:00
Joseph Frazier cecf0657a5 Re-add EditorConfig support (undo #3213) (#3255)
* Revert "Revert "Respect EditorConfig settings" (#3213)"

This reverts commit d2241fc0d5.

* Comment out EditorConfig docs

See https://github.com/prettier/prettier/pull/3213#issuecomment-343009769

* editorconfig: Support `indent_size = 0`

See https://github.com/prettier/prettier/pull/2760#discussion_r137447715
and c38b84c42a

* Revert "Comment out EditorConfig docs"

This reverts commit ddfa529c55cac4853a1e76e00c8b5e3ef158c01f.

* Mark EditorConfig functionality as v1.9.0+

See https://github.com/prettier/prettier/pull/3255#discussion_r150432508

* editorconfig: Upgrade editorconfig-to-prettier to 0.0.4

* editorconfig: Only enable for CLI, by default

https://github.com/prettier/prettier/pull/3255#issuecomment-348420546

* editorconfig: Add tests confirming that editorconfig is ignored by default in the API

https://github.com/prettier/prettier/pull/3255#issuecomment-348420546

* editorconfig: Add/fix CLI option parsing

* editorconfig: Move docs from configuration.md to options.md

* editorconfig: Add `oppositeDescription` to show docs for `--no-editorconfig`

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154542792

* editorconfig: Update test snapshots

* editorconfig: Remove unnecessary options parsing code

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154544560

* editorconfig: Move docs from options.md to api.md and cli.md

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154545979

* resolveConfig: return null if both .prettierrc and .editorconfig are missing

Addresses https://github.com/prettier/prettier/pull/3255#discussion_r154574613

* Don't add now-failing tests

The way these tests work, both `tests_integration/cli/config/.prettierrc`
and `.prettierrc` apply to `tests_integration/cli/config/editorconfig/file.shouldnotexist`,
so the test wouldn't work even on master. Here's a way to confirm that:

```js
const path = require('path')
const assert = require('assert')
const prettier = require('./')

const file = './tests_integration/cli/config/editorconfig/file.shouldnotexist'
console.log(prettier.resolveConfig.sync(file))
assert(prettier.resolveConfig.sync(file) === null)
```
2017-12-05 09:28:27 +11:00
Ika 073c0b16d8 feat(markdown): add `proseWrap: "preserve"` option (#3340)
* test: add test case

* feat(markdown): add `proseWrap: "preserve"` option

* test: add tests

* docs(options): update `proseWrap`

* feat(markdown): change default to `proseWrap: "preserve"`

BREAKING CHANGE

* docs(options): update `proseWrap`

* test: specify option explicitly

* Fix lint after merge

* Fix error after merge
2017-12-02 09:48:40 +11:00
Brian Ng d52d721cd1 Bump babylon to 7.0.0-beta.33 (#3372) 2017-12-02 09:39:10 +11:00
Suchipi Izumi 41a9ababc3 Add updated snapshot
Whoops, forgot this
2017-11-27 22:27:34 -07:00
Stephen Scott 9a1e408a3f Add option and specs (no implementation yet)
These new snapshots are from https://github.com/prettier/prettier/pull/2676
2017-11-27 22:26:58 -07:00
Ika a1d878acc7 fix(cli): respect `--ignore-path` when using `--stdin-filepath` (#3309) 2017-11-23 21:54:04 +11:00
Ika 76efb33e75 chore: setup markdown formatting (#3224)
* chore(deps): upgrade prettier to v1.8.2

* chore: setup lint-docs script

* docs: add `<!-- prettier-ignore -->`s

* docs: format docs

* Revert "docs: format docs"

This reverts commit 6dba903987dddc498cb589ca311905f25b6aee53.

* chore(prettierrc): set `--no-prose-wrap`

* docs: format docs

* Revert "docs: format docs"

This reverts commit 139bd744b6921916be8fac4fa3bab83bae5d12df.

* docs: tweak

* docs: format docs

* chore: rename .prettierrc

* chore: rename back to .prettierrc

* chore: split out third-party

* refactor: fix linting

* chore: do not split out third-party on website
2017-11-22 22:27:40 +11:00
Lucas Azzola d2241fc0d5
Revert "Respect EditorConfig settings" (#3213)
* Revert "Respect EditorConfig settings (#2760)"

This reverts commit 8f58ca0f48.
2017-11-09 11:38:58 +11:00
Joseph Frazier 8f58ca0f48
Respect EditorConfig settings (#2760)
This fixes https://github.com/prettier/prettier/issues/42.
It adds support for .editorconfig's `indent_style`, `indent_size`, `tab_width`,
and `max_line_length` properties.

It doesn't support the `end_of_line` property as described in
https://github.com/prettier/prettier/issues/42#issuecomment-327073326,
but that could be added later. The same goes for `quote_type`
(https://github.com/prettier/prettier-atom/issues/293#issue-267288335).

* Make test .prettierrc not set config for all file extensions

This makes it easier to keep tests isolated.
2017-11-08 14:30:28 -05:00
Ika 4f1a2c4108 feat(markdown): add `--no-prose-wrap` option (#3199)
* feat(markdown): add `--no-prose-wrap` option

* refactor: fix typo

* refactor: fix typo

* refactor: reduce duplicate code

* docs: mention the option is for markdown
2017-11-08 21:01:06 +11:00
Ika 76ee59a191
chore(deps): update prettier to 1.8.0 (#3167)
* chore(deps): update prettier to 1.8.0

* refactor: fix linting
2017-11-07 16:42:38 +08:00
Lucas Azzola 3f13ab08ab
Update getSupportInfo snapshot for 1.8.0 (#3164) 2017-11-07 15:28:23 +11:00
Lucas Azzola 71a5533c4e
Move all docs to website (#3139)
* Sync README -> docs/options.md

* Sync README -> docs/*.md

* Misc fixups

* Remove markdown-toc

* Remove insert-pragma from ToC

* Never again!

* Move all docs to ./docs

* Remove yarn toc

* Fix inter-doc links

* Fix links in footer

* Clean up README.md

* Add basic description to README.md

* Use flat badges

* Move editor guides to website

* Improve prettier-ignore docs

* Fixup bad find/replace

* Add JSON to README

* Fix custom parser API link

* Fixup GitHub centering, add downloads badge

* Add 1.8 docs

* docs(website): mention markdown on homepage (#1)

* Add intro

* Add watching-files.md

* Fix markdown syntax highlighting

* Switch back to .md links
2017-11-07 14:39:07 +11:00
Lucas Azzola e436adae04
Implement getSupportInfo() and use it for inference (#3033)
* Implement getSupportInfo() and use it for inference

* Add comment with source of languages.yml

* Fix build, pin semver

* Simplify test snapshots

* Remove stray 'type' property

* Fix parser being overwritten

* Don't infer unreleased parser from extension

* Add CLI and docs for support info
2017-11-03 18:06:25 +11:00
Lucas Azzola d5de6ac84f Delete $schema from resolved config 2017-10-18 23:54:55 +11:00
Lucas Azzola 21d7561ecd Resolve file paths relative to config file (#3037)
* Add currently passing test case for #3005

* Fix test to fail without code change
2017-10-15 18:32:16 +11:00
Ika 2ef879f20d feat(cli): add `--loglevel` option (#2992)
* feat(cli): add `--loglevel` option

* fix: handle error from invalid option

* fix: choice value and shouldLog logic

* test: fix test cases

* fix: change log style

* test: truncate snapshots

* test: reduce duplicate code

* test: use patterns instead of snapshots

* test: fix regex
2017-10-13 20:17:01 -05:00
Ika 9f6f3e7355 feat: support markdown (#2943)
* feat(markdown): inital implementation

* feat(markdown): support strong

* fix: add missing default value

* feat(markdown): support inlineCode

* feat: support delete

* feat: support link

* feat: support image

* feat: support blockquote

* feat: support heading

* feat: support code

* feat: support yaml

* feat: support html

* feat: support list

* feat: support thematicBreak

* feat: support table

* feat: support linkReference

* feat: support imageReference

* feat: support definition

* feat: support footnote

* feat: support footnoteReference

* feat: support footnoteDefinition

* test(cli): update snapshots

* refactor: extract SINGLE_LINE_NODE_TYPES

* refactor: printChildren

* fix: correct newlines

* test: add trailing newline

* fix: blockquote formatting

* fix: node types

* fix: break line correctly

* fix: remove unnecessary properties to make AST_COMPARE happy

* fix: escape `|` in tableCell content

* fix: unexpected line break

* fix: ast difference from loose list

* fix: html break lines

* refactor: fix linting

* fix: normalize ast

* fix: escape specific chars

* test: add more tests

* fix: build markdown parser

* chore: remove unnecessary *.log

* fix: escape html entity

* feat: support prettier-ignore

* fix: line break for non-loose listItem

* feat: support formatting `code` based on `lang`

* fix: add `jsx` and `tsx`

* fix: use multiparser

* refactor: fix linting

* test: update test case 😉

* feat: switch to `_` style emphasis

* fix: sequence list should use different prefix

* test: add tests

* fix: do not print additional new line after `prettier-ignore`

* fix(list): enforce `1.` to avoid unnecessary git diff

* feat: enable `commonmark` option

* feat: support `break`
* fix: escape backslash
* refactor: escape html entity using backslash

* fix: respect autolink-style link

* feat: support md`...` and markdown`...`

* docs: replace ands with commas

* fix: respect indented code block

* fix: respect html entity

* docs: add docs for modified MDAST

* fix: inlineCode is breakline-able

* feat: support backtick in inlineCode

* feat: support a-lot-of-backtick in fenced code block

* feat: use `~~~`-style code block in js template

* fix: respect escaped chars

* fix: use `*`-style emphasis for invalid `_`-style output

* test: add test cases

* fix: use `- - -`-style thematicBreak to avoid conflict with yaml

* fix: remain the same content for linkReference identifier

* fix: `inlineCode` gap can be a line break

* fix: `html` should not print trailing spaces if it's in root

* refactor: fix typo

* fix: wrap `definition`'s url if there's whitespace

* fix: remove unnecessary whitespace at the end of paragraph

* fix: fix: remove unnecessary whitespace at the start of paragraph

* fix: setence children length is possible 0

* fix: support continuous ordered list

* fix: do not print addtional hardline after loose list

* fix: use double-backtick style for single-backtick value in inlineCode

* fix: support nested emphasis

* fix: support space-url in link/image

* fix: escape `)` in link/image url

* fix: support single-quote in link/image/definition title

* fix: respect alt in image/imageReference

* fix: use `*`-style thematicBreak in list

* fix: loose/tight list linebreaks

* fix: print third linebreak before indented code block with a tight list in the previous

* test: move bug cases

* fix: remove unnecessary linebreaks

* refactor: fix typo
2017-10-12 09:46:44 +11:00
Ika f7907b9282 fix(doc-printer): respect CJK width (#3003)
* test: add failing test

* fix(doc-printer): respect CJK width
2017-10-11 00:32:45 -05:00
Ika 6c8cde9672 fix(cli): do not early exit for `--debug-check` (#2987)
* test: add failing test

* fix(cli): do not early exit for `--debug-check`
2017-10-07 04:36:43 -05:00
Joern Bernhardt 3c00979530 Fix typo in test files (`*formated` -> `*formatted`) (#2982)
* Fix typo in test files

Signed-off-by: Joern Bernhardt <jb@campudus.com>

* Rename cursot-offset.js to cursor-offset.js

Signed-off-by: Joern Bernhardt <jb@campudus.com>
2017-10-06 20:01:21 +11:00
Jake 50f3e646c7 Add option to insert @format to first docblock if absent (#2865)
* Add option to insert @format pragma if absent

prependPragma --> insertPragma

add tst dir, move stripBom, add to README, update snapshots

remove noise from test + update snapshots

use jest@test new functions, update docs, rerun snapshots

fix accidental upgrade to jest@test

update jest-docblock again to latest with strip()

updated snapshot

* updated snapshots

* revert jest dep change

* apply a trim to parsed comments

* remove empty object

* Revert "apply a trim to parsed comments"

This reverts commit 467f71ce5f4b4f8a1b5c4474ee0484bc96c92141.

* rerun snapshots with proper jest version

* pin jest-docblock to latest @test release

* comment out docs for new feature from readme

* remove leading newlines

* ensure blank line between docblock and rest of file

* remove backtick string
2017-10-06 19:37:14 +11:00
Simon Lydell bc420370c6 Include duration in --write snapshots (#2960) 2017-10-06 08:20:47 +02:00
Lucas Azzola 482ec01c8e Fix build (#2981) 2017-10-06 14:12:32 +11:00
Joern Bernhardt 201105334d Don't use ANSI codes if stdout isn't a TTY (#2903)
Don't use ANSI codes if stdout isn't a TTY
2017-10-05 22:02:31 +11:00
Ahmed El Gabri 2fed6c873b Use relative paths with CLI (#2969)
* always get relative paths

* Add test

* update snapshots
2017-10-04 18:56:01 +11:00
Ika d9737e6ffa test: fix snapshots (#2957)
* test: trigger test to check its status

* test: update snapshots

* refactor: use strip-ansi
2017-10-02 19:56:34 +02:00
Ika 7770356a51 test(integration): update title and catch all outputs (#2951) 2017-10-02 18:08:34 +02:00
Simon Lydell 43cb08c45c Make production tests always run against dist/ (attempt 2) (#2942)
* Make production tests always run against dist/

* Try to mock process.stdin instead of get-stream

* fix: mock `get-stream` from `index.js`

* refactor: remove unnecessary variable

* Try `transform: {}` in jest.config.js

* Add comment explaining the unusual get-stream mocking
2017-10-02 17:58:55 +02:00
Lucas Azzola a6096ee799 Respect --stdin-filepath, regardless of config source (#2948)
* Respect --stdin-filepath, regardless of config source

Fixes #2946

* Remove obsolete snapshot
2017-10-01 15:55:35 +11:00
Ika 0d756080b5 fix: ignore and show warning for unknown option from config file (#2929) 2017-09-28 19:59:32 +02:00
Lucas Azzola 3c91c2ab42 Fix unit tests on Windows (#2922) 2017-09-28 19:30:51 +10:00
Simon Lydell c6bac7cfe6 Split Less and SCSS parsing into different parsers (#2844)
* Split Less and SCSS parsing into different parsers

Now, .less files are always parsed with postcss-less, and .scss files
areare always parsed with postcss-scss. This:

- Is less hacky.
- Is meant to avoid issues like #2829.
- Is probably more performant.

`parser: "postcss"` and `--parser postcss` continue to work like before:
First trying postcss-less, and if that fails, postcss-scss, unless a
regex says that we should try in the opposite order. The new values for
the parser option are "postcss-less" and "postcss-scss".

* Remove postcss from package.json since it is not used

* Rename parser-less to less and parser-scss to scss

* Deprecate parser:postcss in favor of parser:css

* Fix CSS tests
2017-09-26 07:08:11 +02:00
Ika 4435ecbc7b fix(cli): validate options for every `config-precedence` (#2894)
* fix(cli): validate options for every `config-precedence`

* refactor: use camelcase

* refactor: reduce duplicate code

* refactor: rename function

* refactor: rename parameter
2017-09-25 21:04:25 +02:00
Ika 184e368a9a feat: support detailed `--help` (#2847)
* feat: support detailed --help

* refactor: put alias first, separate with comma

* feat: support detailed --help for --no-option

* docs: add missing type

* docs: remove `This requires node 8 or a transform`

* docs: remove config-precedence's choice descriptions in option.description

* docs: replace `option-name` with `flag`

* docs: update docs for `choices`

* docs: update `help` description

* docs: update error message

* docs: replace `undocumented` with empty string

* refactor: extract `getOptionDefaultValue`

* refactor: dynamically generate `defaults to ...`

* refactor: extract `getOptionWithLevenSuggestion`

* refactor: extract `createChoiceUsages`

* refactor: remove `optionTitleName`

* test: add `--help` tests for all options

* fix: handle `--help --help`

* feat: support `--help <alias>`

* refactor: use `flattenArray`

* feat: handle `--help <unknown>`

* docs: add description for `semi`, `color` and `bracket-spacing`

* fix: remove unnecessary option in `--help`
2017-09-21 07:54:13 +02:00
Nick Ribal 592f99fde6 Enable cosmiconfig rcExtensions (#2749)
* Enable cosmiconfig rcExtensions; add two tests

* Remove default value; make integration input files self descripting; update all integration snapshots

* Add engines field to package.json
2017-09-17 02:47:53 +10:00