diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..3684c7cb --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "proseWrap": false +} diff --git a/.travis.yml b/.travis.yml index 0bb9ef0b..54625a78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ before_script: - if [ "${NODE_ENV}" = "production" ]; then yarn build; fi script: - yarn lint + - yarn lint-docs - AST_COMPARE=1 yarn test -- --runInBand - if [ "${NODE_ENV}" = "development" ]; then yarn codecov; fi deploy: diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e6eaab..84bb3b3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ * Fix website on iOS Safari (#1970) Formatting change: + * Position JSX whitespace (`{" "}`) at the end of lines (#1964) Lots of small fixes, mainly for TypeScript. @@ -209,7 +210,7 @@ Lots of small fixes, mainly for TypeScript. * Add space around `=` for flow generics default arguments (#1476) * Don't break for unparenthesised single argument flow function (#1452) * Don't break on empty arrays and objects (#1440) -* Do not break on [0] (#1441) +* Do not break on `[0]` (#1441) * Reorder flow object props (#1451) * Break inline object first in function arguments (#1453) * Break inline object first in function arguments (#1453) (#1173) @@ -308,7 +309,7 @@ Lots of small fixes, mainly for TypeScript. * [JSX] Break if opening element breaks (#942) * Parenthesize function expressions in expression position (#941) * update the README to add a pre-commit hook (#944) -* Fix #951: properly parenthesize ** expressions (#952) +* Fix #951: properly parenthesize \** expressions (#952) * [WIP] TypeScript Parser (#915) * Do not break long `describe` calls (#953) * Recursively find leading comments inside ReturnStatements (#955) @@ -578,50 +579,50 @@ Lots of small fixes, mainly for TypeScript. Now using minor versions instead of patch versions for the releases. - * Swap quotes (#355) - * Drop jsesc (#357) - * Use a Symbol instead of the private dep (#359) - * Add parens for default export FunctionExpressions (#345) - * Fix export extension output (#361) - * Exit with an error if an unknown CLI option is passed (#365) - * Warn if using deprecated CLI options (#364) - * s/jscodefmt/prettier/ (#370) - * Fix CLI options (#369) - * Fix some parens cases for UpdateExpressions (#381) - * Output strings with the minimum amount of escaped quotes (#390) - * Ignore EmptyStatement inside of switch case (#391) - * Support multiple standalones in import (#389) - * Fix missing semi-colon in for loop and var body (#388) - * Fix empty labels (#383) - * Fix forced trailing comma (#382) - * Empty switch should not have an empty line (#384) - * add formatAST() for formatting ASTs directly (#393) - * Fix class extends parenthesis (#396) - * Fix class inside of binary expression missing parenthesis (#397) - * Fix parenthesis in object as left-hand-side of template (#398) - * Remove unneeded parens for FunctionExpression inside LogicalExpression (#399) - * Remove trailing comma for array destructuring with rest (#400) - * Fix +++x (#401) - * Also do the class extend parenthesis for class expressions (#403) - * Fix various parenthesis issues on the left side of template (#404) - * Fix in inside of the first group of a for (#406) - * Add parenthesis for arrow function inside of ternary (#408) - * Add parenthesis around class expression when left side of call expression (#409) - * Ensure computed method names don't lose quotes (#419) - * Add parenthesis for yield inside of a conditional (#418) - * Add parenthesis around assignment for arrow function body (#422) - * Add parenthesis around export default assignments (#423) - * Add parenthesis for class expression on left of member expression (#421) - * Fix missing parens around object in MemberExpression (#424) - * Re-run snapshot tests - * Workaround flow bug around trailing comma (#427) - * Add parenthesis when class expressions are left of a ternary (#428) - * Revert "Workaround flow bug around trailing comma" (#429) - * Update commands.md (#430) - * Improve vim integration section (#416) - * Add glob support to the CLI (#363) - * Use babel-code-frame for syntax errors (#367) - * Update yarn.lock +* Swap quotes (#355) +* Drop jsesc (#357) +* Use a Symbol instead of the private dep (#359) +* Add parens for default export FunctionExpressions (#345) +* Fix export extension output (#361) +* Exit with an error if an unknown CLI option is passed (#365) +* Warn if using deprecated CLI options (#364) +* s/jscodefmt/prettier/ (#370) +* Fix CLI options (#369) +* Fix some parens cases for UpdateExpressions (#381) +* Output strings with the minimum amount of escaped quotes (#390) +* Ignore EmptyStatement inside of switch case (#391) +* Support multiple standalones in import (#389) +* Fix missing semi-colon in for loop and var body (#388) +* Fix empty labels (#383) +* Fix forced trailing comma (#382) +* Empty switch should not have an empty line (#384) +* add formatAST() for formatting ASTs directly (#393) +* Fix class extends parenthesis (#396) +* Fix class inside of binary expression missing parenthesis (#397) +* Fix parenthesis in object as left-hand-side of template (#398) +* Remove unneeded parens for FunctionExpression inside LogicalExpression (#399) +* Remove trailing comma for array destructuring with rest (#400) +* Fix +++x (#401) +* Also do the class extend parenthesis for class expressions (#403) +* Fix various parenthesis issues on the left side of template (#404) +* Fix in inside of the first group of a for (#406) +* Add parenthesis for arrow function inside of ternary (#408) +* Add parenthesis around class expression when left side of call expression (#409) +* Ensure computed method names don't lose quotes (#419) +* Add parenthesis for yield inside of a conditional (#418) +* Add parenthesis around assignment for arrow function body (#422) +* Add parenthesis around export default assignments (#423) +* Add parenthesis for class expression on left of member expression (#421) +* Fix missing parens around object in MemberExpression (#424) +* Re-run snapshot tests +* Workaround flow bug around trailing comma (#427) +* Add parenthesis when class expressions are left of a ternary (#428) +* Revert "Workaround flow bug around trailing comma" (#429) +* Update commands.md (#430) +* Improve vim integration section (#416) +* Add glob support to the CLI (#363) +* Use babel-code-frame for syntax errors (#367) +* Update yarn.lock # 0.0.10 @@ -744,7 +745,7 @@ Now using minor versions instead of patch versions for the releases. * remove unused recast ref * Fix typo in README. * Support type annotation for rest argument on babylon parser -* Use `setq' instead of `infc' and `decf' +* Use `setq` instead of `infc` and `decf` * Add title and encoding to the REPL * Fix old name reference in tests_config * Minimize string escapes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fc663b3..ec0884d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,30 +11,14 @@ yarn test Here's what you need to know about the tests: * The tests uses [Jest](https://facebook.github.io/jest/) snapshots. -* You can make changes and run `jest -u` (or `yarn test -u`) to update the - snapshots. Then run `git diff` to take a look at what changed. Always update - the snapshots when opening a PR. -* You can run `AST_COMPARE=1 jest` for a more robust test run. That formats each - file, re-parses it, and compares the new AST with the original one and makes - sure they are semantically equivalent. -* Each test folder has a `jsfmt.spec.js` that runs the tests. Normally you can - just put `run_spec(__dirname);` there. You can also pass options and - additional parsers, like this: - `run_spec(__dirname, { trailingComma: "es5" }, ["babylon"]);` -* `tests/flow/` contains the Flow test suite, and is not supposed to be edited - by hand. To update it, clone the Flow repo next to the Prettier repo and run: - `node scripts/sync-flow-tests.js ../flow/tests/`. -* If you would like to debug prettier locally, you can either debug it in node - or the browser. The easiest way to debug it in the browser is to run the - interactive `docs` REPL locally. The easiest way to debug it in node, is to - create a local test file and run it in an editor like VS Code. +* You can make changes and run `jest -u` (or `yarn test -u`) to update the snapshots. Then run `git diff` to take a look at what changed. Always update the snapshots when opening a PR. +* You can run `AST_COMPARE=1 jest` for a more robust test run. That formats each file, re-parses it, and compares the new AST with the original one and makes sure they are semantically equivalent. +* Each test folder has a `jsfmt.spec.js` that runs the tests. Normally you can just put `run_spec(__dirname);` there. You can also pass options and additional parsers, like this: `run_spec(__dirname, { trailingComma: "es5" }, ["babylon"]);` +* `tests/flow/` contains the Flow test suite, and is not supposed to be edited by hand. To update it, clone the Flow repo next to the Prettier repo and run: `node scripts/sync-flow-tests.js ../flow/tests/`. +* If you would like to debug prettier locally, you can either debug it in node or the browser. The easiest way to debug it in the browser is to run the interactive `docs` REPL locally. The easiest way to debug it in node, is to create a local test file and run it in an editor like VS Code. Run `yarn lint --fix` to automatically format files. -If you can, take look at [commands.md](commands.md) and check out [Wadler's -paper](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf) to -understand how Prettier works. +If you can, take look at [commands.md](commands.md) and check out [Wadler's paper](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf) to understand how Prettier works. -If you want to know more about Prettier's GitHub labels, see the -[Issue Labels](https://github.com/prettier/prettier/wiki/Issue-Labels) -page on the Wiki. +If you want to know more about Prettier's GitHub labels, see the [Issue Labels](https://github.com/prettier/prettier/wiki/Issue-Labels) page on the Wiki. diff --git a/README.md b/README.md index 27b3ed46..8e65d209 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,11 @@ ## Intro -Prettier is an opinionated code formatter. It enforces a consistent style by -parsing your code and re-printing it with its own rules that take the maximum -line length into account, wrapping code when necessary. +Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. ### Input + ```js foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne()); ``` @@ -60,16 +59,13 @@ foo( ); ``` -Prettier can be ran [in your editor](http://prettier.io/docs/en/editors.html) -on-save, in a [pre-commit hook](https://prettier.io/docs/en/precommit.html), -or in [CI environments](https://prettier.io/docs/en/cli.html#list-different) -to ensure your codebase has a consistent style without devs ever having to post -a nit comment on a code review ever again! +Prettier can be ran [in your editor](http://prettier.io/docs/en/editors.html) on-save, in a [pre-commit hook](https://prettier.io/docs/en/precommit.html), or in [CI environments](https://prettier.io/docs/en/cli.html#list-different) to ensure your codebase has a consistent style without devs ever having to post a nit comment on a code review ever again! -- - - +--- **[Documentation](https://prettier.io/docs/en/)** + [Install](https://prettier.io/docs/en/install.html) · [Options](https://prettier.io/docs/en/options.html) · [CLI](https://prettier.io/docs/en/cli.html) · @@ -77,11 +73,11 @@ a nit comment on a code review ever again! **[Playground](https://prettier.io/playground/)** -- - - +--- ## Badge -Show the world you're using *Prettier* → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +Show the world you're using _Prettier_ → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) ```md [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) diff --git a/commands.md b/commands.md index 6c0a6aa0..137f53dc 100644 --- a/commands.md +++ b/commands.md @@ -1,8 +1,4 @@ -The core of the algorithm is implemented in `doc-{printer,builders,utils,debug}.js`. The printer should -use the basic formatting abstractions provided to construct a format -when printing a node. Parts of the API only exist to be compatible -with recast's previous API to ease migration, but over time we can -clean it up. +The core of the algorithm is implemented in `doc-{printer,builders,utils,debug}.js`. The printer should use the basic formatting abstractions provided to construct a format when printing a node. Parts of the API only exist to be compatible with recast's previous API to ease migration, but over time we can clean it up. The following commands are available: @@ -12,29 +8,20 @@ Combine an array into a single string. ### group -Mark a group of items which the printer should try to fit on one line. -This is the basic command to tell the printer when to break. Groups -are usually nested, and the printer will try to fit everything on one -line, but if it doesn't fit it will break the outermost group first -and try again. It will continue breaking groups until everything fits -(or there are no more groups to break). +Mark a group of items which the printer should try to fit on one line. This is the basic command to tell the printer when to break. Groups are usually nested, and the printer will try to fit everything on one line, but if it doesn't fit it will break the outermost group first and try again. It will continue breaking groups until everything fits (or there are no more groups to break). -A document can force parent groups to break by including `breakParent` -(see below). A hard and literal line automatically include this so -they always break parent groups. Breaks are propagated to all parent -groups, so if a deeply nested expression has a hard break, everything -with break. This only matters for "hard" breaks, i.e. newlines that -are printed no matter what and can be statically analyzed. +A document can force parent groups to break by including `breakParent` (see below). A hard and literal line automatically include this so they always break parent groups. Breaks are propagated to all parent groups, so if a deeply nested expression has a hard break, everything with break. This only matters for "hard" breaks, i.e. newlines that are printed no matter what and can be statically analyzed. For example, an array will try to fit on one line: + ```js [1, "foo", { bar: 2 }] ``` -However, if any of the items inside the array have a hard break, the -array will *always* break as well: +However, if any of the items inside the array have a hard break, the array will _always_ break as well: + ```js [ 1, @@ -45,14 +32,13 @@ array will *always* break as well: ] ``` -Functions always break after the opening curly brace no matter what, -so the array breaks as well for consistent formatting. See the -implementation of `ArrayExpression` for an example. +Functions always break after the opening curly brace no matter what, so the array breaks as well for consistent formatting. See the implementation of `ArrayExpression` for an example. ### conditionalGroup This should be used as **last resort** as it triggers an exponential complexity when nested. This will try to print the first argument, if it fit use it, otherwise go to the next one and so on. + ```js conditionalGroup([a, b, c]) ``` @@ -61,24 +47,25 @@ conditionalGroup([a, b, c]) This is an alternative type of group which behave like text layout: it's going to add a break whenever the next element doesn't fit in the line anymore. The difference with a typical group is that it's not going to break all the separators, just the ones that are at the end of lines. + ```js fill(["I", line, "love", line, "prettier"]) ``` - ### ifBreak Prints something if the current group breaks and something else if it doesn't. + ```js ifBreak(";", " ") ``` ### breakParent -Include this anywhere to force all parent groups to break. See `group` -for more info. Example: +Include this anywhere to force all parent groups to break. See `group` for more info. Example: + ```js group( concat([ @@ -96,35 +83,32 @@ Join an array of items with a separator. ### line -Specify a line break. If an expression fits on one line, the line -break will be replaced with a space. Line breaks always indent the -next line with the current level of indentation. +Specify a line break. If an expression fits on one line, the line break will be replaced with a space. Line breaks always indent the next line with the current level of indentation. ### softline -Specify a line break. The difference from `line` is that if the -expression fits on one line, it will be replaced with nothing. +Specify a line break. The difference from `line` is that if the expression fits on one line, it will be replaced with nothing. ### hardline -Specify a line break that is **always** included in the output, no -matter if the expression fits on one line or not. +Specify a line break that is **always** included in the output, no matter if the expression fits on one line or not. ### literalline -Specify a line break that is **always** included in the output, and -don't indent the next line. This is used for template literals. +Specify a line break that is **always** included in the output, and don't indent the next line. This is used for template literals. ### lineSuffix This is used to implement trailing comments. In practice, it is not practical to find where the line ends and you don't want to accidentally print some code at the end of the comment. `lineSuffix` will buffer the output and flush it before any new line. + ```js concat(["a", lineSuffix(" // comment"), ";", hardline]) ``` will output + ```js a; // comment ``` @@ -133,12 +117,14 @@ a; // comment In cases where you embed code inside of templates, comments shouldn't be able to leave the code part. lineSuffixBoundary is an explicit marker you can use to flush code in addition to newlines. + ```js concat(["{", lineSuffix(" // comment"), lineSuffixBoundary, "}", hardline]) ``` will output + ```js { // comment } @@ -146,6 +132,7 @@ will output and **not** + ```js {} // comment ``` @@ -166,6 +153,7 @@ This is a placeholder value where the cursor is in the original input in order t For an example, here's the implementation of the `ArrayExpression` node type: + ```js group( concat([ @@ -186,6 +174,4 @@ group( ) ``` -This is a group with opening and closing brackets, and possibly -indented contents. Because it's a `group` it will always be -broken up if any of the sub-expressions are broken. +This is a group with opening and closing brackets, and possibly indented contents. Because it's a `group` it will always be broken up if any of the sub-expressions are broken. diff --git a/docs/api.md b/docs/api.md index d87424c7..38bd252f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -18,13 +18,11 @@ prettier.format("foo ( );", { semi: false }); ## `prettier.check(source [, options])` -`check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`. -This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios. +`check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`. This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios. ## `prettier.formatWithCursor(source [, options])` -`formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code. -This is useful for editor integrations, to prevent the cursor from moving when code is formatted. +`formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code. This is useful for editor integrations, to prevent the cursor from moving when code is formatted. The `cursorOffset` option should be provided, to specify where the cursor is. This option cannot be used with `rangeStart` and `rangeEnd`. @@ -35,11 +33,8 @@ prettier.formatWithCursor(" 1", { cursorOffset: 2 }); ## `prettier.resolveConfig(filePath [, options])` -`resolveConfig` can be used to resolve configuration for a given source file, passing its path as the first argument. -The config search will start at the file path and continue to search up the directory (you can use `process.cwd()` to start -searching from the current directory). -Or you can pass directly the path of the config file as `options.config` if you don't wish to search for it. -A promise is returned which will resolve to: +`resolveConfig` can be used to resolve configuration for a given source file, passing its path as the first argument. The config search will start at the file path and continue to search up the directory (you can use `process.cwd()` to start searching from the current directory). Or you can pass directly the path of the config file as `options.config` if you don't wish to search for it. A promise is returned which will resolve to: + * An options object, providing a [config file](configuration.md) was found. * `null`, if no file was found. @@ -51,24 +46,20 @@ If `options.useCache` is `false`, all caching will be bypassed. const text = fs.readFileSync(filePath, "utf8"); prettier.resolveConfig(filePath).then(options => { const formatted = prettier.format(text, options); -}) +}); ``` Use `prettier.resolveConfig.sync(filePath [, options])` if you'd like to use sync version. ## `prettier.clearConfigCache()` -As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. -This function will clear the cache. Generally this is only needed for editor integrations that -know that the file system has changed since the last format took place. +As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache. Generally this is only needed for editor integrations that know that the file system has changed since the last format took place. ## `prettier.getSupportInfo([version])` -Returns an object representing the parsers, languages and file types Prettier -supports. +Returns an object representing the parsers, languages and file types Prettier supports. -If `version` is provided (e.g. `"1.5.0"`), information for that version will be -returned, otherwise information for the current version will be returned. +If `version` is provided (e.g. `"1.5.0"`), information for that version will be returned, otherwise information for the current version will be returned. The support information looks like this: @@ -95,6 +86,7 @@ The support information looks like this: ## Custom Parser API If you need to make modifications to the AST (such as codemods), or you want to provide an alternate parser, you can do so by setting the `parser` option to a function. The function signature of the parser function is: + ```js (text: string, parsers: object, options: object) => AST; ``` diff --git a/docs/cli.md b/docs/cli.md index 39059a36..ed184ba3 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -3,11 +3,9 @@ id: cli title: CLI --- -Run Prettier through the CLI with this script. Run it without any -arguments to see the [options](options.md). +Run Prettier through the CLI with this script. Run it without any arguments to see the [options](options.md). -To format a file in-place, use `--write`. You may want to consider -committing your code before doing that, just in case. +To format a file in-place, use `--write`. You may want to consider committing your code before doing that, just in case. ```bash prettier [opts] [filename ...] @@ -19,24 +17,17 @@ In practice, this may look something like: prettier --single-quote --trailing-comma es5 --write "{app,__{tests,mocks}__}/**/*.js" ``` -Don't forget the quotes around the globs! The quotes make sure that Prettier -expands the globs rather than your shell, for cross-platform usage. -The [glob syntax from the glob module](https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer) -is used. +Don't forget the quotes around the globs! The quotes make sure that Prettier expands the globs rather than your shell, for cross-platform usage. The [glob syntax from the glob module](https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer) is used. Prettier CLI will ignore files located in `node_modules` directory. To opt-out from this behavior use `--with-node-modules` flag. ## `--debug-check` -If you're worried that Prettier will change the correctness of your code, add `--debug-check` to the command. -This will cause Prettier to print an error message if it detects that code correctness might have changed. -Note that `--write` cannot be used with `--debug-check`. +If you're worried that Prettier will change the correctness of your code, add `--debug-check` to the command. This will cause Prettier to print an error message if it detects that code correctness might have changed. Note that `--write` cannot be used with `--debug-check`. ## `--find-config-path` and `--config` -If you are repeatedly formatting individual files with `prettier`, you will incur a small performance cost -when prettier attempts to look up a [configuration file](configuration.md). In order to skip this, you may -ask prettier to find the config file once, and re-use it later on. +If you are repeatedly formatting individual files with `prettier`, you will incur a small performance cost when prettier attempts to look up a [configuration file](configuration.md). In order to skip this, you may ask prettier to find the config file once, and re-use it later on. ```bash prettier --find-config-path ./my/file.js @@ -49,19 +40,18 @@ This will provide you with a path to the configuration file, which you can pass prettier --config ./my/.prettierrc --write ./my/file.js ``` -You can also use `--config` if your configuration file lives somewhere where prettier cannot find it, -such as a `config/` directory. +You can also use `--config` if your configuration file lives somewhere where prettier cannot find it, such as a `config/` directory. -If you don't have a configuration file, or want to ignore it if it does exist, -you can pass `--no-config` instead. +If you don't have a configuration file, or want to ignore it if it does exist, you can pass `--no-config` instead. ### `--ignore-path` -Path to a file containing patterns that describe files to ignore. By default, prettier looks for `./.prettierignore`. +Path to a file containing patterns that describe files to ignore. By default, prettier looks for `./.prettierignore`. ## `--require-pragma` Require a special comment, called a pragma, to be present in the file's first docblock comment in order for prettier to format it. + ```js /** * @prettier @@ -72,8 +62,7 @@ Valid pragmas are `@prettier` and `@format`. ## `--insert-pragma` -Insert a `@format` pragma to the top of formatted files when pragma is absent. -Works well when used in tandem with `--require-pragma`. +Insert a `@format` pragma to the top of formatted files when pragma is absent. Works well when used in tandem with `--require-pragma`. ## `--list-different` @@ -85,7 +74,7 @@ prettier --single-quote --list-different "src/**/*.js" ## `--no-config` -Do not look for a configuration file. The default settings will be used. +Do not look for a configuration file. The default settings will be used. ## `--config-precedence` @@ -111,4 +100,4 @@ Prettier CLI will ignore files located in `node_modules` directory. To opt-out f ## `--write` -This rewrites all processed files in place. This is comparable to the `eslint --fix` workflow. +This rewrites all processed files in place. This is comparable to the `eslint --fix` workflow. diff --git a/docs/configuration.md b/docs/configuration.md index d5ef4ca0..10b93fe0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -3,15 +3,13 @@ id: configuration title: Configuration File --- -Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support. -This means you can configure prettier via: +Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support. This means you can configure prettier via: * A `.prettierrc` file, written in YAML or JSON, with optional extensions: `.yaml/.yml/.json/.js`. * A `prettier.config.js` file that exports an object. * A `"prettier"` key in your `package.json` file. -The configuration file will be resolved starting from the location of the file being formatted, -and searching up the file tree until a config file is (or isn't) found. +The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found. The options to the configuration file are the same as the [API options](options.md). @@ -37,20 +35,21 @@ parser: flow ## Configuration Overrides -Prettier borrows eslint's [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). -This allows you to apply configuration to specific files. +Prettier borrows eslint's [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). This allows you to apply configuration to specific files. JSON: ```json { "semi": false, - "overrides": [{ - "files": "*.test.js", - "options": { - "semi": true + "overrides": [ + { + "files": "*.test.js", + "options": { + "semi": true + } } - }] + ] } ``` @@ -64,17 +63,18 @@ overrides: semi: true ``` -`files` is required for each override, and may be a string or array of strings. -`excludeFiles` may be optionally provided to exclude files for a given rule, and may also be a string or array of strings. +`files` is required for each override, and may be a string or array of strings. `excludeFiles` may be optionally provided to exclude files for a given rule, and may also be a string or array of strings. To get prettier to format its own `.prettierrc` file, you can do: ```json { - "overrides": [{ - "files": ".prettierrc", - "options": { "parser": "json" } - }] + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + } + ] } ``` diff --git a/docs/editors.md b/docs/editors.md index 4f153065..d80cae45 100644 --- a/docs/editors.md +++ b/docs/editors.md @@ -5,13 +5,11 @@ title: Editor Integration ## Atom -Atom users can simply install the [prettier-atom](https://github.com/prettier/prettier-atom) package and use -`Ctrl+Alt+F` to format a file (or format on save if enabled). +Atom users can simply install the [prettier-atom](https://github.com/prettier/prettier-atom) package and use `Ctrl+Alt+F` to format a file (or format on save if enabled). ## Emacs -Emacs users should see [this repository](https://github.com/prettier/prettier-emacs) -for on-demand formatting. +Emacs users should see [this repository](https://github.com/prettier/prettier-emacs) for on-demand formatting. ## Vim @@ -31,8 +29,7 @@ Install the [JavaScript Prettier extension](https://github.com/madskristensen/Ja ## Sublime Text -Sublime Text support is available through Package Control and -the [JsPrettier](https://packagecontrol.io/packages/JsPrettier) plug-in. +Sublime Text support is available through Package Control and the [JsPrettier](https://packagecontrol.io/packages/JsPrettier) plug-in. ## JetBrains WebStorm, PHPStorm, PyCharm... diff --git a/docs/eslint.md b/docs/eslint.md index ed7d5ab5..685a392f 100644 --- a/docs/eslint.md +++ b/docs/eslint.md @@ -31,7 +31,7 @@ yarn add --dev prettier eslint-plugin-prettier Whether you run Prettier via ESLint or run both tools separately, you probably only want to hear about each formatting issue once, and you especially don't want ESLint to complain about formatting "issues" which are simply a different preference than what Prettier does. -So you'll probably want to disable the conflicting rules (while keeping around other rules that Prettier doesn't care about). The easiest way to do this is to use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier). It's a one liner that can be added on-top of any existing ESLint configuration. +So you'll probably want to disable the conflicting rules (while keeping around other rules that Prettier doesn't care about). The easiest way to do this is to use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier). It's a one liner that can be added on-top of any existing ESLint configuration. ``` $ yarn add --dev eslint-config-prettier @@ -41,9 +41,7 @@ $ yarn add --dev eslint-config-prettier ```json { - "extends": [ - "prettier" - ] + "extends": ["prettier"] } ``` diff --git a/docs/ignore.md b/docs/ignore.md index 7849a9a3..568d0d99 100644 --- a/docs/ignore.md +++ b/docs/ignore.md @@ -11,6 +11,7 @@ A JavaScript comment of `// prettier-ignore` will exclude the next node in the a For example: + ```js matrix( 1, 0, 0, @@ -43,8 +44,8 @@ matrix( ```jsx
- {/* prettier-ignore */} - + {/* prettier-ignore */} +
; ``` diff --git a/docs/index.md b/docs/index.md index 3a6ebc70..1d66a537 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,8 +14,7 @@ Prettier is an opinionated code formatter with support for: * [GraphQL](http://graphql.org/) * [Markdown](http://commonmark.org/), including [GFM](https://github.github.com/gfm/) -It removes all original styling[\*](#footnotes) and ensures that all outputted code -conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) +It removes all original styling[\*](#footnotes) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) Prettier takes your code and reprints it from scratch by taking the line length into account. @@ -27,6 +26,7 @@ foo(arg1, arg2, arg3, arg4); It fits in a single line so it's going to stay as is. However, we've all run into this situation: + ```js foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne()); ``` @@ -52,9 +52,7 @@ If you want to learn more, these two conference talks are great introductions: #### Footnotes -\* _Well actually, some original styling is preserved when practical—see - [empty lines] and [multi-line objects]._ +\* _Well actually, some original styling is preserved when practical—see [empty lines] and [multi-line objects]._ - -[empty lines]:rationale.md#empty-lines -[multi-line objects]:rationale.md#multi-line-objects +[empty lines]: rationale.md#empty-lines +[multi-line objects]: rationale.md#multi-line-objects diff --git a/docs/install.md b/docs/install.md index 9bc0d779..138282d7 100644 --- a/docs/install.md +++ b/docs/install.md @@ -15,7 +15,7 @@ You can install it globally if you like: yarn global add prettier ``` -*We're using `yarn` but you can use `npm` if you like:* +_We're using `yarn` but you can use `npm` if you like:_ ``` npm install --save-dev --save-exact prettier @@ -23,5 +23,4 @@ npm install --save-dev --save-exact prettier npm install --global prettier ``` -> We recommend pinning an exact version of prettier in your `package.json` -> as we introduce stylistic changes in patch releases. +> We recommend pinning an exact version of prettier in your `package.json` as we introduce stylistic changes in patch releases. diff --git a/docs/language-support.md b/docs/language-support.md index ee479b6c..20b144ed 100644 --- a/docs/language-support.md +++ b/docs/language-support.md @@ -3,15 +3,9 @@ id: language-support title: Language Support --- -Prettier attempts to support all JavaScript language features, -including non-standardized ones. By default it uses the -[Babylon](https://github.com/babel/babylon) parser with all language -features enabled, but you can also use the -[Flow](https://github.com/facebook/flow) parser with the -`parser` API or `--parser` CLI [option](options.md). +Prettier attempts to support all JavaScript language features, including non-standardized ones. By default it uses the [Babylon](https://github.com/babel/babylon) parser with all language features enabled, but you can also use the [Flow](https://github.com/facebook/flow) parser with the `parser` API or `--parser` CLI [option](options.md). -All of JSX and Flow syntax is supported. In fact, the test suite in -`tests/flow` *is* the entire Flow test suite and they all pass. +All of JSX and Flow syntax is supported. In fact, the test suite in `tests/flow` _is_ the entire Flow test suite and they all pass. Prettier also supports [TypeScript](https://www.typescriptlang.org/), CSS, [Less](http://lesscss.org/), [SCSS](http://sass-lang.com), [JSON](http://json.org/), [GraphQL](http://graphql.org/), and [Markdown](http://commonmark.org). diff --git a/docs/options.md b/docs/options.md index c1943797..8a9cfee7 100644 --- a/docs/options.md +++ b/docs/options.md @@ -11,29 +11,29 @@ Specify the line length that the printer will wrap on. > **For readability we recommend against using more than 80 characters:** > ->In code styleguides, maximum line length rules are often set to 100 or 120. However, when humans write code, they don't strive to reach the maximum number of columns on every line. Developers often use whitespace to break up long lines for readability. In practice, the average line length often ends up well below the maximum. +> In code styleguides, maximum line length rules are often set to 100 or 120. However, when humans write code, they don't strive to reach the maximum number of columns on every line. Developers often use whitespace to break up long lines for readability. In practice, the average line length often ends up well below the maximum. > > Prettier, on the other hand, strives to fit the most code into every line. With the print width set to 120, prettier may produce overly compact, or otherwise undesirable code. -Default | CLI Override | API Override ---------|--------------|------------- -`80` | `--print-width ` | `printWidth: ` +| Default | CLI Override | API Override | +| ------- | --------------------- | ------------------- | +| `80` | `--print-width ` | `printWidth: ` | ## Tab Width Specify the number of spaces per indentation-level. -Default | CLI Override | API Override ---------|--------------|------------- - `2` | `--tab-width ` | `tabWidth: ` +| Default | CLI Override | API Override | +| ------- | ------------------- | ----------------- | +| `2` | `--tab-width ` | `tabWidth: ` | ## Tabs Indent lines with tabs instead of spaces -Default | CLI Override | API Override ---------|--------------|------------- -`false` | `--use-tabs` | `useTabs: ` +| Default | CLI Override | API Override | +| ------- | ------------ | ----------------- | +| `false` | `--use-tabs` | `useTabs: ` | ## Semicolons @@ -41,73 +41,76 @@ Print semicolons at the ends of statements. Valid options: - * `true` - Add a semicolon at the end of every statement. - * `false` - Only add semicolons at the beginning of lines that may introduce ASI failures. +* `true` - Add a semicolon at the end of every statement. +* `false` - Only add semicolons at the beginning of lines that may introduce ASI failures. -Default | CLI Override | API Override ---------|--------------|------------- -`true` | `--no-semi` | `semi: ` +| Default | CLI Override | API Override | +| ------- | ------------ | -------------- | +| `true` | `--no-semi` | `semi: ` | ## Quotes Use single quotes instead of double quotes. Notes: + * Quotes in JSX will always be double and ignore this setting. * If the number of quotes outweighs the other quote, the quote which is less used will be used to format the string - Example: `"I'm double quoted"` results in `"I'm double quoted"` and `"This \"example\" is single quoted"` results in `'This "example" is single quoted'`. -Default | CLI Override | API Override ---------|--------------|------------- -`false` | `--single-quote` | `singleQuote: ` +| Default | CLI Override | API Override | +| ------- | ---------------- | --------------------- | +| `false` | `--single-quote` | `singleQuote: ` | ## Trailing Commas -Print trailing commas wherever possible when multi-line. (A single-line array, -for example, never gets trailing commas.) +Print trailing commas wherever possible when multi-line. (A single-line array, for example, never gets trailing commas.) Valid options: - * `"none"` - No trailing commas. - * `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.) - * `"all"` - Trailing commas wherever possible (including function arguments). This requires node 8 or a [transform](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/). -Default | CLI Override | API Override ---------|--------------|------------- -`"none"` | --trailing-comma | trailingComma: "" +* `"none"` - No trailing commas. +* `"es5"` - Trailing commas where valid in ES5 (objects, arrays, etc.) +* `"all"` - Trailing commas wherever possible (including function arguments). This requires node 8 or a [transform](https://babeljs.io/docs/plugins/syntax-trailing-function-commas/). + +| Default | CLI Override | API Override | +| -------- | ------------------------------------------------------ | ------------------------------------------------------ | +| `"none"` | --trailing-comma | trailingComma: "" | ## Bracket Spacing Print spaces between brackets in object literals. Valid options: - * `true` - Example: `{ foo: bar }`. - * `false` - Example: `{foo: bar}`. -Default | CLI Override | API Override ---------|--------------|------------- -`true` | `--no-bracket-spacing` | `bracketSpacing: ` +* `true` - Example: `{ foo: bar }`. +* `false` - Example: `{foo: bar}`. + +| Default | CLI Override | API Override | +| ------- | ---------------------- | ------------------------ | +| `true` | `--no-bracket-spacing` | `bracketSpacing: ` | ## JSX Brackets Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line (does not apply to self closing elements). -Default | CLI Override | API Override ---------|--------------|------------- -`false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: ` +| Default | CLI Override | API Override | +| ------- | ------------------------- | ---------------------------- | +| `false` | `--jsx-bracket-same-line` | `jsxBracketSameLine: ` | ## Range Format only a segment of a file. These two options can be used to format code starting and ending at a given character offset (inclusive and exclusive, respectively). The range will extend: + * Backwards to the start of the first line containing the selected statement. * Forwards to the end of the selected statement. These options cannot be used with `cursorOffset`. -Default | CLI Override | API Override ---------|--------------|------------- -`0` | `--range-start `| `rangeStart: ` -`Infinity` | `--range-end ` | `rangeEnd: ` +| Default | CLI Override | API Override | +| ---------- | --------------------- | ------------------- | +| `0` | `--range-start ` | `rangeStart: ` | +| `Infinity` | `--range-end ` | `rangeEnd: ` | ## Parser @@ -116,19 +119,20 @@ Specify which parser to use. Both the `babylon` and `flow` parsers support the same set of JavaScript features (including Flow). Prettier automatically infers the parser from the input file path, so you shouldn't have to change this setting. Built-in parsers: - * [`babylon`](https://github.com/babel/babylon/) - * [`flow`](https://github.com/facebook/flow/tree/master/src/parser) - * [`typescript`](https://github.com/eslint/typescript-eslint-parser) _Since v1.4.0_ - * [`postcss`](https://github.com/postcss/postcss) _Since v1.4.0_ - * [`json`](https://github.com/babel/babylon/tree/f09eb3200f57ea94d51c2a5b1facf2149fb406bf#babylonparseexpressioncode-options) _Since v1.5.0_ - * [`graphql`](https://github.com/graphql/graphql-js/tree/master/src/language) _Since v1.5.0_ - * [`markdown`](https://github.com/wooorm/remark/tree/master/packages/remark-parse) _Since v1.8.0_ -[Custom parsers](api.md#custom-parser-api) are also supported. _Since v1.5.0_ +* [`babylon`](https://github.com/babel/babylon/) +* [`flow`](https://github.com/facebook/flow/tree/master/src/parser) +* [`typescript`](https://github.com/eslint/typescript-eslint-parser) _Since v1.4.0_ +* [`postcss`](https://github.com/postcss/postcss) _Since v1.4.0_ +* [`json`](https://github.com/babel/babylon/tree/f09eb3200f57ea94d51c2a5b1facf2149fb406bf#babylonparseexpressioncode-options) _Since v1.5.0_ +* [`graphql`](https://github.com/graphql/graphql-js/tree/master/src/language) _Since v1.5.0_ +* [`markdown`](https://github.com/wooorm/remark/tree/master/packages/remark-parse) _Since v1.8.0_ -Default | CLI Override | API Override ---------|--------------|------------- -`babylon` | `--parser `
`--parser ./my-parser` | `parser: ""`
`parser: require("./my-parser")` +[Custom parsers](api.md#custom-parser-api) are also supported. _Since v1.5.0_ + +| Default | CLI Override | API Override | +| --------- | ----------------------------------------------- | ---------------------------------------------------------- | +| `babylon` | `--parser `
`--parser ./my-parser` | `parser: ""`
`parser: require("./my-parser")` | ## FilePath @@ -140,16 +144,15 @@ For example, the following will use `postcss` parser: cat foo | prettier --stdin-filepath foo.css ``` -Default | CLI Override | API Override ---------|--------------|------------- -None | `--stdin-filepath ` | `filepath: ""` +| Default | CLI Override | API Override | +| ------- | --------------------------- | ---------------------- | +| None | `--stdin-filepath ` | `filepath: ""` | ## Require pragma _available in v1.7.0+_ -Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. This is very useful -when gradually transitioning large, unformatted codebases to prettier. +Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. This is very useful when gradually transitioning large, unformatted codebases to prettier. For example, a file with the following as its first comment will be formatted when `--require-pragma` is supplied: @@ -167,31 +170,26 @@ or */ ``` -Default | CLI Override | API Override ---------|--------------|------------- -`false` | `--require-pragma` | `requirePragma: ` +| Default | CLI Override | API Override | +| ------- | ------------------ | ----------------------- | +| `false` | `--require-pragma` | `requirePragma: ` | ## Insert Pragma _available in v1.8.0+_ -Prettier can insert a special @format marker at the top of files specifying that the file has been formatted -with prettier. This works well when used in tandem with the `--require-pragma` option. If there is already a -docblock at the top of the file then this option will add a newline to it with the @format marker. +Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier. This works well when used in tandem with the `--require-pragma` option. If there is already a docblock at the top of the file then this option will add a newline to it with the @format marker. -Default | CLI Override | API Override ---------|--------------|------------- -`false` | `--insert-pragma` | `insertPragma: ` +| Default | CLI Override | API Override | +| ------- | ----------------- | ---------------------- | +| `false` | `--insert-pragma` | `insertPragma: ` | ## Prose Wrap _available in v1.8.2+_ -By default, Prettier will wrap markdown text at the specified print width. -In some cases you may want to rely on editor/viewer soft wrapping instead, -so this option allows you to opt out. When prose wrapping is disabled, each -paragraph will be printed on its own line. +By default, Prettier will wrap markdown text at the specified print width. In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out. When prose wrapping is disabled, each paragraph will be printed on its own line. -Default | CLI Override | API Override ---------|--------------|------------- -`true` | `--no-prose-wrap` | `proseWrap: ` +| Default | CLI Override | API Override | +| ------- | ----------------- | ------------------- | +| `true` | `--no-prose-wrap` | `proseWrap: ` | diff --git a/docs/precommit.md b/docs/precommit.md index 84fb6186..03e559a7 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -21,29 +21,24 @@ and add this config to your `package.json`: "precommit": "lint-staged" }, "lint-staged": { - "*.{js,json,css}": [ - "prettier --write", - "git add" - ] + "*.{js,json,css}": ["prettier --write", "git add"] } } ``` + There is a limitation where if you stage specific lines this approach will stage the whole file after regardless. See this [issue](https://github.com/okonet/lint-staged/issues/62) for more info. See https://github.com/okonet/lint-staged#configuration for more details about how you can configure lint-staged. - ## Option 2. [pre-commit](https://github.com/pre-commit/pre-commit) Copy the following config into your `.pre-commit-config.yaml` file: ```yaml - - repo: https://github.com/prettier/prettier sha: '' # Use the sha or tag you want to point at hooks: - id: prettier - ``` Find more info from [here](http://pre-commit.com). diff --git a/docs/rationale.md b/docs/rationale.md index 0bac38fa..2bdded20 100644 --- a/docs/rationale.md +++ b/docs/rationale.md @@ -5,7 +5,6 @@ title: Rationale Prettier is an opinionated code formatter. This document gives a rationale behind those opinions. - ## What prettier is concerned about ### Consistency @@ -16,7 +15,6 @@ Prettier exists for one purpose: to enforce consistency across your entire proje The first requirement of prettier is to output valid JavaScript and code that has the exact same behavior as before formatting. Please report any JavaScript code where prettier fails to follow these correctness rules — that's a bug which needs to be fixed! - ### Whitespace: indentation and line breaks This is the core of prettier. The formatting rules are going to be explained in a later section. @@ -25,40 +23,36 @@ This is the core of prettier. The formatting rules are going to be explained in Prettier enforces double quotes by default, but has a setting for enforcing single quotes instead. There are two exceptions: -- The number of escaped quotes are minimized. For example, if you have a string with a single quote inside, it will be enclosed in double quotes regardless of the quote setting: `"that's a double quote"`, not `'that\'s a double quote'`. -- JSX always uses double quotes. JSX takes its roots from HTML, where the dominant use of quotes for attributes is double quotes. Browser developer tools also follow this convention by always displaying HTML with double quotes, even if the source code uses single quotes. +* The number of escaped quotes are minimized. For example, if you have a string with a single quote inside, it will be enclosed in double quotes regardless of the quote setting: `"that's a double quote"`, not `'that\'s a double quote'`. +* JSX always uses double quotes. JSX takes its roots from HTML, where the dominant use of quotes for attributes is double quotes. Browser developer tools also follow this convention by always displaying HTML with double quotes, even if the source code uses single quotes. Prettier maintains the way your string is escaped. For example, `"🙂"` won't be formatted into `"\uD83D\uDE42"` and vice versa. - ### Parentheses Prettier outputs the minimum number of parentheses required to ensure that the behavior of the formatted code stays unchanged. This may lead to code that feels ambiguous. If that's the case, you are encouraged to extract the ambiguous parts into variables. - ### Empty lines It turns out that empty lines are very hard to automatically generate. The approach that prettier takes is to preserve empty lines the way they were in the original source code. The only constraint is that prettier disallows several empty lines in a row. They are collapsed to a single one. - ### Multi-line objects It is tempting to collapse an object to a single line if it fits, but there are times when it is better for sibling/cousin keys to stay vertically aligned—see [object lists], [nested configs], [stylesheets], and [keyed methods]. To avoid unfavorable collapsing, prettier simply formats any object as multi-line if it appears as such in the original source code. This is the same strategy used by [elm-format] for multi-line records. -[object lists]:https://github.com/prettier/prettier/issues/74#issue-199965534 -[nested configs]:https://github.com/prettier/prettier/issues/88#issuecomment-275448346 -[stylesheets]:https://github.com/prettier/prettier/issues/74#issuecomment-275262094 -[keyed methods]:https://github.com/prettier/prettier/pull/495#issuecomment-275745434 -[elm-format]:https://github.com/prettier/prettier/issues/74#issuecomment-275621526 +[object lists]: https://github.com/prettier/prettier/issues/74#issue-199965534 +[nested configs]: https://github.com/prettier/prettier/issues/88#issuecomment-275448346 +[stylesheets]: https://github.com/prettier/prettier/issues/74#issuecomment-275262094 +[keyed methods]: https://github.com/prettier/prettier/pull/495#issuecomment-275745434 +[elm-format]: https://github.com/prettier/prettier/issues/74#issuecomment-275621526 ## What prettier is _not_ concerned about Here are a few examples of things that are out of scope for prettier: -- Turning single/double quotes into template literals or vice versa. -- Adding/removing `{}` and `return` where they are optional. -- Turning `?:` into `if then else`. - +* Turning single/double quotes into template literals or vice versa. +* Adding/removing `{}` and `return` where they are optional. +* Turning `?:` into `if then else`. @@ -19,6 +20,7 @@ next: doc2 ``` Blog posts should be written as markdown files with the following front matter: + ``` --- title: Blog Post Title @@ -27,6 +29,7 @@ authorURL: http://twitter.com/author authorFBID: 21315325 --- ``` + In the blog post you should include a line ``. This will determine under which point text will be ignored when generating the preview of your blog post. Blog posts should have the file name format: `yyyy-mm-dd-your-file-name.md`. ### Language Configurations @@ -57,7 +60,6 @@ yarn start This will start a server hosting your website locally at `localhost:3000`. This server will ignore any occurrences `siteConfig.baseUrl` in URLs, e.g. `localhost:3000/your-site/index.html` will be the same as `localhost:3000/index.html`. Any changes to configured files will be reflected by refreshing the page, i.e. the server does not need to be restarted to show changes. - ### Build Static Pages To create a static build of your website, run the script: diff --git a/yarn.lock b/yarn.lock index 33bfcc9d..0d3a8a3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -147,6 +147,10 @@ array-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" @@ -953,6 +957,13 @@ callsites@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + camelcase@4.1.0, camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" @@ -961,6 +972,10 @@ camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + camelcase@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" @@ -998,7 +1013,7 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.3.0: +chalk@^2.1.0, chalk@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" dependencies: @@ -1259,6 +1274,12 @@ cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0": dependencies: cssom "0.3.x" +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -1279,7 +1300,7 @@ debug@^2.1.1, debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: dependencies: ms "2.0.0" -decamelize@^1.0.0, decamelize@^1.1.1: +decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1426,6 +1447,16 @@ escodegen@^1.6.1: optionalDependencies: source-map "~0.2.0" +eslint-formatter-pretty@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-1.3.0.tgz#985d9e41c1f8475f4a090c5dbd2dfcf2821d607e" + dependencies: + ansi-escapes "^2.0.0" + chalk "^2.1.0" + log-symbols "^2.0.0" + plur "^2.1.2" + string-width "^2.0.0" + eslint-friendly-formatter@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/eslint-friendly-formatter/-/eslint-friendly-formatter-3.0.0.tgz#278874435a6c46ec1d94fa0b1ff494e30ef04290" @@ -1472,6 +1503,13 @@ eslint-plugin-prettier@2.1.2: fast-diff "^1.1.1" jest-docblock "^20.0.1" +eslint-plugin-prettier@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d" + dependencies: + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + eslint-plugin-react@7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.1.0.tgz#27770acf39f5fd49cd0af4083ce58104eb390d4c" @@ -1823,6 +1861,10 @@ get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + get-stream@3.0.0, get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -1861,7 +1903,7 @@ globals@^9.0.0, globals@^9.17.0, globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" -globby@6.1.0: +globby@6.1.0, globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" dependencies: @@ -2028,7 +2070,7 @@ ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" -ignore@3.3.7: +ignore@3.3.7, ignore@^3.3.5: version "3.3.7" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" @@ -2040,6 +2082,12 @@ imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + indexes-of@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" @@ -2100,6 +2148,10 @@ invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" +irregular-plurals@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" + is-alphabetical@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-alphabetical/-/is-alphabetical-1.0.1.tgz#c77079cc91d4efac775be1034bf2d243f95e6f08" @@ -2440,7 +2492,7 @@ jest-docblock@^20.0.1: version "20.0.3" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-20.0.3.tgz#17bea984342cc33d83c50fbe1545ea0efaa44712" -jest-docblock@^21.2.0: +jest-docblock@^21.0.0, jest-docblock@^21.2.0: version "21.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" @@ -2748,6 +2800,10 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +lines-and-columns@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -2799,6 +2855,12 @@ lodash@^4.0.0, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +log-symbols@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.1.0.tgz#f35fa60e278832b538dc4dddcbb478a45d3e3be6" + dependencies: + chalk "^2.0.1" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -2809,6 +2871,13 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0" +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + lru-cache@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" @@ -2840,6 +2909,10 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + markdown-escapes@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.1.tgz#1994df2d3af4811de59a6714934c2b2292734518" @@ -2857,6 +2930,21 @@ memory-fs@^0.4.0, memory-fs@~0.4.1: errno "^0.1.3" readable-stream "^2.0.1" +meow@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + merge@^1.1.3: version "1.2.0" resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" @@ -2918,7 +3006,7 @@ minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" -minimist@1.2.0, minimist@^1.1.1, minimist@^1.2.0: +minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" @@ -3015,6 +3103,15 @@ normalize-package-data@^2.3.2: semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" +normalize-package-data@^2.3.4: + version "2.4.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + normalize-path@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" @@ -3292,6 +3389,12 @@ pkg-dir@^1.0.0: dependencies: find-up "^1.0.0" +plur@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a" + dependencies: + irregular-plurals "^1.0.0" + pluralize@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" @@ -3353,9 +3456,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.0.tgz#d9dc68277cf1ded816c8e8863ab47889c29ce9a6" +prettier@1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.2.tgz#bff83e7fd573933c607875e5ba3abbdffb96aeb8" pretty-format@^21.1.0: version "21.1.0" @@ -3371,6 +3474,18 @@ pretty-format@^21.2.1: ansi-regex "^3.0.0" ansi-styles "^3.2.0" +prettylint@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettylint/-/prettylint-1.0.0.tgz#b71720ad9733e098fdd8ebea90c61cda33371aa1" + dependencies: + eslint-formatter-pretty "^1.3.0" + eslint-plugin-prettier "^2.2.0" + globby "^6.1.0" + ignore "^3.3.5" + lines-and-columns "^1.1.6" + meow "^3.7.0" + tslib "^1.8.0" + private@^0.1.6, private@^0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" @@ -3512,6 +3627,13 @@ rechoir@^0.6.2: dependencies: resolve "^1.1.6" +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + regenerate@^1.2.1: version "1.3.2" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" @@ -4060,6 +4182,12 @@ strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -4189,6 +4317,10 @@ tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" @@ -4209,6 +4341,10 @@ tryit@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" +tslib@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.8.0.tgz#dc604ebad64bcbf696d613da6c954aa0e7ea1eb6" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"