From a1a7502f4f77498d24085862e9fd40f46c056f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Gim=C3=A9nez?= Date: Mon, 13 Sep 2021 13:33:33 -0300 Subject: [PATCH 001/193] Update integrating-with-linters.md (#11399) --- docs/integrating-with-linters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integrating-with-linters.md b/docs/integrating-with-linters.md index fe2107104fe3..25a10e5b9dc3 100644 --- a/docs/integrating-with-linters.md +++ b/docs/integrating-with-linters.md @@ -31,7 +31,7 @@ The downsides of those plugins are: - They are slower than running Prettier directly. - They’re yet one layer of indirection where things may break. -Finally, we have tools that runs `prettier` and then immediately for example `eslint --fix` on files. +Finally, we have tools that run `prettier` and then immediately for example `eslint --fix` on files. - [prettier-eslint](https://github.com/prettier/prettier-eslint) - [prettier-tslint](https://github.com/azz/prettier-tslint) From ae33e494a91ced3e80f139ca075cb27bc645acb2 Mon Sep 17 00:00:00 2001 From: Carlos Frias <32054831+terracota-p@users.noreply.github.com> Date: Mon, 13 Sep 2021 18:38:11 +0200 Subject: [PATCH 002/193] fix(docs): lint-staged install instructions (#11363) As per https://github.com/okonet/lint-staged#installation-and-setup The previous ones were not working. --- docs/precommit.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/precommit.md b/docs/precommit.md index 9a22010a4bcf..955acb272ab5 100644 --- a/docs/precommit.md +++ b/docs/precommit.md @@ -12,7 +12,7 @@ You can use Prettier with a pre-commit tool. This can re-format your files that _Make sure Prettier is installed and is in your [`devDependencies`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file) before you proceed._ ```bash -npx mrm lint-staged +npx mrm@2 lint-staged ``` This will install [husky](https://github.com/typicode/husky) and [lint-staged](https://github.com/okonet/lint-staged), then add a configuration to the project’s `package.json` that will automatically format supported files in a pre-commit hook. From aa63269743e510ed1eaedaa4e9465430c9ff807d Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Wed, 15 Sep 2021 21:03:04 +0900 Subject: [PATCH 003/193] Add new CLI option `debug-print-ast` (#11514) * Add new CLI option debug-print-ast * Add tests * Add changelog * Remove text from ast * Update tests/integration/__tests__/debug-print-ast.js Co-authored-by: Georgii Dolzhykov * Update tests Co-authored-by: Georgii Dolzhykov --- changelog_unreleased/cli/11514.md | 3 +++ src/cli/constant.js | 3 +++ src/cli/format.js | 7 +++++++ .../__tests__/__snapshots__/debug-print-ast.js.snap | 5 +++++ tests/integration/__tests__/debug-print-ast.js | 12 ++++++++++++ 5 files changed, 30 insertions(+) create mode 100644 changelog_unreleased/cli/11514.md create mode 100644 tests/integration/__tests__/__snapshots__/debug-print-ast.js.snap create mode 100644 tests/integration/__tests__/debug-print-ast.js diff --git a/changelog_unreleased/cli/11514.md b/changelog_unreleased/cli/11514.md new file mode 100644 index 000000000000..cc6ed95ac4ab --- /dev/null +++ b/changelog_unreleased/cli/11514.md @@ -0,0 +1,3 @@ +#### Add new CLI option `debug-print-ast` (#11514 by @sosukesuzuki) + +A new `--debug-print-ast` CLI flag for debugging. diff --git a/src/cli/constant.js b/src/cli/constant.js index 05f45556eb0b..584fa08336f5 100644 --- a/src/cli/constant.js +++ b/src/cli/constant.js @@ -135,6 +135,9 @@ const options = { "debug-print-comments": { type: "boolean", }, + "debug-print-ast": { + type: "boolean", + }, "debug-repeat": { // Repeat the formatting a few times and measure the average duration. type: "int", diff --git a/src/cli/format.js b/src/cli/format.js index 208066d8be6b..df9055c433d4 100644 --- a/src/cli/format.js +++ b/src/cli/format.js @@ -126,6 +126,13 @@ function format(context, input, opt) { }; } + if (context.argv["debug-print-ast"]) { + const { ast } = prettier.__debug.parse(input, opt); + return { + formatted: JSON.stringify(ast), + }; + } + if (context.argv["debug-check"]) { const pp = prettier.format(input, opt); const pppp = prettier.format(pp, opt); diff --git a/tests/integration/__tests__/__snapshots__/debug-print-ast.js.snap b/tests/integration/__tests__/__snapshots__/debug-print-ast.js.snap new file mode 100644 index 000000000000..bb55eecf05ad --- /dev/null +++ b/tests/integration/__tests__/__snapshots__/debug-print-ast.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`prints information for debugging AST --debug-print-ast (stdout) 1`] = `"{\\"type\\":\\"File\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"errors\\":[],\\"program\\":{\\"type\\":\\"Program\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"sourceType\\":\\"module\\",\\"interpreter\\":null,\\"body\\":[{\\"type\\":\\"VariableDeclaration\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"declarations\\":[{\\"type\\":\\"VariableDeclarator\\",\\"start\\":6,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[6,17],\\"id\\":{\\"type\\":\\"Identifier\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9},\\"identifierName\\":\\"foo\\"},\\"range\\":[6,9],\\"name\\":\\"foo\\"},\\"init\\":{\\"type\\":\\"StringLiteral\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[12,17],\\"extra\\":{\\"rawValue\\":\\"foo\\",\\"raw\\":\\"'foo'\\"},\\"value\\":\\"foo\\"}}],\\"kind\\":\\"const\\"}],\\"directives\\":[]},\\"comments\\":[],\\"tokens\\":[{\\"type\\":{\\"label\\":\\"const\\",\\"keyword\\":\\"const\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"const\\",\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":5}}},{\\"type\\":{\\"label\\":\\"name\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9}}},{\\"type\\":{\\"label\\":\\"=\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":true,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"=\\",\\"start\\":10,\\"end\\":11,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":10},\\"end\\":{\\"line\\":1,\\"column\\":11}}},{\\"type\\":{\\"label\\":\\"string\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}}},{\\"type\\":{\\"label\\":\\";\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":17,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":17},\\"end\\":{\\"line\\":1,\\"column\\":18}}},{\\"type\\":{\\"label\\":\\"eof\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":18,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":18},\\"end\\":{\\"line\\":1,\\"column\\":18}}}]}"`; + +exports[`prints information for debugging AST --debug-print-ast (write) 1`] = `Array []`; diff --git a/tests/integration/__tests__/debug-print-ast.js b/tests/integration/__tests__/debug-print-ast.js new file mode 100644 index 000000000000..53022674e4c2 --- /dev/null +++ b/tests/integration/__tests__/debug-print-ast.js @@ -0,0 +1,12 @@ +"use strict"; + +const runPrettier = require("../runPrettier.js"); + +describe("prints information for debugging AST --debug-print-ast", () => { + runPrettier("cli/with-shebang", ["--debug-print-ast", "--parser", "babel"], { + input: "const foo = 'foo';", + }).test({ + stderr: "", + status: 0, + }); +}); From 59b5eb4e1faf912dd46759c98b45cfe5807e7a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Nikoli=C4=87?= Date: Thu, 16 Sep 2021 07:08:03 +0200 Subject: [PATCH 004/193] Fix wildcard syntax in `@forward` (#11482) (#11487) * Fix wildcard syntax in `@forward` (#11482) * Add additional tests * Apply suggestions from code review Co-authored-by: Georgii Dolzhykov Co-authored-by: Georgii Dolzhykov --- changelog_unreleased/scss/11487.md | 13 +++++++++++++ src/language-css/printer-postcss.js | 13 +++++++++++++ .../scss/quotes/__snapshots__/jsfmt.spec.js.snap | 12 ++++++++++-- tests/format/scss/quotes/quotes.scss | 2 ++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 changelog_unreleased/scss/11487.md diff --git a/changelog_unreleased/scss/11487.md b/changelog_unreleased/scss/11487.md new file mode 100644 index 000000000000..f562cf488cc5 --- /dev/null +++ b/changelog_unreleased/scss/11487.md @@ -0,0 +1,13 @@ +#### Fix wildcard syntax in `@forward` (#11482) (#11487 by @niksy) + + +```scss +// Input +@forward "library" as btn-*; + +// Prettier stable +@forward "library" as btn- *; + +// Prettier main +@forward "library" as btn-*; +``` diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index c7ebe7e561f4..0c326d6d26bd 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -550,6 +550,19 @@ function genericPrint(path, options, print) { continue; } + // Ignore SCSS @forward wildcard suffix + if ( + insideAtRuleNode(path, "forward") && + iNode.type === "value-word" && + iNode.value && + iPrevNode.type === "value-word" && + iPrevNode.value === "as" && + iNextNode.type === "value-operator" && + iNextNode.value === "*" + ) { + continue; + } + // Ignore after latest node (i.e. before semicolon) if (!iNextNode) { continue; diff --git a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap index 042fdbb3bf79..06419858dada 100644 --- a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap @@ -29,6 +29,8 @@ singleQuote: true @forward "library" as btn-*; +@forward "library" as btn*; + =====================================output===================================== @use 'library'; @@ -47,7 +49,9 @@ singleQuote: true @forward 'library' hide gradient; -@forward 'library' as btn- *; +@forward 'library' as btn-*; + +@forward 'library' as btn*; ================================================================================ `; @@ -80,6 +84,8 @@ printWidth: 80 @forward "library" as btn-*; +@forward "library" as btn*; + =====================================output===================================== @use "library"; @@ -98,7 +104,9 @@ printWidth: 80 @forward "library" hide gradient; -@forward "library" as btn- *; +@forward "library" as btn-*; + +@forward "library" as btn*; ================================================================================ `; diff --git a/tests/format/scss/quotes/quotes.scss b/tests/format/scss/quotes/quotes.scss index 332074a453a5..20607380fbad 100644 --- a/tests/format/scss/quotes/quotes.scss +++ b/tests/format/scss/quotes/quotes.scss @@ -19,3 +19,5 @@ @forward "library" hide gradient; @forward "library" as btn-*; + +@forward "library" as btn*; From 7ced9e66549b8d5a8e3a74473af462f86fb0245c Mon Sep 17 00:00:00 2001 From: sosukesuzuki Date: Thu, 16 Sep 2021 15:06:00 +0900 Subject: [PATCH 005/193] Release 2.4.1 --- .github/ISSUE_TEMPLATE/formatting.md | 2 +- .github/ISSUE_TEMPLATE/integration.md | 2 +- CHANGELOG.md | 22 ++++++++++++++++ docs/browser.md | 26 +++++++++---------- package.json | 2 +- .../versioned_docs/version-stable/browser.md | 26 +++++++++---------- .../integrating-with-linters.md | 2 +- .../version-stable/precommit.md | 2 +- 8 files changed, 53 insertions(+), 31 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 4d1086e84486..0e49a3b9a36c 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you: --> -**Prettier 2.4.0** +**Prettier 2.4.1** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index 392f0594aed7..ad20de82a127 100644 --- a/.github/ISSUE_TEMPLATE/integration.md +++ b/.github/ISSUE_TEMPLATE/integration.md @@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE: **Environments:** -- Prettier Version: 2.4.0 +- Prettier Version: 2.4.1 - Running Prettier via: - Runtime: - Operating System: diff --git a/CHANGELOG.md b/CHANGELOG.md index 34fccfd16a41..03e7a43c1f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# 2.4.1 + +[diff](https://github.com/prettier/prettier/compare/2.4.0...2.4.1) + +#### Fix wildcard syntax in `@forward` ([#11482](https://github.com/prettier/prettier/pull/11482)) ([#11487](https://github.com/prettier/prettier/pull/11487) by [@niksy](https://github.com/niksy)) + + +```scss +// Input +@forward "library" as btn-*; + +// Prettier 2.4.0 +@forward "library" as btn- *; + +// Prettier 2.4.1 +@forward "library" as btn-*; +``` + +#### Add new CLI option `debug-print-ast` ([#11514](https://github.com/prettier/prettier/pull/11514) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +A new `--debug-print-ast` CLI flag for debugging. + # 2.4.0 [diff](https://github.com/prettier/prettier/compare/2.3.2...2.4.0) diff --git a/docs/browser.md b/docs/browser.md index 8c650329ec52..0a741f408e28 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -32,8 +32,8 @@ See below for examples. ### Global ```html - - + + - + +