From f859cafb84862cb753c2e2dbf6153e7ba2f8db62 Mon Sep 17 00:00:00 2001
From: Georgii Dolzhykov >); // OK
================================================================================
`;
-exports[`test2.js 1`] = `
+exports[`test2.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
@@ -207,7 +207,7 @@ class C--quote-props
| quoteProps: "
|
## JSX Quotes
@@ -103,9 +103,9 @@ Valid options:
- `"none"` - No trailing commas.
- `"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 |
-| ------- | --------------------------------- | --------------------------------- |
-| `"es5"` | `--trailing-comma --trailing-comma
| trailingComma: "
|
## Bracket Spacing
@@ -166,9 +166,9 @@ Valid options:
- `"always"` - Always include parens. Example: `(x) => x`
- `"avoid"` - Omit parens when possible. Example: `x => x`
-| Default | CLI Override | API Override |
-| ---------- | ------------------------------- | ------------------------------- |
-| `"always"` | `--arrow-parens --arrow-parens
| arrowParens: "
|
At first glance, avoiding parentheses may look like a better choice because of less visual noise.
However, when Prettier removes parentheses, it becomes harder to add type annotations, extra arguments or default values as well as making other changes.
@@ -292,9 +292,9 @@ Valid options:
- `"never"` - Do not wrap prose.
- `"preserve"` - Wrap prose as-is. _First available in v1.9.0_
-| Default | CLI Override | API Override |
-| ------------ | -------------------------------------- | -------------------------------------- |
-| `"preserve"` | `--prose-wrap --prose-wrap
| proseWrap: "
|
## HTML Whitespace Sensitivity
@@ -310,9 +310,9 @@ Valid options:
- `"strict"` - Whitespaces are considered sensitive.
- `"ignore"` - Whitespaces are considered insensitive.
-| Default | CLI Override | API Override |
-| ------- | --------------------------------------------------- | -------------------------------------------------- |
-| `"css"` | `--html-whitespace-sensitivity --html-whitespace-sensitivity
| htmlWhitespaceSensitivity: "
|
## Vue files script and style tags indentation
@@ -361,6 +361,6 @@ Valid options:
- `"auto"` - Maintain existing line endings
(mixed values within one file are normalised by looking at what's used after the first line)
-| Default | CLI Override | API Override |
-| ------- | --------------------------------- | -------------------------------- |
-| `"lf"` | `--end-of-line --end-of-line
| endOfLine: "
|
diff --git a/website/versioned_docs/version-stable/options.md b/website/versioned_docs/version-stable/options.md
index e0e0803483..ffb36eda05 100644
--- a/website/versioned_docs/version-stable/options.md
+++ b/website/versioned_docs/version-stable/options.md
@@ -80,9 +80,9 @@ Valid options:
- `"consistent"` - If at least one property in an object requires quotes, quote all properties.
- `"preserve"` - Respect the input use of quotes in object properties.
-| Default | CLI Override | API Override |
-| ------------- | ----------------------------------------------- | ----------------------------------------------- |
-| `"as-needed"` | `--quote-props --quote-props
| quoteProps: "
|
## JSX Quotes
@@ -104,9 +104,9 @@ Valid options:
- `"none"` - No trailing commas.
- `"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 |
-| ------- | --------------------------------- | --------------------------------- |
-| `"es5"` | `--trailing-comma --trailing-comma
| trailingComma: "
|
## Bracket Spacing
@@ -167,9 +167,9 @@ Valid options:
- `"always"` - Always include parens. Example: `(x) => x`
- `"avoid"` - Omit parens when possible. Example: `x => x`
-| Default | CLI Override | API Override |
-| ---------- | ------------------------------- | ------------------------------- |
-| `"always"` | `--arrow-parens --arrow-parens
| arrowParens: "
|
At first glance, avoiding parentheses may look like a better choice because of less visual noise.
However, when Prettier removes parentheses, it becomes harder to add type annotations, extra arguments or default values as well as making other changes.
@@ -293,9 +293,9 @@ Valid options:
- `"never"` - Do not wrap prose.
- `"preserve"` - Wrap prose as-is. _First available in v1.9.0_
-| Default | CLI Override | API Override |
-| ------------ | -------------------------------------- | -------------------------------------- |
-| `"preserve"` | `--prose-wrap --prose-wrap
| proseWrap: "
|
## HTML Whitespace Sensitivity
@@ -311,9 +311,9 @@ Valid options:
- `"strict"` - Whitespaces are considered sensitive.
- `"ignore"` - Whitespaces are considered insensitive.
-| Default | CLI Override | API Override |
-| ------- | --------------------------------------------------- | -------------------------------------------------- |
-| `"css"` | `--html-whitespace-sensitivity --html-whitespace-sensitivity
| htmlWhitespaceSensitivity: "
|
## Vue files script and style tags indentation
@@ -362,6 +362,6 @@ Valid options:
- `"auto"` - Maintain existing line endings
(mixed values within one file are normalised by looking at what's used after the first line)
-| Default | CLI Override | API Override |
-| ------- | --------------------------------- | -------------------------------- |
-| `"lf"` | `--end-of-line --end-of-line
| endOfLine: "
|
From 1b56e90170ea2f911381d46786a5bd359d2fc472 Mon Sep 17 00:00:00 2001
From: Georgii Dolzhykov Redirecting…
if (match != null) {
const [, /* url */ pr] = match;
location.replace(
- `https://deploy-preview-${pr}--prettier.netlify.com/playground`
+ `https://deploy-preview-${pr}--prettier.netlify.app/playground`
);
} else {
const el = document.createElement("p");
From 5a2a1c21011f4f056f853550b301435521674131 Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Tue, 7 Apr 2020 12:20:16 +0300
Subject: [PATCH 0003/2034] Bump rollup from 2.3.2 to 2.3.3 (#7960)
Bumps [rollup](https://github.com/rollup/rollup) from 2.3.2 to 2.3.3.
- [Release notes](https://github.com/rollup/rollup/releases)
- [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rollup/rollup/compare/v2.3.2...v2.3.3)
Signed-off-by: dependabot-preview[bot]
+I am expecting this to come out exactly like it went in. +`; + +// using --embedded-language-formatting=auto (or omitting this option) +html` +
+ I am expecting this to come out exactly like it went in. +
+`; + +// using --embedded-language-formatting=off +html` +
+I am expecting this to come out exactly like it went in.
+`;
+```
diff --git a/docs/options.md b/docs/options.md
index 5176e2544f..b8173c0c19 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -364,3 +364,22 @@ Valid options:
| Default | CLI Override | API Override |
| ------- | ----------------------------------------------------------- | ---------------------------------------------------------- |
| `"lf"` | --end-of-line
| endOfLine: "
|
+
+## Embedded Language Formatting
+
+_First available in v2.1.0_
+
+Control whether Prettier formats quoted code embedded in the file.
+
+When Prettier identifies cases where it looks like you've placed some code it knows how to format within a string in another file, like in a tagged template in JavaScript with a tag named `html` or in code blocks in Markdown, it will by default try to format that code.
+
+Sometimes this behavior is undesirable, particularly in cases where you might not have intended the string to be interpreted as code. This option allows you to switch between the default behavior (`auto`) and disabling this feature entirely (`off`).
+
+Valid options:
+
+- `"auto"` – Format embedded code if Prettier can automatically identify it.
+- `"off"` - Never automatically format embedded code.
+
+| Default | CLI Override | API Override |
+| -------- | ------------------------------------ | ----------------------------------- |
+| `"auto"` | `--embedded-language-formatting=off` | `embeddedLanguageFormatting: "off"` |
diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js
index 5d4298d585..c76b67755d 100644
--- a/src/language-js/printer-estree.js
+++ b/src/language-js/printer-estree.js
@@ -2528,14 +2528,14 @@ function printPathNoParens(path, options, print, args) {
return concat(parts);
}
- // These types are unprintable because they serve as abstract
- // supertypes for other (printable) types.
case "TaggedTemplateExpression":
return concat([
path.call(print, "tag"),
path.call(print, "typeParameters"),
path.call(print, "quasi"),
]);
+ // These types are unprintable because they serve as abstract
+ // supertypes for other (printable) types.
case "Node":
case "Printable":
case "SourceLocation":
diff --git a/src/main/core-options.js b/src/main/core-options.js
index 1721817c8c..f7bf94c91b 100644
--- a/src/main/core-options.js
+++ b/src/main/core-options.js
@@ -246,6 +246,25 @@ const options = {
default: false,
description: "Indent with tabs instead of spaces.",
},
+ embeddedLanguageFormatting: {
+ since: "2.1.0",
+ category: CATEGORY_GLOBAL,
+ type: "choice",
+ default: [{ since: "2.1.0", value: "auto" }],
+ description:
+ "Control how Prettier formats quoted code embedded in the file.",
+ choices: [
+ {
+ value: "auto",
+ description:
+ "Format embedded code if Prettier can automatically identify it.",
+ },
+ {
+ value: "off",
+ description: "Never automatically format embedded code.",
+ },
+ ],
+ },
};
module.exports = {
diff --git a/src/main/multiparser.js b/src/main/multiparser.js
index aedf52b046..5ed4f65cc6 100644
--- a/src/main/multiparser.js
+++ b/src/main/multiparser.js
@@ -4,7 +4,7 @@ const { normalize } = require("./options");
const comments = require("./comments");
function printSubtree(path, print, options, printAstToDoc) {
- if (options.printer.embed) {
+ if (options.printer.embed && options.embeddedLanguageFormatting === "auto") {
return options.printer.embed(
path,
print,
diff --git a/tests/embedded_language_formatting/in-html/__snapshots__/jsfmt.spec.js.snap b/tests/embedded_language_formatting/in-html/__snapshots__/jsfmt.spec.js.snap
new file mode 100644
index 0000000000..5a32c83195
--- /dev/null
+++ b/tests/embedded_language_formatting/in-html/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,55 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`test.html format 1`] = `
+====================================options=====================================
+parsers: ["html"]
+printWidth: 80
+ | printWidth
+=====================================input======================================
+
+
yarn svgo _path/to/image.svg_
before committing a new SVG to the repository.
+
+## Playground
+
+The Playground is not integrated with the Docusaurus infrastructure. Its UI (`website/playground/`) is built separately with webpack configured to put the resulting bundle in Docusaurus's `static` directory. The `yarn start` command (in `website/`) concurrently starts both Docusaurus's local server and webpack in the watch mode for the Playground.
+
+Another part of the Playground is a web worker where formatting happens. It's not managed by webpack and resides directly in `static/worker.js`. It expects to find the [UMD bundles of Prettier](https://prettier.io/docs/en/browser.html) in `static/lib/`. That's why running `yarn build-docs` or `PULL_REQUEST=true yarn build-docs` in the project root is a required step.
-In the project repo, the `docs` folder is used to hold documentation written in markdown. A `blog` folder can be used to hold blog posts written in markdown.
+Finally, there is a service worker that caches Prettier's relatively heavy bundles (`static/service-worker.js`).
-### Document and Blog Front Matters
+## Documentation
-Documentation should contain front matter that follows this example:
+In the project repo, the `docs` directory is used to hold documentation written in Markdown.
+The front matter of documentation files should follow this example:
```yaml
id: doc1 # used for docs to find each other and to map links
@@ -40,88 +60,22 @@ next: doc2 # next doc on the sidebar for navigation
```
-Blog posts should be written as markdown files with the following front matter:
+The docs from `docs/` are published to `https://prettier.io/docs/en/next/` and are considered to be the docs of the next (not yet released) version of Prettier. When a release happens, the docs from `docs/` are copied to the `website/versioned_docs/version-stable` directory, whose content is published to `https://prettier.io/docs/en`.
+
+## Blog
+
+The `website/blog` directory contains blog posts written in Markdown. Their front matter should follow this example:
```yaml
title: Blog Post Title
author: Author Name
-authorURL: http://twitter.com/author # (or some other link)
-authorFBID: 21315325 # id to get author's picture
+authorURL: http://github.com/author # (or some other link)
---
```
-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
-
-The `examples` script will generate a `languages.js` file and `i18n` folder for translation support, but if you only wish to support English, then these are not needed.
-
-### Site Configurations
-
-Configure the siteConfig.js file which has comments guiding you through what needs to be done and how each configuration affects your website.
-
-Customize core/Footer.js which will serve as the footer for each page on your website.
-
-Include your own top-level pages as React components in `pages/`. These components should just be the body sections of the pages you want, and they will be included with the header and footer that the rest of Docusaurus uses. Examples are provided for your reference. Currently, if you want to add other React components to your pages, you must include all of it inside that file due to how `require` paths are set-up. You may also include `.html` files directly, but this is not recommended, and these will just be served as is and will not have any of the header/footer/styles shared by the rest of Docusaurus.
-
-All images and other static assets you wish to include should be placed inside the `static` folder. Any `.css` files provided in `static` will be concatenated to the standard styles provided by Docusaurus and used site-wide.
-
-Files placed in `static/` will be accessible in the following way: `static/img/image.png` will be accessible at `img/image.png`.
-
-Please run yarn svgo _path/to/image.svg_
before committing a new SVG to the repository.
-
-## Using Docusaurus
-
-### Run the Server
-
-To run your website locally run the script:
-
-```bash
-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
+In the blog post, you should include a line ``. This determines 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`.
-To create a static build of your website, run the script:
-
-```bash
-yarn build
-```
+## Static Build
-This will generate `.html` files from all of your docs and other pages included in `pages/`. This allows you to check whether or not all your files are being generated correctly. The build folder is inside Docusaurus's directory inside `node_modules`.
-
-### Publishing Your Website
-
-Use CircleCI to publish your website whenever your project repo is updated. Configure your circle.yml file in your project repo to run commands to publish to GitHub Pages. An example is shown here:
-
-```yaml
-machine:
- node:
- version: 6.10.3
- npm:
- version: 3.10.10
-
-test:
- override:
- - "true"
-
-deployment:
- website:
- branch: master
- commands:
- - git config --global user.email "test-site-bot@users.noreply.github.com"
- - git config --global user.name "Website Deployment Script"
- - echo "machine github.com login test-site-bot password $GITHUB_TOKEN" > ~/.netrc
- - cd website && npm install && GIT_USER=test-site-bot npm run publish-gh-pages
-```
-
-Note that in this case a GitHub user `test-site-bot` is created to use just for publishing. Make sure to give your Git user push permissions for your project and to set a GITHUB_TOKEN environment variable in Circle if you choose to publish this way.
-
-If you wish to manually publish your website with the `publish-gh-pages` script, run the following example command with the appropriate variables for your project:
-
-```
-DEPLOY_USER=deltice GIT_USER=test-site-bot CIRCLE_PROJECT_USERNAME=deltice CIRCLE_PROJECT_REPONAME=test-site CIRCLE_BRANCH=master npm run publish-gh-pages
-```
+To create a static build of the website, run `yarn build` (in `website/`). The result will be put in `website/build/`.
diff --git a/website/deploy.sh b/website/deploy.sh
deleted file mode 100755
index 0614e335ff..0000000000
--- a/website/deploy.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-if [ "$NODE_ENV" = production ]; then
- echo "info: skipping deploy in production builds"
- exit 0
-fi
-
-if [ ! "$GITHUB_TOKEN" ]; then
- >&2 echo "error: GITHUB_TOKEN not present in env"
- exit 1
-fi
-
-git config --global user.email "prettier-bot@users.noreply.github.com"
-git config --global user.name "Prettier Bot"
-echo "machine github.com login prettier-bot password $GITHUB_TOKEN" > ~/.netrc
-
-cd website
-export GIT_USER=prettier-bot
-export CIRCLE_BRANCH=$TRAVIS_BRANCH
-export CIRCLE_PROJECT_USERNAME=prettier
-export CIRCLE_PROJECT_REPONAME=prettier
-export CI_PULL_REQUEST=$TRAVIS_PULL_REQUEST_BRANCH
-yarn --pure-lockfile && yarn run publish-gh-pages
diff --git a/website/package.json b/website/package.json
index 9d2e5718d7..e7920f606e 100644
--- a/website/package.json
+++ b/website/package.json
@@ -2,7 +2,6 @@
"license": "MIT",
"scripts": {
"build": "webpack -p && docusaurus-build",
- "publish-gh-pages": "docusaurus-publish",
"start": "concurrently \"docusaurus-start\" \"webpack -d -w\"",
"svgo": "svgo --pretty --indent=2 --config=svgo.yml",
"svgo-all": "find static | grep '\\.svg$' | xargs -Iz -n 1 yarn svgo z",
From 232661c13652d0649113aa10f0332f9934b86df4 Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Wed, 15 Apr 2020 19:13:13 +0800
Subject: [PATCH 0061/2034] Bump semver from 7.3.0 to 7.3.2 (#8060)
Bumps [semver](https://github.com/npm/node-semver) from 7.3.0 to 7.3.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/master/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.3.0...v7.3.2)
Signed-off-by: dependabot-preview[bot]