diff --git a/.azure-pipelines/jobs/dev-lint.yml b/.azure-pipelines/jobs/dev-lint.yml deleted file mode 100644 index 90486064dcb5..000000000000 --- a/.azure-pipelines/jobs/dev-lint.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: - - template: ../steps/install-nodejs.yml - - template: ../steps/install-dependencies.yml - - script: yarn lint:deps - displayName: "Check dependencies" - - script: yarn lint:typecheck - displayName: "Check JSDoc types" - - script: yarn lint:eslint - displayName: "Lint code" - - script: yarn lint:prettier - displayName: "Lint prettier" - - script: yarn lint:spellcheck - displayName: "Spellcheck" - - script: yarn lint:changelog - displayName: "Lint changelog" - - script: yarn && echo "Listing changed files:" && git diff --name-only --exit-code && echo "No files changed during lint." - displayName: "Check file changes" diff --git a/.azure-pipelines/jobs/dev-test.yml b/.azure-pipelines/jobs/dev-test.yml deleted file mode 100644 index a34f334f3b20..000000000000 --- a/.azure-pipelines/jobs/dev-test.yml +++ /dev/null @@ -1,7 +0,0 @@ -steps: - - template: ../steps/install-nodejs.yml - - template: ../steps/install-dependencies.yml - - script: yarn test - displayName: "Run tests" - - template: ../steps/publish-test-results.yml - - template: ../steps/publish-code-coverage.yml diff --git a/.azure-pipelines/jobs/prod-build.yml b/.azure-pipelines/jobs/prod-build.yml deleted file mode 100644 index c767aa6dd335..000000000000 --- a/.azure-pipelines/jobs/prod-build.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - template: ../steps/install-nodejs.yml - - template: ../steps/install-dependencies.yml - - script: yarn build - displayName: "Build dist" - - template: ../steps/upload-dist.yml diff --git a/.azure-pipelines/jobs/prod-lint.yml b/.azure-pipelines/jobs/prod-lint.yml deleted file mode 100644 index d1a9d70b7da0..000000000000 --- a/.azure-pipelines/jobs/prod-lint.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - template: ../steps/download-dist.yml - - template: ../steps/install-nodejs.yml - - template: ../steps/install-dependencies.yml - - script: yarn lint:dist - displayName: "Lint dist" diff --git a/.azure-pipelines/jobs/prod-pack.yml b/.azure-pipelines/jobs/prod-pack.yml deleted file mode 100644 index a143f0cd31c8..000000000000 --- a/.azure-pipelines/jobs/prod-pack.yml +++ /dev/null @@ -1,10 +0,0 @@ -steps: - - template: ../steps/download-dist.yml - - template: ../steps/install-nodejs.yml - - bash: mv $(npm pack ./dist --silent) $(Build.ArtifactStagingDirectory) - displayName: "Pack dist" - - task: PublishPipelineArtifact@0 - inputs: - artifactName: "dist.tgz" - targetPath: $(Build.ArtifactStagingDirectory) - displayName: "Upload dist.tgz" diff --git a/.azure-pipelines/jobs/prod-test.yml b/.azure-pipelines/jobs/prod-test.yml deleted file mode 100644 index 29acd85677a9..000000000000 --- a/.azure-pipelines/jobs/prod-test.yml +++ /dev/null @@ -1,8 +0,0 @@ -steps: - - template: ../steps/download-dist.yml - - template: ../steps/install-nodejs.yml - - template: ../steps/install-dependencies.yml - - script: yarn test:dist - displayName: "Run tests on dist" - - template: ../steps/publish-test-results.yml - - template: ../steps/publish-code-coverage.yml diff --git a/.azure-pipelines/steps/download-dist.yml b/.azure-pipelines/steps/download-dist.yml deleted file mode 100644 index 7ce24d2862c7..000000000000 --- a/.azure-pipelines/steps/download-dist.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - task: DownloadPipelineArtifact@0 - inputs: - artifactName: "dist" - targetPath: dist - displayName: "Download dist" diff --git a/.azure-pipelines/steps/install-dependencies.yml b/.azure-pipelines/steps/install-dependencies.yml deleted file mode 100644 index f062c636ebbf..000000000000 --- a/.azure-pipelines/steps/install-dependencies.yml +++ /dev/null @@ -1,6 +0,0 @@ -parameters: - flags: "" - -steps: - - script: yarn install --frozen-lockfile - displayName: "Install dependencies" diff --git a/.azure-pipelines/steps/install-nodejs.yml b/.azure-pipelines/steps/install-nodejs.yml deleted file mode 100644 index b431abaa0f3e..000000000000 --- a/.azure-pipelines/steps/install-nodejs.yml +++ /dev/null @@ -1,5 +0,0 @@ -steps: - - task: NodeTool@0 - inputs: - versionSpec: "$(node_version)" - displayName: "Install Node.js" diff --git a/.azure-pipelines/steps/publish-code-coverage.yml b/.azure-pipelines/steps/publish-code-coverage.yml deleted file mode 100644 index 9c5cd329a279..000000000000 --- a/.azure-pipelines/steps/publish-code-coverage.yml +++ /dev/null @@ -1,11 +0,0 @@ -steps: - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - reportDirectory: $(System.DefaultWorkingDirectory)/coverage - summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml - displayName: "Publish coverage" - condition: and(variables.ENABLE_CODE_COVERAGE, succeededOrFailed()) - - script: yarn codecov -f coverage/cobertura-coverage.xml - displayName: "Publish coverage to Codecov" - condition: and(variables.ENABLE_CODE_COVERAGE, succeededOrFailed()) diff --git a/.azure-pipelines/steps/publish-test-results.yml b/.azure-pipelines/steps/publish-test-results.yml deleted file mode 100644 index 77f371d53ef0..000000000000 --- a/.azure-pipelines/steps/publish-test-results.yml +++ /dev/null @@ -1,7 +0,0 @@ -steps: - - task: PublishTestResults@2 - inputs: - testResultsFormat: JUnit - testResultsFiles: $(System.DefaultWorkingDirectory)/junit.xml - displayName: "Publish test results" - condition: succeededOrFailed() diff --git a/.azure-pipelines/steps/upload-dist.yml b/.azure-pipelines/steps/upload-dist.yml deleted file mode 100644 index 0cde72aa0235..000000000000 --- a/.azure-pipelines/steps/upload-dist.yml +++ /dev/null @@ -1,6 +0,0 @@ -steps: - - task: PublishPipelineArtifact@0 - inputs: - artifactName: "dist" - targetPath: dist - displayName: "Upload dist" diff --git a/.editorconfig b/.editorconfig index cda3b3db3ee5..49a6d74cdd74 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ insert_final_newline = true [cspell.json] indent_size = 4 + +[website/blog/*.md] +trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE/formatting.md b/.github/ISSUE_TEMPLATE/formatting.md index 6d8cdafc710d..885dec4ab1b6 100644 --- a/.github/ISSUE_TEMPLATE/formatting.md +++ b/.github/ISSUE_TEMPLATE/formatting.md @@ -26,7 +26,7 @@ Tip! Don't write this stuff manually. --> -**Prettier 2.0.1** +**Prettier 2.0.2** [Playground link](https://prettier.io/playground/#.....) ```sh diff --git a/.github/ISSUE_TEMPLATE/integration.md b/.github/ISSUE_TEMPLATE/integration.md index f0fca7187b2c..e5d498ce5b79 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.0.1 +- Prettier Version: 2.0.2 - Running Prettier via: - Runtime: - Operating System: diff --git a/.github/workflows/dev-test.yml b/.github/workflows/dev-test.yml index aab8738039f4..cbf1672f1cee 100644 --- a/.github/workflows/dev-test.yml +++ b/.github/workflows/dev-test.yml @@ -1,9 +1,9 @@ -name: Dev_Test +name: Dev -on: [pull_request] +on: [push, pull_request] jobs: - dev_test: + test: strategy: fail-fast: false matrix: @@ -15,8 +15,14 @@ jobs: - "13" - "12" - "10" - - name: Dev test on node ${{ matrix.node }} and ${{ matrix.os }} + include: + # only enable coverage on the fastest job + - os: "ubuntu-latest" + node: "12" + ENABLE_CODE_COVERAGE: true + env: + ENABLE_CODE_COVERAGE: ${{ matrix.ENABLE_CODE_COVERAGE }} + name: Node.js ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -27,10 +33,17 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v1 with: - node-version: ${{ matrix.NODE }} + node-version: ${{ matrix.node }} - name: Install Dependencies run: yarn install --frozen-lockfile - - name: Run Test - run: yarn test + - name: Run Tests + run: yarn test --maxWorkers=4 + + - name: Upload Coverage + uses: codecov/codecov-action@v1 + if: matrix.ENABLE_CODE_COVERAGE + with: + file: ./coverage/lcov.info + fail_ci_if_error: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bcb60fdc6a71..cc29015377f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,6 @@ name: Lint -on: [pull_request] +on: [push, pull_request] jobs: lint: @@ -20,20 +20,23 @@ jobs: - name: Install Dependencies run: yarn install --frozen-lockfile - - name: Check dependencies + - name: Check Dependencies run: yarn lint:deps - - name: Check JSDoc types + - name: Check JSDoc Types run: yarn lint:typecheck - - name: Lint code + - name: Lint ESLint run: yarn lint:eslint - - name: Lint prettier + - name: Lint Prettier run: yarn lint:prettier - name: Spellcheck run: yarn lint:spellcheck - - name: Check file changes + - name: Lint Changelog + run: yarn lint:changelog + + - name: Check Lock File Changes run: yarn && echo "Listing changed files:" && git diff --name-only --exit-code && echo "No files changed during lint." diff --git a/.github/workflows/prod-test.yml b/.github/workflows/prod-test.yml index ac2c3bc5f4dc..8e52592168c7 100644 --- a/.github/workflows/prod-test.yml +++ b/.github/workflows/prod-test.yml @@ -1,6 +1,6 @@ -name: Prod_Test +name: Prod -on: [pull_request] +on: [push, pull_request] jobs: build: @@ -29,7 +29,34 @@ jobs: name: dist path: dist - prod_test: + lint: + name: Lint + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: "12" + + - name: Install Dependencies + run: yarn install --frozen-lockfile + + - name: Download Artifact + uses: actions/download-artifact@v1 + with: + name: dist + path: dist + + - name: Lint Code + run: yarn lint:dist + + test: strategy: fail-fast: false matrix: @@ -41,8 +68,47 @@ jobs: - "13" - "12" - "10" + name: Node.js ${{ matrix.node }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + needs: [build] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + + - name: Install Dependencies + run: yarn install --frozen-lockfile + + - name: Download Artifact + uses: actions/download-artifact@v1 + with: + name: dist + path: dist + + - name: Run Tests + run: yarn test:dist - name: Prod test on node ${{ matrix.node }} and ${{ matrix.os }} + standalone: + strategy: + fail-fast: false + matrix: + os: + - "ubuntu-latest" + - "macos-latest" + - "windows-latest" + node: + - "13" + - "12" + - "10" + env: + STANDALONE: true + name: Node.js ${{ matrix.node }} on ${{ matrix.os }} (standalone) runs-on: ${{ matrix.os }} needs: [build] steps: @@ -65,5 +131,5 @@ jobs: name: dist path: dist - - name: Run Test + - name: Run Tests run: yarn test:dist diff --git a/CHANGELOG.md b/CHANGELOG.md index c09161d38b2f..8951d877a08e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,104 @@ +# 2.0.2 + +[diff](https://github.com/prettier/prettier/compare/2.0.1...2.0.2) + +### 2.0 regressions + +#### JavaScript: Fix formatting of pseudo-elements and pseudo-classes in styled-components template literals ([#7842](https://github.com/prettier/prettier/pull/7842) by [@thorn0](https://github.com/thorn0)) + + +```jsx +// Input +const Foo = styled.div` + ${media.smallDown}::before {} +`; + +// Prettier 2.0.0 +const Foo = styled.div` + ${media.smallDown}: : before{ + } +`; + +// Prettier 2.0.2 +const Foo = styled.div` + ${media.smallDown}::before { + } +`; +``` + +#### TypeScript: Avoid trailing commas on index signatures with only one parameter ([#7836](https://github.com/prettier/prettier/pull/7836) by [@bakkot](https://github.com/bakkot)) + +TypeScript index signatures technically allow multiple parameters and trailing commas, but it's an error to have multiple parameters there, and Babel's TypeScript parser does not accept them. So Prettier now avoids putting a trailing comma there when you have only one parameter. + + +```ts +// Input +export type A = { + a?: { + [ + x: string + ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; + } | null; +}; + +// Prettier 2.0.0 +export type A = { + a?: { + [ + x: string, + ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; + } | null; +}; + +// Prettier 2.0.2 +export type A = { + a?: { + [ + x: string + ]: typeof SomeLongLongLongTypeName[keyof typeof SomeLongLongLongTypeName]; + } | null; +}; +``` + +#### Revert "markdown: fix redundant leading spaces in markdown list" ([#7847](https://github.com/prettier/prettier/pull/7847)) + +See [#7846](https://github.com/prettier/prettier/issues/7846) + +### Other changes + +#### TypeScript: Fix `prettier-ignore` in union types ([#7798](https://github.com/prettier/prettier/pull/7798) by [@thorn0](https://github.com/thorn0)) + + +```ts +// Input +export type a = + // foo + | foo1&foo2 + // prettier-ignore + | bar1&bar2 + // baz + | baz1&baz2; + +// Prettier 2.0.0 +export type a = + // foo + | foo1&foo2 + // prettier-ignore + // prettier-ignore + | (bar1 & bar2) + // baz + | (baz1 & baz2); + +// Prettier 2.0.2 +export type a = + // foo + | (foo1 & foo2) + // prettier-ignore + | bar1&bar2 + // baz + | (baz1 & baz2); +``` + # 2.0.1 [diff](https://github.com/prettier/prettier/compare/2.0.0...2.0.1) diff --git a/README.md b/README.md index a6a129de2373..07dc84ff477e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -## Prettier 2.0 - -This is the branch containing code for Prettier’s 2.0 release. See [the `master` branch](https://github.com/prettier/prettier) for the 1.x code/docs. - ---- - ![Prettier Banner](https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-banner-light.png)
- - + + + + + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 93294fb1ebea..000000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,92 +0,0 @@ -trigger: - - master - - next - - release-* - -variables: - ENABLE_CODE_COVERAGE: "" # only enable coverage on the fastest job - -jobs: - - job: Dev_Lint - displayName: Dev Lint on Linux Node v12 - pool: - vmImage: "Ubuntu 16.04" - variables: - node_version: 12 - steps: - - template: .azure-pipelines/jobs/dev-lint.yml - - - job: Dev_Test_Windows - displayName: Dev Test on Windows Node v12 - pool: - vmImage: vs2017-win2016 - variables: - node_version: 12 - TEST_CRLF: true - steps: - - template: .azure-pipelines/jobs/dev-test.yml - - - job: Dev_Test_macOS - displayName: Dev Test on macOS Node v12 - pool: - vmImage: macos-10.14 - variables: - node_version: 12 - ENABLE_CODE_COVERAGE: true - steps: - - template: .azure-pipelines/jobs/dev-test.yml - - - job: Dev_Test_Linux - displayName: Dev Test on Linux Node v12 - pool: - vmImage: "Ubuntu 16.04" - variables: - node_version: 12 - steps: - - template: .azure-pipelines/jobs/dev-test.yml - - - job: Prod_Build - displayName: Prod Build on Linux Node v12 - pool: - vmImage: "Ubuntu 16.04" - variables: - node_version: 12 - steps: - - template: .azure-pipelines/jobs/prod-build.yml - - - job: Prod_Pack - dependsOn: Prod_Build - displayName: Prod Pack on Linux Node v12 - pool: - vmImage: "Ubuntu 16.04" - variables: - node_version: 12 - steps: - - template: .azure-pipelines/jobs/prod-pack.yml - - - job: Prod_Lint - dependsOn: Prod_Build - displayName: Prod Lint on Linux Node v12 - pool: - vmImage: "Ubuntu 16.04" - variables: - node_version: 12 - steps: - - template: .azure-pipelines/jobs/prod-lint.yml - - - job: Prod_Test - dependsOn: Prod_Build - displayName: Prod Test on macOS - pool: - vmImage: macos-10.14 - strategy: - matrix: - Node_v10: - node_version: 10 - Node_v12: - node_version: 12 - Node_v12_standalone: - node_version: 12 - TEST_STANDALONE: true - steps: - - template: .azure-pipelines/jobs/prod-test.yml diff --git a/cspell.json b/cspell.json index 17b88e5135b7..eabba62c51e6 100644 --- a/cspell.json +++ b/cspell.json @@ -2,8 +2,10 @@ "version": "0.1", "words": [ "ACMR", + "algolia", "Amjad", "Andrey", + "animationend", "apos", "aquibm", "arduner", @@ -96,6 +98,7 @@ "ENOENT", "ericsakmar", "Ericsburgh", + "errored", "Esben", "esbenp", "eslint's", @@ -149,6 +152,7 @@ "Horky", "hotpink", "hsla", + "htmlblock", "htmlhint", "hugomrdias", "hwba", @@ -242,6 +246,8 @@ "noncharacters", "nonenumerable", "nonspacing", + "noopener", + "noreferrer", "normalise", "normalised", "nrvtbfux", @@ -249,6 +255,7 @@ "nullish", "Nuno", "nvim", + "octicon", "Okazaki", "Okonetchnikov", "oneth", @@ -256,6 +263,7 @@ "onwarn", "Oopsy", "overparenthesization", + "overscroll", "packagejson", "Panasenko", "Pangsakulyanont", @@ -270,6 +278,7 @@ "pomber", "postprocess", "postprocessor", + "precache", "precommit", "prefetch", "preorder", @@ -299,8 +308,8 @@ "refmt", "regexes", "reimplement", - "repo's", "repo", + "repo's", "repos", "reselect", "rhengles", @@ -309,11 +318,13 @@ "rreverser", "ruleset", "rulesets", + "sandhose", "Sapegin", "sbdchd", "scandir", "schemastore", "serializer", + "serviceworker", "setlocal", "shellscape", "shellsession", @@ -349,8 +360,9 @@ "templating", "tempy", "tgriesser", - "tidelift’s", "tidelift", + "tidelift’s", + "tldr", "Tomasek", "Tradeshift", "Transloadit", @@ -359,6 +371,7 @@ "TSJS", "Typeahead", "typecasted", + "typecheck", "typeof", "udbff", "udfff", @@ -368,8 +381,10 @@ "unaries", "uncheck", "uncook", + "unignore", "uniqby", "unist", + "unmount", "unparenthesised", "unparenthesized", "unparseable", @@ -384,13 +399,13 @@ "vanguarding", "versary", "vimrc", - "vjeux's", "vjeux", + "vjeux's", "vnopts", "Voyer", "Vue's", - "Wadler's", "Wadler", + "Wadler's", "warrenseine", "webstorm", "whitespaces", @@ -410,5 +425,12 @@ "\\[`\\w+`\\]", "ve{2,}r{2,}y", "ve+r+y+long\\w*" + ], + "ignorePaths": [ + "**/node_modules/**", + "website/build/**", + "website/playground/codeSamples.js", + "website/static/lib/**", + "website/static/playground.js" ] -} +} \ No newline at end of file diff --git a/docs/browser.md b/docs/browser.md index fd6ede1c5972..db8b99763964 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -16,8 +16,8 @@ See [Usage](#usage) below for examples. ### Global ```html - - + + - + +