diff --git a/.editorconfig b/.editorconfig index 58db511587d7..d18a28ff4a8a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ insert_final_newline = true indent_size = 4 insert_final_newline = false -[website/blog/*.md] +[{,website/blog/,changelog_unreleased/**/}*.md] trim_trailing_whitespace = false [tests/{**/__snapshots__/*, tests/format/**/*}] diff --git a/.eslintrc.js b/.eslintrc.js index 562538ab626b..73aea2d35397 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,9 +4,10 @@ const { isCI } = require("ci-info"); module.exports = { root: true, env: { - es2020: true, + es2021: true, node: true, }, + reportUnusedDisableDirectives: true, extends: ["eslint:recommended", "prettier"], plugins: ["prettier-internal-rules", "import", "regexp", "unicorn"], settings: { @@ -89,7 +90,7 @@ module.exports = { }, ], - "import/extensions": ["error", "always", { ignorePackages: true }], + "import/extensions": ["error", "ignorePackages"], "import/no-extraneous-dependencies": [ "error", { @@ -118,6 +119,8 @@ module.exports = { "unicorn/new-for-builtins": "error", "unicorn/no-array-for-each": "error", "unicorn/no-array-push-push": "error", + "unicorn/no-new-array": "error", + "unicorn/no-useless-length-check": "error", "unicorn/no-useless-undefined": "error", "unicorn/prefer-array-flat": [ "error", @@ -126,12 +129,15 @@ module.exports = { }, ], "unicorn/prefer-array-flat-map": "error", + "unicorn/prefer-array-some": "error", "unicorn/prefer-includes": "error", "unicorn/prefer-number-properties": "error", "unicorn/prefer-optional-catch-binding": "error", "unicorn/prefer-regexp-test": "error", "unicorn/prefer-spread": "error", "unicorn/prefer-string-slice": "error", + "unicorn/prefer-string-starts-ends-with": "error", + "unicorn/prefer-type-error": "error", }, overrides: [ { @@ -168,6 +174,7 @@ module.exports = { alwaysAwait: true, }, ], + "jest/prefer-to-be": "error", }, }, { @@ -229,7 +236,7 @@ module.exports = { functions: ["hasComment", "getComments"], }, "src/language-js/pragma.js", - "src/language-js/parse/postprocess.js", + "src/language-js/parse/postprocess/*.js", "src/language-js/parse/babel.js", "src/language-js/parse/meriyah.js", "src/language-js/parse/json.js", diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9423d6060b16..17a8b818f478 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,6 +5,8 @@ # See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt # Prettier bump after release +# 2.4.1 +2b5b22056e7e180ba52b04c849b6e8a1e26d87d1 # 2.4.0 ef514b9b5c817cf5105bac31a59e88cbdbdf189b # 2.3.2 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/.github/workflows/dev-package-test.yml b/.github/workflows/dev-package-test.yml index dd3b770f216b..0c194e1e752a 100644 --- a/.github/workflows/dev-package-test.yml +++ b/.github/workflows/dev-package-test.yml @@ -31,10 +31,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} cache: "yarn" diff --git a/.github/workflows/dev-test.yml b/.github/workflows/dev-test.yml index 40bcb7e966d9..3622b4bfa5b8 100644 --- a/.github/workflows/dev-test.yml +++ b/.github/workflows/dev-test.yml @@ -18,13 +18,13 @@ jobs: - "macos-latest" - "windows-latest" node: - - "16" + - "16.10.0" - "14" - "12" include: # only enable coverage on the fastest job - os: "ubuntu-latest" - node: "16" + node: "16.10.0" ENABLE_CODE_COVERAGE: true FULL_TEST: true CHECK_TEST_PARSERS: true @@ -41,13 +41,13 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 # `codecov/codecov-action` require depth to be at least `2`, see #10219 with: fetch-depth: 2 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} cache: "yarn" @@ -64,7 +64,7 @@ jobs: run: yarn test --maxWorkers=2 - name: Upload Coverage - uses: codecov/codecov-action@v2.0.3 + uses: codecov/codecov-action@v2.1.0 if: ${{ matrix.ENABLE_CODE_COVERAGE }} with: fail_ci_if_error: true @@ -76,7 +76,7 @@ jobs: PRETTIER_FALLBACK_RESOLVE: true - name: Upload Coverage (PRETTIER_FALLBACK_RESOLVE) - uses: codecov/codecov-action@v2.0.3 + uses: codecov/codecov-action@v2.1.0 if: ${{ matrix.ENABLE_CODE_COVERAGE }} with: fail_ci_if_error: true diff --git a/.github/workflows/eslint-rules.yml b/.github/workflows/eslint-rules.yml index 718ab4a71c0c..724f2b3a5611 100644 --- a/.github/workflows/eslint-rules.yml +++ b/.github/workflows/eslint-rules.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: cache: "yarn" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4dbd35a0e96f..5a7de9eba532 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: cache: "yarn" diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 6f8df0eff0a2..5207ea059c61 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -8,13 +8,13 @@ jobs: lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v2 + - uses: dessant/lock-threads@v3 with: # https://github.com/dessant/lock-threads github-token: ${{ github.token }} - issue-lock-inactive-days: "90" - issue-exclude-created-before: "" - issue-exclude-labels: "keep-unlocked, status:awaiting response" - issue-lock-labels: "locked-due-to-inactivity" - issue-lock-comment: "" + issue-inactive-days: "90" + exclude-issue-created-before: "" + exclude-any-issue-labels: "keep-unlocked, status:awaiting response" + add-issue-labels: "locked-due-to-inactivity" + issue-comment: "" issue-lock-reason: "resolved" diff --git a/.github/workflows/mark-issue-duplicate.yml b/.github/workflows/mark-issue-duplicate.yml index 203a55c2d4b4..5247a0e5c520 100644 --- a/.github/workflows/mark-issue-duplicate.yml +++ b/.github/workflows/mark-issue-duplicate.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: ${{ !github.event.issue.pull_request && startsWith(github.event.comment.body, 'Duplicate of ') }} steps: - - uses: actions-cool/issues-helper@v2.4.2 + - uses: actions-cool/issues-helper@v2.5.0 with: actions: "mark-duplicate" token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prod-test.yml b/.github/workflows/prod-test.yml index e7ee6d881add..6e8161c34165 100644 --- a/.github/workflows/prod-test.yml +++ b/.github/workflows/prod-test.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: cache: "yarn" @@ -59,10 +59,10 @@ jobs: needs: [build] steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: cache: "yarn" @@ -88,13 +88,13 @@ jobs: - "macos-latest" - "windows-latest" node: - - "16" + - "16.10.0" - "14" - "12" - "10" include: - os: "ubuntu-latest" - node: "16" + node: "16.10.0" FULL_TEST: true exclude: - os: "macos-latest" @@ -112,10 +112,10 @@ jobs: needs: [build] steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node }} cache: "yarn" diff --git a/.github/workflows/release-script-test.yml b/.github/workflows/release-script-test.yml index 52470aae7bc2..5fcdf8fabca8 100644 --- a/.github/workflows/release-script-test.yml +++ b/.github/workflows/release-script-test.yml @@ -20,10 +20,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: version: "14" cache: "yarn" diff --git a/CHANGELOG.md b/CHANGELOG.md index 34fccfd16a41..f5dbcfdf437f 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) @@ -289,6 +311,7 @@ const foo = call<{ #### Fix order of `override` modifiers ([#10961](https://github.com/prettier/prettier/pull/10961) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + ```ts // Input class Foo extends Bar { @@ -297,7 +320,7 @@ class Foo extends Bar { // Prettier stable class Foo extends Bar { - abstract override foo: string; + override abstract foo: string; } // Prettier main diff --git a/README.md b/README.md index 189df95a6982..14ced8d52a58 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ foo( ); ``` -Prettier can be run [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-picky comment on a code review ever again! +Prettier can be run [in your editor](https://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-picky comment on a code review ever again! --- 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/changelog_unreleased/handlebars/11524.md b/changelog_unreleased/handlebars/11524.md new file mode 100644 index 000000000000..09d8fd6c4580 --- /dev/null +++ b/changelog_unreleased/handlebars/11524.md @@ -0,0 +1,14 @@ +#### Uses the opposite quote type for quotes inside mustache statements in attributes (#11524 by @bmaehr) + + +```hbs +{{!-- Input --}} +
+ +{{!-- Prettier main --}} + + +{{!-- Prettier stable --}} + + +``` diff --git a/changelog_unreleased/html/11827.md b/changelog_unreleased/html/11827.md new file mode 100644 index 000000000000..64380852e4c7 --- /dev/null +++ b/changelog_unreleased/html/11827.md @@ -0,0 +1 @@ +#### Reverts #7865, keeping class names on the same line (#11827 by @jlongster) diff --git a/changelog_unreleased/javascript/11593.md b/changelog_unreleased/javascript/11593.md new file mode 100644 index 000000000000..2369da27af14 --- /dev/null +++ b/changelog_unreleased/javascript/11593.md @@ -0,0 +1,15 @@ +#### Fix parentheses around sequence expression as body of arrow chain (#11593 by @bakkot) + +The required parentheses around sequence expressions as the body of arrow functions were dropped for chained arrows, causing incorrect code to be generated. Now they are included. + + +```jsx +// Input +const f = () => () => (0, 1); + +// Prettier stable +const f = () => () => 0, 1; + +// Prettier main +const f = () => () => (0, 1); +``` diff --git a/changelog_unreleased/javascript/11750.md b/changelog_unreleased/javascript/11750.md new file mode 100644 index 000000000000..e36df4ac284b --- /dev/null +++ b/changelog_unreleased/javascript/11750.md @@ -0,0 +1,18 @@ +#### Ignore errors for sloppy mode syntax (#11750 by @fisker, #11778 by @sosukesuzuki) + + +```jsx +// Input +function foo() { var bar = 1; delete bar; } + +// Prettier stable +SyntaxError: Deleting local variable in strict mode. (1:31) +> 1 | function foo() { var bar = 1; delete bar; } + | ^ + +// Prettier main +function foo() { + var bar = 1; + delete bar; +} +``` diff --git a/changelog_unreleased/javascript/11800.md b/changelog_unreleased/javascript/11800.md new file mode 100644 index 000000000000..8572920c855a --- /dev/null +++ b/changelog_unreleased/javascript/11800.md @@ -0,0 +1,22 @@ +#### Respect spacing for between expressions and parentheses in embedded CSS (#11800 by @sosukesuzuki) + + + + +```jsx +// Input +const paragraph2 = css` + transform: ${expr}(30px); +`; + +// Prettier stable +const paragraph2 = css` + transform: ${expr} (30px); +`; + +// Prettier main +const paragraph2 = css` + transform: ${expr}(30px); +`; + +``` diff --git a/changelog_unreleased/javascript/11835.md b/changelog_unreleased/javascript/11835.md new file mode 100644 index 000000000000..eb7e51eb7e72 --- /dev/null +++ b/changelog_unreleased/javascript/11835.md @@ -0,0 +1,29 @@ +#### Support ES2022 class-private-fields-in syntax in `espree` parser (#11835 by @fisker) + + +```jsx +// Input +class Foo { + #brand; + static isC(obj) { + return #brand in Foo; + } +} + +// Prettier stable +SyntaxError: Unexpected token #brand (4:12) + 2 | #brand; + 3 | static isC(obj) { +> 4 | return #brand in Foo; + | ^ + 5 | } + 6 | } + +// Prettier main +class Foo { + #brand; + static isC(obj) { + return #brand in Foo; + } +} +``` diff --git a/changelog_unreleased/markdown/11685.md b/changelog_unreleased/markdown/11685.md new file mode 100644 index 000000000000..be3d2301251d --- /dev/null +++ b/changelog_unreleased/markdown/11685.md @@ -0,0 +1,21 @@ +#### Keep trailing commas for type parameters in embedded TSX (#11685 by @sosukesuzuki) + + + + +````md + +```tsx +const test =