├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ ├── Feature_request.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md ├── auto_assign.yml ├── dependabot.yml └── workflows │ ├── dependabot.yaml │ ├── dependency-review.yml │ ├── lock.yml │ ├── main.yml │ ├── more-info.yaml │ ├── on-open.yml │ └── stale.yml ├── .gitignore ├── .husky ├── .gitignore └── pre-commit ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LICENSE ├── README.md ├── THIRDPARTY.md ├── icon.png ├── package-json-schema.json ├── package.json ├── package.nls.json ├── package.nls.zh-cn.json ├── package.nls.zh-tw.json ├── scripts ├── clean.js └── version.js ├── src ├── BrowserModuleResolver.ts ├── Files.ts ├── LoggingService.ts ├── ModuleLoader.ts ├── ModuleResolver.ts ├── PrettierEditProvider.ts ├── PrettierEditService.ts ├── PrettierInstance.ts ├── PrettierMainThreadInstance.ts ├── PrettierWorkerInstance.ts ├── StatusBar.ts ├── TemplateService.ts ├── commands.ts ├── extension.ts ├── languageFilters.ts ├── message.ts ├── test │ ├── runTests.ts │ └── suite │ │ ├── ModuleResolver.test.ts │ │ ├── config.test.ts │ │ ├── format.test.ts │ │ ├── formatRanges.test.ts │ │ ├── ignore.test.ts │ │ ├── index.ts │ │ ├── module.test.ts │ │ ├── plugin-tailwindcss.test.ts │ │ ├── plugins.test.ts │ │ ├── v3-plugin-override.test.ts │ │ ├── v3-plugins.test.ts │ │ └── v3.test.ts ├── types.d.ts ├── util.ts └── worker │ └── prettier-instance-worker.js ├── test-fixtures ├── .do-not-use-prettier-vscode-root ├── config │ ├── customextension │ │ ├── .prettierrc │ │ ├── test.abc │ │ └── test.result.abc │ ├── editorconfig │ │ ├── .editorconfig │ │ ├── test.js │ │ └── test.result.js │ ├── hbsfile │ │ ├── prettier.config.js │ │ ├── test.hbs │ │ └── test.result.hbs │ ├── jsconfigfile │ │ ├── prettier.config.js │ │ ├── test.js │ │ └── test.result.js │ ├── jsfile │ │ ├── .prettierrc.js │ │ ├── test.js │ │ └── test.result.js │ ├── rcfile │ │ ├── .prettierrc │ │ ├── test.js │ │ └── test.result.js │ ├── vscodeconfig-language-overridable │ │ ├── test.result.ts │ │ └── test.ts │ └── vscodeconfig │ │ ├── test.js │ │ └── test.result.js ├── explicit-dep │ ├── implicit-dep │ │ ├── index.js │ │ ├── index.result.js │ │ ├── package.json │ │ └── yarn.lock │ ├── index.js │ ├── index.result.js │ ├── package.json │ └── yarn.lock ├── module-dep │ ├── package.json │ └── yarn.lock ├── module-plugin-dep │ ├── .do-not-use-prettier-vscode-root │ ├── package.json │ └── yarn.lock ├── module-plugin │ ├── .do-not-use-prettier-vscode-root │ ├── .prettierrc │ ├── index.js │ ├── index.result.js │ ├── package.json │ └── yarn.lock ├── module │ ├── .do-not-use-prettier-vscode-root │ ├── .prettierrc │ ├── index.js │ ├── index.result.js │ ├── package.json │ └── yarn.lock ├── no-dep │ ├── .do-not-use-prettier-vscode-root │ ├── .prettierrc │ ├── index.js │ ├── index.result.js │ └── package.json ├── outdated │ ├── package.json │ ├── ugly.js │ └── yarn.lock ├── plugin-tailwindcss │ ├── index.js │ ├── index.result.js │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ └── tailwind.config.js ├── plugins-pnpm │ ├── .npmrc │ ├── .prettierrc │ ├── index.js │ ├── index.php │ ├── index.result.js │ ├── index.result.php │ ├── package.json │ ├── pnpm-lock.yaml │ └── unused-module.js ├── plugins │ ├── .prettierrc │ ├── index.php │ ├── index.result.php │ ├── package.json │ └── yarn.lock ├── project │ ├── .prettierignore │ ├── .prettierrc │ ├── fileToIgnore.js │ ├── formatTest │ │ ├── htmlWithLiterals.html │ │ ├── lwc.html │ │ ├── package.json │ │ ├── ugly.css │ │ ├── ugly.graphql │ │ ├── ugly.hbs │ │ ├── ugly.html │ │ ├── ugly.js │ │ ├── ugly.json │ │ ├── ugly.jsonc │ │ ├── ugly.scss │ │ ├── ugly.ts │ │ ├── ugly.tsx │ │ └── ugly.vue │ ├── ignoreMe │ │ └── subdir │ │ │ └── index.js │ └── ignoreMe2 │ │ └── index.js ├── specific-version │ ├── package.json │ ├── ugly.js │ └── yarn.lock ├── test.code-workspace ├── v3-plugin-override │ ├── .prettierrc.mjs │ ├── index.js │ ├── index.result.js │ ├── package.json │ ├── prettier-plugin-override │ │ ├── index.js │ │ └── package.json │ └── yarn.lock ├── v3-plugins │ ├── .prettierrc │ ├── index.result.xml │ ├── index.xml │ ├── package-lock.json │ └── package.json ├── v3 │ ├── .prettierrc.mjs │ ├── index.result.ts │ ├── index.ts │ ├── package.json │ └── yarn.lock └── workspace │ └── .vscode │ └── settings.json ├── tsconfig.json ├── webpack.config.js └── yarn.lock /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/typescript-node/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster 4 | ARG VARIANT="18-bullseye" 5 | FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} 6 | 7 | # [Optional] Uncomment this section to install additional OS packages. 8 | RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 9 | && apt-get -y install --no-install-recommends php 10 | 11 | # [Optional] Uncomment if you want to install an additional version of node using nvm 12 | # ARG EXTRA_NODE_VERSION=10 13 | # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" 14 | 15 | # [Optional] Uncomment if you want to install more global node packages 16 | # RUN su node -c "npm install -g " 17 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/typescript-node 3 | { 4 | "name": "Node.js & TypeScript", 5 | "build": { 6 | "dockerfile": "Dockerfile", 7 | // Update 'VARIANT' to pick a Node version: 16, 14, 12. 8 | // Append -bullseye or -buster to pin to an OS version. 9 | // Use -bullseye variants on local on arm64/Apple Silicon. 10 | "args": { 11 | "VARIANT": "18-bullseye" 12 | } 13 | }, 14 | 15 | // Set *default* container specific settings.json values on container create. 16 | "settings": {}, 17 | 18 | // Add the IDs of extensions you want installed when the container is created. 19 | "extensions": [ 20 | "dbaeumer.vscode-eslint", 21 | "esbenp.prettier-vscode", 22 | "streetsidesoftware.code-spell-checker" 23 | ], 24 | 25 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 26 | // "forwardPorts": [], 27 | 28 | // Use 'postCreateCommand' to run commands after the container is created. 29 | "postCreateCommand": "yarn install", 30 | 31 | // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 32 | "remoteUser": "node" 33 | } 34 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /src/worker/*.js 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /**@type {import('eslint').Linter.Config} */ 2 | // eslint-disable-next-line no-undef 3 | module.exports = { 4 | root: true, 5 | parser: "@typescript-eslint/parser", 6 | plugins: ["@typescript-eslint"], 7 | extends: [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "prettier", 11 | ], 12 | rules: { 13 | "no-console": "error", 14 | "@typescript-eslint/explicit-module-boundary-types": 0, 15 | "@typescript-eslint/no-non-null-assertion": 0, 16 | "@typescript-eslint/no-floating-promises": "error", 17 | }, 18 | ignorePatterns: ["test-fixtures/**"], 19 | parserOptions: { 20 | project: "./tsconfig.json", 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 22 | 23 | ### Summary 24 | 25 | _Short summary of what is going on or to provide context_. 26 | 27 | ### Github Repository to Reproduce Issue 28 | 29 | Link to a Github repo that can be used to reproduce the issue. 30 | 31 | ### Steps To Reproduce: 32 | 33 | 1. This is step 1. 34 | 1. This is step 2. All steps should start with '1.' 35 | 36 | ### Expected result 37 | 38 | _Describe what should have happened_. 39 | 40 | ### Actual result 41 | 42 | _Describe what actually happened instead_. 43 | 44 | ### Additional information 45 | 46 | _Feel free to attach a screenshot_. 47 | 48 | **VS Code Version**: 49 | 50 | 51 | 52 | **Prettier Extension Version**: 53 | 54 | **OS and version**: 55 | 56 | ## Prettier Log Output 57 | 58 | 59 | 60 | 61 | ``` 62 | LOG GOES HERE. DO NOT USE A SCREENSHOT, COPY AND PASTE THE TEXT 63 | ``` 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | **Is your feature request related to a problem? Please describe.** 7 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 8 | 9 | **Describe the solution you'd like** 10 | A clear and concise description of what you want to happen. 11 | 12 | **Describe alternatives you've considered** 13 | A clear and concise description of any alternative solutions or features you've considered. 14 | 15 | **Additional context** 16 | Add any other context or screenshots about the feature request here. 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Stackoverflow 4 | url: https://stackoverflow.com/questions/tagged/prettier 5 | about: For support questions, please use Stackoverflow. 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | - [ ] Run tests 2 | - [ ] Update the [`CHANGELOG.md`][1] with a summary of your changes 3 | 4 | [1]: https://github.com/prettier/prettier-vscode/blob/main/CHANGELOG.md 5 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 4 | -------------------------------------------------------------------------------- /.github/auto_assign.yml: -------------------------------------------------------------------------------- 1 | # Set to true to add reviewers to pull requests 2 | addReviewers: true 3 | 4 | # Set to true to add assignees to pull requests 5 | addAssignees: true 6 | 7 | # A list of reviewers to be added to pull requests (GitHub user name) 8 | reviewers: 9 | - ntotten 10 | 11 | # A number of reviewers added to the pull request 12 | # Set 0 to add all the reviewers (default: 0) 13 | numberOfReviewers: 0 14 | 15 | # A list of assignees, overrides reviewers if set 16 | # assignees: 17 | # - assigneeA 18 | 19 | # A number of assignees to add to the pull request 20 | # Set to 0 to add all of the assignees. 21 | # Uses numberOfReviewers if unset. 22 | # numberOfAssignees: 2 23 | 24 | # A list of keywords to be skipped the process that add reviewers if pull requests include it 25 | # skipKeywords: 26 | # - wip 27 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | 9 | # Maintain dependencies for GitHub Actions 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | -------------------------------------------------------------------------------- /.github/workflows/dependabot.yaml: -------------------------------------------------------------------------------- 1 | name: Dependabot auto-approve 2 | on: pull_request 3 | 4 | permissions: 5 | pull-requests: write 6 | 7 | jobs: 8 | dependabot: 9 | runs-on: ubuntu-latest 10 | if: ${{ github.actor == 'dependabot[bot]' }} 11 | steps: 12 | - name: Dependabot metadata 13 | id: metadata 14 | uses: dependabot/fetch-metadata@v2.2.0 15 | with: 16 | github-token: "${{ secrets.GITHUB_TOKEN }}" 17 | - name: Approve a PR 18 | run: gh pr review --approve "$PR_URL" 19 | env: 20 | PR_URL: ${{github.event.pull_request.html_url}} 21 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 22 | -------------------------------------------------------------------------------- /.github/workflows/dependency-review.yml: -------------------------------------------------------------------------------- 1 | # Dependency Review Action 2 | # 3 | # This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. 4 | # 5 | # Source repository: https://github.com/actions/dependency-review-action 6 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement 7 | name: 'Dependency Review' 8 | on: [pull_request] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | dependency-review: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: 'Checkout Repository' 18 | uses: actions/checkout@v4 19 | - name: 'Dependency Review' 20 | uses: actions/dependency-review-action@v4 21 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: "Lock threads" 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: dessant/lock-threads@v5 12 | with: 13 | github-token: ${{ secrets.GITHUB_TOKEN }} 14 | issue-inactive-days: "90" 15 | process-only: "issues" 16 | add-issue-labels: "locked" 17 | issue-comment: > 18 | This issue has been automatically locked since there 19 | has not been any recent activity after it was closed. 20 | Please open a new issue for related bugs. 21 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: "Main" 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | os: [windows-latest, ubuntu-latest, macos-latest] 11 | name: Test on ${{ matrix.os }} 12 | steps: 13 | - uses: pnpm/action-setup@v4 14 | with: 15 | version: 7 16 | run_install: false 17 | - uses: actions/checkout@v4 18 | - uses: actions/setup-node@v4 19 | with: 20 | node-version-file: ".nvmrc" 21 | cache: "yarn" 22 | 23 | - run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & echo "Started xvfb" 24 | shell: bash 25 | if: ${{ success() && matrix.os == 'ubuntu-latest' }} 26 | 27 | - run: yarn install 28 | - run: yarn test 29 | env: 30 | DISPLAY: ":99.0" 31 | package: 32 | runs-on: ubuntu-latest 33 | needs: test 34 | name: Package 35 | steps: 36 | - uses: actions/checkout@v4 37 | - uses: actions/setup-node@v4 38 | with: 39 | node-version-file: ".nvmrc" 40 | cache: "yarn" 41 | - run: yarn install 42 | - run: npm install -g vsce 43 | - run: vsce package 44 | - run: echo "VSIX_PATH=$(find . -maxdepth 1 -type f -iname "*.vsix" | head -1)" >> $GITHUB_ENV 45 | - run: echo "VSIX_NAME=$(basename $(find . -maxdepth 1 -type f -iname "*.vsix" | head -1))" >> $GITHUB_ENV 46 | - uses: actions/upload-artifact@v4 47 | with: 48 | path: ${{ env.VSIX_PATH }} 49 | name: ${{ env.VSIX_NAME }} 50 | release: 51 | runs-on: ubuntu-latest 52 | needs: package 53 | if: startsWith(github.ref, 'refs/tags/v') 54 | name: Release 55 | steps: 56 | - uses: actions/checkout@v4 57 | - uses: actions/setup-node@v4 58 | with: 59 | node-version-file: ".nvmrc" 60 | cache: "yarn" 61 | - run: yarn install 62 | - run: npm install -g vsce 63 | - run: vsce package 64 | - run: echo "VSIX_PATH=$(find . -maxdepth 1 -type f -iname "*.vsix" | head -1)" >> $GITHUB_ENV 65 | - run: echo "VSIX_NAME=$(basename $(find . -maxdepth 1 -type f -iname "*.vsix" | head -1))" >> $GITHUB_ENV 66 | - uses: actions/create-release@v1 67 | id: create_release 68 | env: 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 70 | with: 71 | tag_name: ${{ github.ref }} 72 | release_name: ${{ github.ref }} 73 | body: See [CHANGE LOG](https://github.com/prettier/prettier-vscode/blob/main/CHANGELOG.md) for details. 74 | draft: false 75 | prerelease: false 76 | - uses: actions/upload-release-asset@v1 77 | env: 78 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 79 | with: 80 | upload_url: ${{ steps.create_release.outputs.upload_url }} 81 | asset_path: ${{ env.VSIX_PATH }} 82 | asset_name: ${{ env.VSIX_NAME }} 83 | asset_content_type: application/zip 84 | - run: vsce publish -p ${{ secrets.MARKETPLACE_TOKEN }} 85 | -------------------------------------------------------------------------------- /.github/workflows/more-info.yaml: -------------------------------------------------------------------------------- 1 | name: Comment on More Info 2 | on: 3 | issues: 4 | types: 5 | - labeled 6 | jobs: 7 | add-comment: 8 | if: github.event.label.name == 'need-more-info' 9 | runs-on: ubuntu-latest 10 | permissions: 11 | issues: write 12 | steps: 13 | - name: Add comment 14 | uses: peter-evans/create-or-update-comment@v4 15 | with: 16 | issue-number: ${{ github.event.issue.number }} 17 | body: | 18 | This bug is missing information needed to diagnose the problem. Please see our [guide on how to open a good issue](https://github.com/prettier/prettier-vscode/wiki/Writing-a-Good-Issue) and provide the missing information. Most configuration-related issues can only be resolved by [providing a full repro](https://github.com/prettier/prettier-vscode/wiki/Writing-a-Good-Issue#5-provide-a-sample-github-repo). **If you don't provide a sample to reproduce your issue, your bug will most likely be closed.** 19 | -------------------------------------------------------------------------------- /.github/workflows/on-open.yml: -------------------------------------------------------------------------------- 1 | name: On Open 2 | on: 3 | issues: 4 | types: [opened] 5 | 6 | jobs: 7 | main: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout Actions 11 | uses: actions/checkout@v4 12 | with: 13 | repository: "microsoft/vscode-github-triage-actions" 14 | ref: stable 15 | path: ./actions 16 | - name: Install Actions 17 | run: npm install --production --prefix ./actions 18 | 19 | - name: Run Clipboard Labeler 20 | uses: ./actions/regex-labeler 21 | with: 22 | label: "invalid" 23 | mustNotMatch: "^We have written the needed data into your clipboard because it was too large to send\\. Please paste\\.$" 24 | comment: "It looks like you're using the VS Code Issue Reporter but did not paste the text generated into the created issue. We've closed this issue, please open a new one containing the text we placed in your clipboard.\n\nHappy Coding!" 25 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: "Close stale issues and PRs" 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write # only for delete-branch option 12 | issues: write 13 | pull-requests: write 14 | 15 | steps: 16 | - uses: actions/stale@v9 17 | with: 18 | stale-issue-label: needs-more-info 19 | any-of-labels: need-more-info 20 | exempt-issue-labels: enhancement, help-wanted 21 | days-before-stale: -1 22 | days-before-close: 7 23 | - uses: actions/stale@v9 24 | with: 25 | exempt-issue-labels: need-more-info, enhancement, help-wanted 26 | stale-issue-message: "This issue has been labeled as stale due to inactivity. Reply to keep this issue open." 27 | stale-pr-message: "This pull request has been labeled as stale due to inactivity. Reply to keep this pull request open." 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test 5 | .vscode-test-web 6 | *.vsix 7 | .DS_STORE 8 | *.log 9 | test-results.xml -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | yarn lint-staged -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .vscode-test/ 2 | out/ 3 | dist/ 4 | test-fixtures/ 5 | node_modules/ -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "esbenp.prettier-vscode", 5 | "streetsidesoftware.code-spell-checker" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--disable-extensions", 15 | "--extensionDevelopmentPath=${workspaceFolder}" 16 | ], 17 | "outFiles": ["${workspaceFolder}/dist/**/*.js"], 18 | "preLaunchTask": "npm: webpack" 19 | }, 20 | { 21 | "name": "Run Extension (With Other Extensions)", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "runtimeExecutable": "${execPath}", 25 | "args": ["--extensionDevelopmentPath=${workspaceFolder}"], 26 | "outFiles": ["${workspaceFolder}/dist/**/*.js"], 27 | "preLaunchTask": "npm: webpack" 28 | }, 29 | { 30 | "name": "Extension Tests", 31 | "type": "extensionHost", 32 | "request": "launch", 33 | "runtimeExecutable": "${execPath}", 34 | "args": [ 35 | "${workspaceFolder}/test-fixtures/test.code-workspace", 36 | "--disable-extensions", 37 | "--extensionDevelopmentPath=${workspaceFolder}", 38 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 39 | ], 40 | "outFiles": ["${workspaceFolder}/out/test/**/*.js"], 41 | "preLaunchTask": "npm: test-compile" 42 | }, 43 | { 44 | "name": "Run Web Extension", 45 | "type": "pwa-extensionHost", 46 | "debugWebWorkerHost": true, 47 | "request": "launch", 48 | "args": [ 49 | "--extensionDevelopmentPath=${workspaceFolder}", 50 | "--extensionDevelopmentKind=web" 51 | ], 52 | "outFiles": ["${workspaceFolder}/dist/**/*.js"], 53 | "preLaunchTask": "npm: webpack" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.codeActionsOnSave": { 4 | "source.fixAll.eslint": "explicit" 5 | }, 6 | "editor.formatOnSave": true, 7 | "editor.defaultFormatter": "esbenp.prettier-vscode", 8 | "editor.formatOnType": false, 9 | "files.eol": "\n", 10 | "cSpell.words": [ 11 | "Parens", 12 | "Whitespaces", 13 | "codebases", 14 | "commonmark", 15 | "docblock", 16 | "editorconfig", 17 | "esbenp", 18 | "gitignore", 19 | "pnpm", 20 | "prettier's", 21 | "prettiercode", 22 | "prettierignore", 23 | "prettierrc", 24 | "promisify", 25 | "stylelint", 26 | "userdata", 27 | "vsce" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "compile", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "silent" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .github/ 2 | .husky/ 3 | .vscode/ 4 | .vscode-test/ 5 | .vscode-test-web/ 6 | out/ 7 | scripts/ 8 | src/ 9 | test-fixtures/ 10 | .gitattributes 11 | .gitignore 12 | .nvmrc 13 | .prettierignore 14 | .prettierrc 15 | CODE_OF_CONDUCT.md 16 | CONTRIBUTING.md 17 | CONTRIBUTORS.md 18 | tsconfig.json 19 | webpack.config.js 20 | yarn.lock 21 | dist/*.map 22 | 23 | node_modules/ 24 | !node_modules/prettier/* 25 | node_modules/prettier/esm 26 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribute 2 | 3 | Feel free to open issues or PRs! 4 | 5 | ## Running extension 6 | 7 | - Open this repository inside VSCode 8 | - `yarn install` 9 | - Debug sidebar 10 | - `Run Extension` 11 | 12 | ## Running tests 13 | 14 | Tests open a VSCode instance and load `./testProject` as root workspace. 15 | 16 | - Open this repository inside VSCode 17 | - Debug sidebar 18 | - `Launch Tests` 19 | 20 | OR 21 | 22 | Without having an instance VSCode running (or it won't start) 23 | `yarn test` 24 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | - [Cole Kennedy](https://github.com/colek42) 2 | - [Cyril Junod](https://github.com/CiGit) 3 | - [David Burrows](https://github.com/dburrows) 4 | - [Jon Wolfe](https://github.com/JonathanWolfe) 5 | - [Laurence Rowe](https://github.com/lrowe) 6 | - [Robin Malfait](https://github.com/RobinMalfait) 7 | - [Oliver Joseph Ash](https://github.com/OliverJAsh) 8 | - [Nathan Totten](https://github.com/ntotten) 9 | - [Benas Svipas](https://github.com/svipas) 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Esben Petersen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prettier Formatter for Visual Studio Code 2 | 3 | [Prettier](https://prettier.io/) 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. 4 | 5 |

6 | 7 | JavaScript 8 | · TypeScript 9 | · Flow 10 | · JSX 11 | · JSON 12 | 13 |
14 | 15 | CSS 16 | · SCSS 17 | · Less 18 | 19 |
20 | 21 | HTML 22 | · Vue 23 | · Angular 24 | 25 | 26 | HANDLEBARS 27 | · Ember 28 | · Glimmer 29 | 30 |
31 | 32 | GraphQL 33 | · Markdown 34 | · YAML 35 | 36 |
37 | 38 | 39 | Your favorite language? 40 | 41 | 42 |

43 | 44 |

45 | 46 | Build Status 47 | 48 | VS Code Marketplace Downloads 49 | 50 | VS Code Marketplace Installs 51 | 52 | code style: prettier 53 | 54 | Follow Prettier on Twitter 55 |

56 | 57 | ## Installation 58 | 59 | Install through VS Code extensions. Search for `Prettier - Code formatter` 60 | 61 | [Visual Studio Code Market Place: Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) 62 | 63 | Can also be installed in VS Code: Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. 64 | 65 | ``` 66 | ext install esbenp.prettier-vscode 67 | ``` 68 | 69 | ### Default Formatter 70 | 71 | To ensure that this extension is used over other extensions you may have installed, be sure to set it as the default formatter in your VS Code settings. This setting can be set for all languages or by a specific language. 72 | 73 | ```json 74 | { 75 | "editor.defaultFormatter": "esbenp.prettier-vscode", 76 | "[javascript]": { 77 | "editor.defaultFormatter": "esbenp.prettier-vscode" 78 | } 79 | } 80 | ``` 81 | 82 | If you want to disable Prettier on a particular language you can either create a `.prettierignore` file or you can use VS Code's `editor.defaultFormatter` settings. 83 | 84 | The following will use Prettier for all languages except Javascript. 85 | 86 | ```json 87 | { 88 | "editor.defaultFormatter": "esbenp.prettier-vscode", 89 | "[javascript]": { 90 | "editor.defaultFormatter": "" 91 | } 92 | } 93 | ``` 94 | 95 | The following will use Prettier for only Javascript. 96 | 97 | ```json 98 | { 99 | "editor.defaultFormatter": "", 100 | "[javascript]": { 101 | "editor.defaultFormatter": "esbenp.prettier-vscode" 102 | } 103 | } 104 | ``` 105 | 106 | Additionally, you can disable format on save for specific languages if you don't want them to be automatically formatted. 107 | 108 | ```json 109 | { 110 | "[javascript]": { 111 | "editor.formatOnSave": false 112 | } 113 | } 114 | ``` 115 | 116 | ### Prettier Resolution 117 | 118 | This extension will use prettier from your project's local dependencies (recommended). When the `prettier.resolveGlobalModules` is set to `true` the extension can also attempt to resolve global modules. Should prettier not be installed locally with your project's dependencies or globally on the machine, the version of prettier that is bundled with the extension will be used. 119 | 120 | To install prettier in your project and pin its version [as recommended](https://prettier.io/docs/en/install.html), run: 121 | 122 | ``` 123 | npm install prettier -D --save-exact 124 | ``` 125 | 126 | > NOTE: You will be prompted to confirm that you want the extension to load a Prettier module. This is done to ensure that you are not loading a module or script that is not trusted. 127 | 128 | ### Prettier Version 3 129 | 130 | Prettier's preview version 3 is supported as of version 9.12.0. It is not included in the extension by default, but can be used by installing locally in your project. Version 10.0.0 of this extension will include prettier 3.0.0 after it is out of preview. To try version 3 now run the following in your project: 131 | 132 | ```base 133 | npm i prettier@3.0.0-alpha.6 -D 134 | ``` 135 | 136 | ### Plugins 137 | 138 | This extension supports [Prettier plugins](https://prettier.io/docs/en/plugins.html) when you are using a locally or globally resolved version of prettier. If you have Prettier and a plugin registered in your `package.json`, this extension will attempt to register the language and provide automatic code formatting for the built-in and plugin languages. 139 | 140 | ## Configuration 141 | 142 | There are multiple options for configuring Prettier with this extension. You can use [VS Code settings](#prettier-settings), [prettier configuration files](https://prettier.io/docs/en/configuration.html), or an `.editorconfig` file. The VS Code settings are meant to be used as a fallback and are generally intended only for use on non-project files. **It is recommended that you always include a prettier configuration file in your project specifying all settings for your project.** This will ensure that no matter how you run prettier - from this extension, from the CLI, or from another IDE with Prettier, the same settings will get applied. 143 | 144 | Using [Prettier Configuration files](https://prettier.io/docs/en/configuration.html) to set formatting options is the recommended approach. Options are searched recursively down from the file being formatted so if you want to apply prettier settings to your entire project simply set a configuration in the root. Settings can also be configured through VS Code - however, these settings will only apply while running the extension, not when running prettier through the command line. 145 | 146 | ### Configuring Default Options 147 | 148 | Some users may not wish to create a new Prettier config for every project or use the VS Code settings. In order to set a default configuration, set [`prettier.configPath`](https://github.com/prettier/prettier-vscode#prettierconfigpath). However, be careful, if this is set this value will always be used and local configuration files will be ignored. 149 | 150 | ### Visual Studio Code Settings 151 | 152 | You can use [VS Code settings](#prettier-settings) to configure prettier. Settings will be read from (listed by priority): 153 | 154 | 1. [Prettier configuration file](https://prettier.io/docs/en/configuration.html) 155 | 1. `.editorconfig` 156 | 1. Visual Studio Code Settings (Ignored if any other configuration is present) 157 | 158 | > NOTE: If any local configuration file is present (i.e. `.prettierrc`) the VS Code settings will **NOT** be used. 159 | 160 | ## Usage 161 | 162 | ### Using Command Palette (CMD/CTRL + Shift + P) 163 | 164 | ``` 165 | 1. CMD + Shift + P -> Format Document 166 | OR 167 | 1. Select the text you want to Prettify 168 | 2. CMD + Shift + P -> Format Selection 169 | ``` 170 | 171 | ### Keyboard Shortcuts 172 | 173 | Visual Studio Code provides [default keyboard shortcuts](https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference) for code formatting. You can learn about these for each platform in the [VS Code documentation](https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference). 174 | 175 | If you don't like the defaults, you can rebind `editor.action.formatDocument` and `editor.action.formatSelection` in the keyboard shortcuts menu of vscode. 176 | 177 | ### Format On Save 178 | 179 | Respects `editor.formatOnSave` setting. 180 | 181 | You can turn on format-on-save on a per-language basis by scoping the setting: 182 | 183 | ```json 184 | // Set the default 185 | "editor.formatOnSave": false, 186 | // Enable per-language 187 | "[javascript]": { 188 | "editor.formatOnSave": true 189 | } 190 | ``` 191 | 192 | ### Format Selection 193 | 194 | Format selection works on several languages depending on what Prettier itself supports. The following languages currently are supported: 195 | 196 | ``` 197 | javascript 198 | javascriptreact 199 | typescript 200 | typescriptreact 201 | json 202 | graphql 203 | handlebars 204 | ``` 205 | 206 | ### Format Document (Forced) 207 | 208 | If you would like to format a document that is configured to be ignored by Prettier either because it is in a `.prettierignore` file or part of a normally excluded location like `node_modules`, you can run the command **Format Document (Forced)** to force the document to be formatted. Forced mode will also ignore any config for `requirePragma` allowing you to format files without the pragma comment present. 209 | 210 | ## Linter Integration 211 | 212 | The recommended way of integrating with linters is to let Prettier do the formatting and configure the linter to not deal with formatting rules. You can find instructions on how to configure each linter on the Prettier docs site. You can then use each of the linting extensions as you normally would. For details refer to the [Prettier documentation](https://prettier.io/docs/en/integrating-with-linters.html). 213 | 214 | ## Workspace Trust 215 | 216 | This extension utilizes VS Code [Workspace Trust](https://code.visualstudio.com/docs/editor/workspace-trust) features. When this extension is run on an untrusted workspace, it will only use the built in version of prettier. No plugins, local, or global modules will be supported. Additionally, certain settings are also restricted - see each setting for details. 217 | 218 | ## Settings 219 | 220 | ### Prettier Settings 221 | 222 | All prettier options can be configured directly in this extension. These settings are used as a fallback when no configuration file is present in your project, see the [configuration](#configuration) section of this document for more details. For reference on the options see the [prettier documentation](https://prettier.io/docs/en/options.html). 223 | 224 | > The default values of these configurations are always to their Prettier 2.0 defaults. In order to use defaults from earlier versions of prettier you must set them manually using your VS Code settings or local project configurations. 225 | 226 | ``` 227 | prettier.arrowParens 228 | prettier.bracketSpacing 229 | prettier.endOfLine 230 | prettier.htmlWhitespaceSensitivity 231 | prettier.insertPragma 232 | prettier.singleAttributePerLine 233 | prettier.bracketSameLine 234 | prettier.jsxBracketSameLine 235 | prettier.jsxSingleQuote 236 | prettier.printWidth 237 | prettier.proseWrap 238 | prettier.quoteProps 239 | prettier.requirePragma 240 | prettier.semi 241 | prettier.singleQuote 242 | prettier.tabWidth 243 | prettier.trailingComma 244 | prettier.useTabs 245 | prettier.vueIndentScriptAndStyle 246 | prettier.embeddedLanguageFormatting 247 | prettier.experimentalTernaries 248 | ``` 249 | 250 | ### Extension Settings 251 | 252 | These settings are specific to VS Code and need to be set in the VS Code settings file. See the [documentation](https://code.visualstudio.com/docs/getstarted/settings) for how to do that. 253 | 254 | #### prettier.enable (default: `true`) 255 | 256 | Controls whether prettier is enabled or not. You must restart VS Code when you change this setting. 257 | 258 | #### prettier.requireConfig (default: `false`) 259 | 260 | Require a prettier configuration file to format files. Untitled files will still be formatted using the VS Code Prettier configuration even with this option set to `true`. 261 | 262 | #### prettier.ignorePath (default: `.prettierignore`) 263 | 264 | Supply the path to an ignore file such as `.gitignore` or `.prettierignore`. 265 | Files which match will not be formatted. Set to `null` to not read ignore files. 266 | 267 | **Note, if this is set, this value will always be used and local ignore files will be ignored.** 268 | 269 | **Disabled on untrusted workspaces** 270 | 271 | #### prettier.configPath 272 | 273 | Supply a custom path to the prettier configuration file. 274 | 275 | **Note, if this is set, this value will always be used and local configuration files will be ignored. A better option for global defaults is to put a `~/.prettierrc` file in your home directory.** 276 | 277 | **Disabled on untrusted workspaces** 278 | 279 | #### prettier.prettierPath 280 | 281 | Supply a custom path to the prettier module. This path should be to the module folder, not the bin/script path. i.e. `./node_modules/prettier`, not `./bin/prettier`. 282 | 283 | **Disabled on untrusted workspaces** 284 | 285 | #### prettier.resolveGlobalModules (default: `false`) 286 | 287 | When enabled, this extension will attempt to use global npm or yarn modules if local modules cannot be resolved. 288 | 289 | > NOTE: This setting can have a negative performance impact, particularly on Windows when you have attached network drives. Only enable this if you must use global modules. It is recommended that you always use local modules when possible. 290 | 291 | **Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run** 292 | 293 | **Disabled on untrusted workspaces** 294 | 295 | #### prettier.documentSelectors 296 | 297 | A list of [glob patterns](https://code.visualstudio.com/api/references/vscode-api#GlobPattern) to register Prettier formatter. Typically these will be in the format of `**/*.abc` to tell this extension to register itself as the formatter for all files with the `abc` extension. This feature can be useful when you have [overrides](https://prettier.io/docs/en/configuration.html#configuration-overrides) set in your config file to map custom extensions to a parser. 298 | 299 | It is likely you will need to also update your prettier config. For example, if I register the following document selector by itself, Prettier still won't know what to do with that file. I either need a Prettier extension that formats `.abc` file format or I need to configure Prettier. 300 | 301 | ```json 302 | { 303 | "prettier.documentSelectors": ["**/*.abc"] 304 | } 305 | ``` 306 | 307 | To tell Prettier how to format a file of type `.abc` I can set an override in the prettier config that makes this file type use the `babel` parser. 308 | 309 | ```json 310 | { 311 | "overrides": [ 312 | { 313 | "files": "*.abc", 314 | "options": { 315 | "parser": "babel" 316 | } 317 | } 318 | ] 319 | } 320 | ``` 321 | 322 | **Disabled on untrusted workspaces** 323 | 324 | #### prettier.useEditorConfig (default: `true`) 325 | 326 | Whether or not to take .editorconfig into account when parsing configuration. See the [prettier.resolveConfig docs](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath--options) for details. 327 | 328 | **Disabled on untrusted workspaces (always false)** 329 | 330 | #### prettier.withNodeModules (default: `false`) 331 | 332 | Whether or not to process files in the `node_modules` folder. 333 | 334 | **Disabled on untrusted workspaces** 335 | 336 | ## Error Messages 337 | 338 | **Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`** 339 | 340 | When a `package.json` is present in your project and it contains prettier, plugins, or linter libraries this extension will attempt to load these modules from your `node_module` folder. If you see this error, it most likely means you need to run `npm install` or `yarn install` to install the packages in your `package.json`. 341 | 342 | **Your project is configured to use an outdated version of prettier that cannot be used by this extension. Upgrade to the latest version of prettier.** 343 | 344 | You must upgrade to a newer version of prettier. 345 | 346 | **This workspace is not trusted. Using the bundled version of prettier.** 347 | 348 | You must trust this workspace to use plugins and local/global modules. See: [Workspace Trust](https://code.visualstudio.com/docs/editor/workspace-trust) 349 | -------------------------------------------------------------------------------- /THIRDPARTY.md: -------------------------------------------------------------------------------- 1 | vscode-go 2 | 3 | The MIT License (MIT) 4 | 5 | Original Work Copyright (c) 2015-2020 Microsoft Corporation 6 | Current Work and Modifications Copyright (c) 2020-present The Go Authors 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prettier/prettier-vscode/b8d9e42b8900c88e2210bc72615d9f925439b058/icon.png -------------------------------------------------------------------------------- /package-json-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "properties": { 4 | "prettier": { 5 | "description": "Prettier configuration", 6 | "$ref": "https://json.schemastore.org/prettierrc" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prettier-vscode", 3 | "displayName": "Prettier - Code formatter", 4 | "description": "Code formatter using prettier", 5 | "version": "11.0.0", 6 | "publisher": "esbenp", 7 | "author": "Prettier <@prettiercode>", 8 | "galleryBanner": { 9 | "color": "#ffe04b", 10 | "theme": "light" 11 | }, 12 | "sponsor": { 13 | "url": "https://opencollective.com/prettier" 14 | }, 15 | "homepage": "https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/prettier/prettier-vscode.git" 19 | }, 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/prettier/prettier-vscode/issues" 23 | }, 24 | "engines": { 25 | "vscode": "^1.80.0" 26 | }, 27 | "keywords": [ 28 | "multi-root ready", 29 | "prettier", 30 | "formatter", 31 | "javascript", 32 | "handlebars", 33 | "js", 34 | "jsx", 35 | "flow", 36 | "typescript", 37 | "ts", 38 | "json", 39 | "css", 40 | "less", 41 | "scss", 42 | "styled-components", 43 | "styled-jsx", 44 | "markdown", 45 | "md", 46 | "commonmark", 47 | "mdx", 48 | "php", 49 | "pug", 50 | "ruby", 51 | "swift", 52 | "html", 53 | "vue", 54 | "ember", 55 | "glimmer", 56 | "angular", 57 | "graphql", 58 | "yaml", 59 | "yml" 60 | ], 61 | "categories": [ 62 | "Formatters" 63 | ], 64 | "activationEvents": [ 65 | "onStartupFinished" 66 | ], 67 | "icon": "icon.png", 68 | "main": "./dist/extension", 69 | "browser": "./dist/web-extension", 70 | "scripts": { 71 | "clean": "node ./scripts/clean.js", 72 | "lint": "eslint -c .eslintrc.js --ext .ts .", 73 | "pretest": "yarn test-compile && cd test-fixtures/plugins && yarn install && cd ../plugins-pnpm && pnpm i && cd ../outdated && yarn install && cd ../module && yarn install && cd ../specific-version && yarn install && cd ../explicit-dep && yarn install && cd implicit-dep && yarn install && cd ../../v3 && yarn install && cd ../plugin-tailwindcss && npm i && cd ../v3-plugins && npm i && cd ../v3-plugin-override && yarn install", 74 | "prettier": "prettier --write '**/*.{ts,json,md,hbs,yml,js}'", 75 | "test-compile": "yarn clean && tsc -p ./ && yarn webpack && cp -r ./src/worker ./out", 76 | "test": "node ./out/test/runTests.js", 77 | "version": "node ./scripts/version.js && git add CHANGELOG.md", 78 | "vscode:prepublish": "webpack --mode production", 79 | "watch": "tsc --watch -p ./", 80 | "webpack-dev": "webpack --mode development --watch", 81 | "webpack": "webpack --mode development", 82 | "chrome": "yarn webpack && vscode-test-web --browserType=chromium --extensionDevelopmentPath=. .", 83 | "prepare": "husky" 84 | }, 85 | "lint-staged": { 86 | "**/*.{ts,json,md,yml,hbs,js}": [ 87 | "prettier --write" 88 | ], 89 | "src/**/*.ts": [ 90 | "eslint -c .eslintrc.js --ext .ts ." 91 | ] 92 | }, 93 | "devDependencies": { 94 | "@types/fs-extra": "^11.0.4", 95 | "@types/glob": "^7.2.0", 96 | "@types/mocha": "^10.0.7", 97 | "@types/node": "20.11.30", 98 | "@types/prettier": "^2.7.2", 99 | "@types/resolve": "^1.20.3", 100 | "@types/semver": "^7.5.8", 101 | "@types/sinon": "^17.0.3", 102 | "@types/tmp": "^0.2.6", 103 | "@types/vscode": "^1.80.0", 104 | "@typescript-eslint/eslint-plugin": "^5.45.0", 105 | "@typescript-eslint/parser": "^5.45.0", 106 | "@vscode/test-electron": "^2.4.1", 107 | "@vscode/test-web": "^0.0.56", 108 | "copy-webpack-plugin": "^12.0.2", 109 | "eslint": "^8.31.0", 110 | "eslint-config-prettier": "^9.1.0", 111 | "fs-extra": "^11.2.0", 112 | "glob": "^7.2.0", 113 | "husky": "^9.1.4", 114 | "lint-staged": "^15.2.9", 115 | "mocha": "^10.7.3", 116 | "path-browserify": "^1.0.1", 117 | "process": "^0.11.10", 118 | "sinon": "^17.0.1", 119 | "tmp": "^0.2.3", 120 | "ts-loader": "^9.5.1", 121 | "typescript": "^4.6.3", 122 | "util": "^0.12.4", 123 | "vsce": "^2.15.0", 124 | "vscode-nls-dev": "^4.0.4", 125 | "webpack": "^5.93.0", 126 | "webpack-cli": "^5.0.1" 127 | }, 128 | "dependencies": { 129 | "find-up": "5.0.0", 130 | "prettier": "^2.8.8", 131 | "resolve": "^1.22.8", 132 | "semver": "^7.6.3", 133 | "vscode-nls": "^5.2.0" 134 | }, 135 | "capabilities": { 136 | "virtualWorkspaces": true, 137 | "untrustedWorkspaces": { 138 | "supported": "limited", 139 | "description": "%ext.capabilities.untrustedWorkspaces.description%", 140 | "restrictedConfigurations": [ 141 | "prettier.documentSelectors", 142 | "prettier.resolveGlobalModules", 143 | "prettier.ignorePath", 144 | "prettier.prettierPath", 145 | "prettier.configPath", 146 | "prettier.useEditorConfig", 147 | "prettier.resolveGlobalModules", 148 | "prettier.withNodeModules" 149 | ] 150 | } 151 | }, 152 | "contributes": { 153 | "configuration": { 154 | "type": "object", 155 | "title": "%ext.config.title%", 156 | "properties": { 157 | "prettier.disableLanguages": { 158 | "type": "array", 159 | "items": { 160 | "type": "string" 161 | }, 162 | "deprecationMessage": "%ext.config.disableLanguagesDeprecation%", 163 | "markdownDescription": "%ext.config.disableLanguages%", 164 | "scope": "window" 165 | }, 166 | "prettier.documentSelectors": { 167 | "type": "array", 168 | "items": { 169 | "type": "string" 170 | }, 171 | "markdownDescription": "%ext.config.documentSelectors%", 172 | "scope": "window" 173 | }, 174 | "prettier.enable": { 175 | "type": "boolean", 176 | "default": true, 177 | "markdownDescription": "%ext.config.enable%", 178 | "scope": "resource" 179 | }, 180 | "prettier.requireConfig": { 181 | "type": "boolean", 182 | "default": false, 183 | "markdownDescription": "%ext.config.requireConfig%", 184 | "scope": "resource" 185 | }, 186 | "prettier.resolveGlobalModules": { 187 | "type": "boolean", 188 | "default": false, 189 | "markdownDescription": "%ext.config.resolveGlobalModules%", 190 | "scope": "resource" 191 | }, 192 | "prettier.withNodeModules": { 193 | "type": "boolean", 194 | "default": false, 195 | "markdownDescription": "%ext.config.withNodeModules%", 196 | "scope": "resource" 197 | }, 198 | "prettier.packageManager": { 199 | "scope": "resource", 200 | "type": "string", 201 | "enum": [ 202 | "npm", 203 | "yarn", 204 | "pnpm" 205 | ], 206 | "default": "npm", 207 | "deprecationMessage": "%ext.config.packageManagerDeprecation%", 208 | "markdownDescription": "%ext.config.packageManager%" 209 | }, 210 | "prettier.useEditorConfig": { 211 | "type": "boolean", 212 | "default": true, 213 | "markdownDescription": "%ext.config.useEditorConfig%", 214 | "scope": "resource" 215 | }, 216 | "prettier.ignorePath": { 217 | "type": "string", 218 | "default": ".prettierignore", 219 | "markdownDescription": "%ext.config.ignorePath%", 220 | "scope": "resource" 221 | }, 222 | "prettier.prettierPath": { 223 | "type": "string", 224 | "markdownDescription": "%ext.config.prettierPath%", 225 | "scope": "resource" 226 | }, 227 | "prettier.configPath": { 228 | "type": "string", 229 | "markdownDescription": "%ext.config.configPath%", 230 | "scope": "resource" 231 | }, 232 | "prettier.enableDebugLogs": { 233 | "type": "boolean", 234 | "default": false, 235 | "markdownDescription": "%ext.config.enableDebugLogs%", 236 | "scope": "resource" 237 | }, 238 | "prettier.printWidth": { 239 | "type": "integer", 240 | "default": 80, 241 | "markdownDescription": "%ext.config.printWidth%", 242 | "scope": "language-overridable" 243 | }, 244 | "prettier.tabWidth": { 245 | "type": "integer", 246 | "default": 2, 247 | "markdownDescription": "%ext.config.tabWidth%", 248 | "scope": "language-overridable" 249 | }, 250 | "prettier.singleQuote": { 251 | "type": "boolean", 252 | "default": false, 253 | "markdownDescription": "%ext.config.singleQuote%", 254 | "scope": "language-overridable" 255 | }, 256 | "prettier.trailingComma": { 257 | "type": "string", 258 | "enum": [ 259 | "none", 260 | "es5", 261 | "all" 262 | ], 263 | "default": "es5", 264 | "markdownDescription": "%ext.config.trailingComma%", 265 | "scope": "language-overridable" 266 | }, 267 | "prettier.bracketSpacing": { 268 | "type": "boolean", 269 | "default": true, 270 | "markdownDescription": "%ext.config.bracketSpacing%", 271 | "scope": "language-overridable" 272 | }, 273 | "prettier.singleAttributePerLine": { 274 | "type": "boolean", 275 | "default": false, 276 | "markdownDescription": "%ext.config.singleAttributePerLine%", 277 | "scope": "language-overridable" 278 | }, 279 | "prettier.bracketSameLine": { 280 | "type": "boolean", 281 | "default": false, 282 | "markdownDescription": "%ext.config.bracketSameLine%", 283 | "scope": "language-overridable" 284 | }, 285 | "prettier.jsxBracketSameLine": { 286 | "type": "boolean", 287 | "default": false, 288 | "markdownDescription": "%ext.config.jsxBracketSameLine%", 289 | "deprecationMessage": "%ext.config.jsxBracketSameLineDeprecation%", 290 | "scope": "language-overridable" 291 | }, 292 | "prettier.semi": { 293 | "type": "boolean", 294 | "default": true, 295 | "markdownDescription": "%ext.config.semi%", 296 | "scope": "language-overridable" 297 | }, 298 | "prettier.requirePragma": { 299 | "type": "boolean", 300 | "default": false, 301 | "markdownDescription": "%ext.config.requirePragma%", 302 | "scope": "language-overridable" 303 | }, 304 | "prettier.insertPragma": { 305 | "type": "boolean", 306 | "default": false, 307 | "markdownDescription": "%ext.config.insertPragma%", 308 | "scope": "language-overridable" 309 | }, 310 | "prettier.useTabs": { 311 | "type": "boolean", 312 | "default": false, 313 | "markdownDescription": "%ext.config.useTabs%", 314 | "scope": "language-overridable" 315 | }, 316 | "prettier.proseWrap": { 317 | "type": "string", 318 | "enum": [ 319 | "preserve", 320 | "always", 321 | "never" 322 | ], 323 | "default": "preserve", 324 | "markdownDescription": "%ext.config.proseWrap%", 325 | "scope": "language-overridable" 326 | }, 327 | "prettier.arrowParens": { 328 | "type": "string", 329 | "enum": [ 330 | "avoid", 331 | "always" 332 | ], 333 | "default": "always", 334 | "markdownDescription": "%ext.config.arrowParens%", 335 | "scope": "language-overridable" 336 | }, 337 | "prettier.jsxSingleQuote": { 338 | "type": "boolean", 339 | "default": false, 340 | "markdownDescription": "%ext.config.jsxSingleQuote%", 341 | "scope": "language-overridable" 342 | }, 343 | "prettier.htmlWhitespaceSensitivity": { 344 | "type": "string", 345 | "enum": [ 346 | "css", 347 | "strict", 348 | "ignore" 349 | ], 350 | "default": "css", 351 | "markdownDescription": "%ext.config.htmlWhitespaceSensitivity%", 352 | "scope": "language-overridable" 353 | }, 354 | "prettier.vueIndentScriptAndStyle": { 355 | "type": "boolean", 356 | "default": false, 357 | "markdownDescription": "%ext.config.vueIndentScriptAndStyle%", 358 | "scope": "language-overridable" 359 | }, 360 | "prettier.endOfLine": { 361 | "type": "string", 362 | "enum": [ 363 | "auto", 364 | "lf", 365 | "crlf", 366 | "cr" 367 | ], 368 | "default": "lf", 369 | "markdownDescription": "%ext.config.endOfLine%", 370 | "scope": "language-overridable" 371 | }, 372 | "prettier.quoteProps": { 373 | "type": "string", 374 | "enum": [ 375 | "as-needed", 376 | "consistent", 377 | "preserve" 378 | ], 379 | "default": "as-needed", 380 | "markdownDescription": "%ext.config.quoteProps%", 381 | "scope": "language-overridable" 382 | }, 383 | "prettier.embeddedLanguageFormatting": { 384 | "type": "string", 385 | "enum": [ 386 | "auto", 387 | "off" 388 | ], 389 | "default": "auto", 390 | "markdownDescription": "%ext.config.embeddedLanguageFormatting%", 391 | "scope": "language-overridable" 392 | }, 393 | "prettier.experimentalTernaries": { 394 | "type": "boolean", 395 | "default": false, 396 | "markdownDescription": "%ext.config.experimentalTernaries%", 397 | "scope": "language-overridable" 398 | } 399 | } 400 | }, 401 | "jsonValidation": [ 402 | { 403 | "fileMatch": ".prettierrc", 404 | "url": "https://json.schemastore.org/prettierrc" 405 | }, 406 | { 407 | "fileMatch": ".prettierrc.json", 408 | "url": "https://json.schemastore.org/prettierrc" 409 | }, 410 | { 411 | "fileMatch": "package.json", 412 | "url": "./package-json-schema.json" 413 | } 414 | ], 415 | "languages": [ 416 | { 417 | "id": "json", 418 | "filenames": [ 419 | ".prettierrc" 420 | ] 421 | }, 422 | { 423 | "id": "ignore", 424 | "filenames": [ 425 | ".prettierignore" 426 | ] 427 | }, 428 | { 429 | "id": "graphql", 430 | "extensions": [ 431 | ".graphql" 432 | ] 433 | }, 434 | { 435 | "id": "vue", 436 | "extensions": [ 437 | ".vue" 438 | ] 439 | }, 440 | { 441 | "id": "handlebars", 442 | "extensions": [ 443 | ".hbs", 444 | ".handlebars" 445 | ] 446 | } 447 | ], 448 | "commands": [ 449 | { 450 | "command": "prettier.createConfigFile", 451 | "title": "%ext.command.createConfigFile.title%" 452 | }, 453 | { 454 | "command": "prettier.forceFormatDocument", 455 | "title": "%ext.command.forceFormatDocument.title%", 456 | "when": "editorFocus" 457 | } 458 | ] 459 | }, 460 | "__metadata": { 461 | "id": "96fa4707-6983-4489-b7c5-d5ffdfdcce90", 462 | "publisherDisplayName": "Prettier", 463 | "publisherId": "d16f4e39-2ffb-44e3-9c0d-79d873570e3a", 464 | "isPreReleaseVersion": false 465 | } 466 | } 467 | -------------------------------------------------------------------------------- /package.nls.json: -------------------------------------------------------------------------------- 1 | { 2 | "ext.command.createConfigFile.title": "Prettier: Create Configuration File", 3 | "ext.command.forceFormatDocument.title": "Format Document (Forced)", 4 | "ext.config.arrowParens": "Include parentheses around a sole arrow function parameter.", 5 | "ext.config.bracketSpacing": "Controls the printing of spaces inside object literals.", 6 | "ext.config.configPath": "Path to the prettier configuration file.", 7 | "ext.config.disableLanguages": "A list of languages IDs to disable this extension on.", 8 | "ext.config.disableLanguagesDeprecation": "This feature is no longer supported. Instead, configure VS Code [default formatters](https://github.com/prettier/prettier-vscode#default-formatter) or use .prettierignore.", 9 | "ext.config.documentSelectors": "A list of [glob patterns](https://code.visualstudio.com/api/references/vscode-api#GlobPattern) to register Prettier formatter.", 10 | "ext.config.endOfLine": "Specify the end of line used by prettier.", 11 | "ext.config.htmlWhitespaceSensitivity": "Specify the global [whitespace sensitivity](https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting) for HTML files.\nValid options:\n- `css` - Respect the default value of CSS `display` property.\n- `strict` - Whitespaces are considered sensitive.\n- `ignore` - Whitespaces are considered insensitive.", 12 | "ext.config.ignorePath": "Path to a `.prettierignore` file.", 13 | "ext.config.insertPragma": "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.", 14 | "ext.config.singleAttributePerLine": "Enforces single attribute per line in HTML, JSX, Vue and Angular.", 15 | "ext.config.bracketSameLine": "Puts the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements).", 16 | "ext.config.jsxBracketSameLine": "Puts 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).", 17 | "ext.config.jsxBracketSameLineDeprecation": "This option has been deprecated in v2.4.0, use `bracketSameLine` instead.", 18 | "ext.config.jsxSingleQuote": "Use single quotes instead of double quotes in JSX.", 19 | "ext.config.packageManager": "The package manager you use to install node modules.", 20 | "ext.config.packageManagerDeprecation": "Package manager is now automatically detected by VS Code. This setting is no longer used.", 21 | "ext.config.parser": "Override the parser. You shouldn't have to change this setting.", 22 | "ext.config.parserDeprecationMessage": "This setting is no longer supported. Use a prettier configuration file instead.", 23 | "ext.config.prettierPath": "Path to the `prettier` module, eg: `./node_modules/prettier`.", 24 | "ext.config.printWidth": "Fit code within this line limit.", 25 | "ext.config.proseWrap": "(Markdown) wrap prose over multiple lines.", 26 | "ext.config.quoteProps": "Change when properties in objects are quoted.\nValid options:\n- `\"as-needed\"` - Only add quotes around object properties where required.\n- `\"consistent\"` - If at least one property in an object requires quotes, quote all properties.\n- `\"preserve\"` - Respect the input use of quotes in object properties.", 27 | "ext.config.requireConfig": "Require a prettier configuration file to format. See [documentation for valid configuration files](https://prettier.io/docs/en/configuration.html).\n\n> _Note, untitled files will still be formatted using the VS Code prettier settings even when this setting is set._", 28 | "ext.config.requirePragma": "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.", 29 | "ext.config.resolveGlobalModules": "When enabled, this extension will attempt to use global npm or yarn modules if local modules cannot be resolved.\n> _This setting can have a negative performance impact, particularly on Windows when you have attached network drives. Only enable this if you must use global modules._", 30 | "ext.config.withNodeModules": "This extension will process files in `node_modules`.", 31 | "ext.config.semi": "Whether to add a semicolon at the end of every line.", 32 | "ext.config.singleQuote": "Use single instead of double quotes.", 33 | "ext.config.tabWidth": "Number of spaces it should use per tab.", 34 | "ext.config.title": "Prettier", 35 | "ext.config.trailingComma": "Controls the printing of trailing commas wherever possible. \nValid options:\n- `none` - No trailing commas\n- `es5` - Trailing commas where valid in ES5 (objects, arrays, etc)\n- `all` - Trailing commas wherever possible (function arguments)", 36 | "ext.config.useEditorConfig": "Whether or not to take `.editorconfig` into account when parsing configuration. See the [`prettier.resolveConfig`](https://prettier.io/docs/en/api.html) docs for details.", 37 | "ext.config.useTabs": "Indent lines with tabs.", 38 | "ext.config.vueIndentScriptAndStyle": "Whether or not to indent the code inside `