If your still stuck, get to this point, where you have started to debug/troubleshoot prettier, and comment below about what the debugging info says, or ask a new question and include the debugging info.Use cds version to get information about your installed package version $ cds (global): 2.6.3 This will tell you what is happening each time prettier tries to format. Then open your terminals panel, but instead of using the terminal, your going to click on the OUTPUT option at the top of the panel instead, then in the drop down to the right, select prettier from the menu. Add the following setting to your settings.json file If prettier isn't working getting these debugging details will help you ask your question without people giving you to hard of a time on here. NOTE: Stack overflow requires debugging details for every question about an issue. Prettier outputs this information for you, but you have to know how to get it. If prettier isn't working, then you are going to need to get the debugging information about why it isn't working from the prettier extension. Here is the link to Prettier's page that shows all available configurations you can add to your prettier file. prettierrc file should be placed in the ROOT directory of your project.Īdd the following to your ".prettierrc" document. The prettier configuration file is named ".prettierrc" prettierrc CONFIGURATION FILE TO EVERY PROJECT. WHAT YOU WANT TO DO TO CONFIGURE PRETTIER, IS ADD A. Notice that I added format on save? You want that so when you press CTRL + S your code is formatted.Īnother thing you don't want to do is configure prettier in your settings.json file. "faultFormatter": "esbenp.prettier-vscode", #2 This snippet shows the CORRECT configuration to use /** "settings.json" */ Then once you get Prettier working, you can use settings that specify the languages you want to use it for, and languages you don't want to use it for. html document.įor the context of this question, it isn't technically wrong, but its not the best configuration to use when trying to troubleshoot the issue, instead you should just set your default formatter as Prettier across all languages. The problem is, HTML doesn't always get placed in an. "": Your configuring the formatter to work for HTML files only. The Prettier extension id is as follows "esbenp.prettier-vscode" You need to use the prettier formatter's extension ID. "vscode.html-language-features" is not the correct extension ID. The incorrect configuration above does two things wrong. #1 The example below shows what NOT to do! /** "settings.json" */ It configures the Official Prettier Formatting Extension for all of VSCode. The second configuration is the CORRECT CONFIGURATION TO USE. Which configures the formatter specific to a file extension, and it is configuring the wrong formatter The first example shows the improper configuration that you are currently using. I have included two examples of configuring your default formatter below. Your trying to use VS Codes Languag-features formatter to get the Prettier formatter to work. Currently you don't have the correct formatter configured. We also want to make sure that prettier is the formatter we are equipping. One formats all languages, the other formats HTML only. You just want prettier to be set as the default formatter, as opposed to the default formatter for HTML, there is a big difference between the two. Your trying to specify configurations on a per language basis, which is usually the wrong thing to do if your trying to configure a formatter to format more than one language or file type. You need to configure your default formatter in a generalized way to be able to format JavaScript & HTML. The link shows the official extensions page in the Visual Studio website view, you will probably want to download it inside of your editor as opposed to installing it via a VSIX file. To verify that it is the official extension, its unique extension ID will be: "esbenp.prettier-vscode". HERE IS THE LINK TO THE OFFICIAL PRETTIER EXTENSION You want to make sure that you have the OFFICIAL PRETTIER EXTENSION. There are many prettier extensions to choose from, but only one is the official prettier extension that was written by the same people who maintain prettier. Prettier is formatting HTML, but not JavaScript. "prettier.vueIndentScriptAndStyle": false, "prettier.htmlWhitespaceSensitivity": "css", "prettier.embeddedLanguageFormatting": "auto", "faultFormatter": "esbenp.prettier-vscode", "faultFormatter": "vscode.html-language-features" The ID for the Prettier extension that I currently have equipped in VS Code is: esbenp.prettier-vscode, and my settings.json file is configured as follows: I have not been able to configure prettier to format my HTML and JavaScript code only, I don't know what else to put in my configuration.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |