{"id":15642848,"url":"https://github.com/rohit-gohri/vscode-format-code-action","last_synced_at":"2025-04-19T13:50:04.391Z","repository":{"id":38225614,"uuid":"259902339","full_name":"rohit-gohri/vscode-format-code-action","owner":"rohit-gohri","description":"A simple vscode extension that allows you to run Prettier and ESLint in order","archived":false,"fork":false,"pushed_at":"2023-09-07T22:59:31.000Z","size":46,"stargazers_count":72,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T08:23:40.344Z","etag":null,"topics":["eslint","formatter","formatter-plugin","hacktoberfest","prettier","vscode","vscode-extension"],"latest_commit_sha":null,"homepage":"https://rohit.page/blog/posts/how-to-get-prettier-eslint-play-nicely-with-vscode/?utm_source=github\u0026utm_medium=repo\u0026utm_campaign=hf","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rohit-gohri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-29T11:07:02.000Z","updated_at":"2025-03-16T11:36:57.000Z","dependencies_parsed_at":"2024-10-23T06:02:50.532Z","dependency_job_id":null,"html_url":"https://github.com/rohit-gohri/vscode-format-code-action","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-gohri%2Fvscode-format-code-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-gohri%2Fvscode-format-code-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-gohri%2Fvscode-format-code-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-gohri%2Fvscode-format-code-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohit-gohri","download_url":"https://codeload.github.com/rohit-gohri/vscode-format-code-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249707459,"owners_count":21313849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","formatter","formatter-plugin","hacktoberfest","prettier","vscode","vscode-extension"],"created_at":"2024-10-03T11:57:48.224Z","updated_at":"2025-04-19T13:50:04.364Z","avatar_url":"https://github.com/rohit-gohri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Format Code Action\n\n[![Version](https://vsmarketplacebadges.dev/version-short/rohit-gohri.format-code-action.svg)](https://marketplace.visualstudio.com/items?itemName=rohit-gohri.format-code-action) \u0026nbsp; [![Installs](https://vsmarketplacebadges.dev/installs/rohit-gohri.format-code-action.svg)](https://marketplace.visualstudio.com/items?itemName=rohit-gohri.format-code-action) \u0026nbsp; [![Ratings](https://vsmarketplacebadges.dev/rating-star/rohit-gohri.format-code-action.svg)](https://marketplace.visualstudio.com/items?itemName=rohit-gohri.format-code-action)\n\nRun eslint extension after the prettier extension in VS Code. Or the other way around, whatever way you want.\n\n## Installation\n\n\u003e Requires VS Code 1.44+\n\nInstall through VS Code extensions: [Visual Studio Code Market Place: Format Code Action](https://marketplace.visualstudio.com/items?itemName=rohit-gohri.format-code-action)\n\nOr install from within VS Code: Launch VS Code Quick Open (\u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eP\u003c/kbd\u003e or \u003ckbd\u003ecmd\u003c/kbd\u003e+\u003ckbd\u003eP\u003c/kbd\u003e), paste the following command, and press enter.\n\n    ext install rohit-gohri.format-code-action\n\nOr on the command line:\n\n    code --install-extension rohit-gohri.format-code-action\n\n## Usage\n\nDisable `formatOnSave` and use the `source.formatDocument` codeAction in whatever order you want with VS Code settings:\n\n```json\n  \"editor.formatOnSave\": false,\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"editor.codeActionsOnSave\": [\n    \"source.formatDocument\",\n    \"source.fixAll.eslint\"\n  ]\n```\n\n\u003e NOTE: This was first released with `source.fixAll.format` as the codeAction, that still works for legacy purposes.\n\nThis runs 'Format Document' with the default formatter (in this case prettier).\n\nOr for specific lanuage only:\n\n```json\n  \"editor.formatOnSave\": true,\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"[javascript]\": {\n    \"editor.formatOnSave\": false,\n    \"editor.codeActionsOnSave\": [\"source.formatDocument\", \"source.fixAll.eslint\"]\n  },\n```\n\nThis would run prettier by default, but for javascript files would run prettier and then eslint. If you want to reverse the order then just reverse the array.\n\n### Format Modified (EXPERIMENTAL)\n\nAlternatively you may want to format only the modified part of the file, in that case use `source.formatModified`:\n\n```json\n  \"editor.formatOnSave\": false,\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"editor.codeActionsOnSave\": [\n    \"source.formatModified\",\n    \"source.fixAll.eslint\"\n  ]\n```\n\nThis is experimentally supported right now, if you face any problems please report them at: \u003chttps://github.com/rohit-gohri/vscode-format-code-action/issues/5\u003e\n\n## Motivation\n\nI created this so I could use prettier and eslint together in the editor, in a specific order (eslint after prettier). Earlier prettier was setup to run on save and eslint as a codeAction with:\n\n```json\n  \"editor.formatOnSave\": true,\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  }\n```\n\nThis would often lead to prettier being run after eslint and eslint errors still being present.\n\nSince the [March 2020 (v1.44)](https://code.visualstudio.com/updates/v1_44#_explicit-ordering-for-code-actions-on-save) update, VS Code allows setting `codeActionsOnSave` as an array. This allows setting the order of the codeActions.\n\nThe extension uses the [`CodeActionProvider`](https://code.visualstudio.com/api/references/vscode-api#CodeActionProvider) api to implement a simple code action that runs 'Format Document' on the current file. This allows us to disable `formatOnSave` and use it as a codeAction instead in a specific order with other extensions.\n\nRead More on my blog: [How to get ESlint and Prettier to play nicely in VS Code?](https://rohit.page/blog/posts/how-to-get-prettier-eslint-play-nicely-with-vscode/?utm_source=github\u0026utm_medium=repo\u0026utm_campaign=hf)\n\n## VS Code API\n\n### `vscode` module\n\n- [`languages.registerCodeActionsProvider`](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeActionsProvider)\n\n## Credits\n\nBased on [Microsoft's code-actions-sample](https://github.com/microsoft/vscode-extension-samples/tree/master/code-actions-sample)\n\n### Icon\n\n[formatting by Danil Polshin from the Noun Project](https://thenounproject.com/search/?q=format\u0026i=627383).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohit-gohri%2Fvscode-format-code-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohit-gohri%2Fvscode-format-code-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohit-gohri%2Fvscode-format-code-action/lists"}