Prettier-vscode: No way to stop Prettier formatting Handlebars on save with prettier.disableLanguages or ignorePath

Created on 9 Jan 2018  路  5Comments  路  Source: prettier/prettier-vscode

Hi, thanks for the free plugin.

I have VS-Code Insiders 1.20.0 and editor.formatOnSave = true. I have some handlebars files (.hbs) that I do NOT want to be formatted by prettier, as it isn't smart enough to handle the YAML front matter in those files.

I have tried adding this to the settings, in every combination (btw, where do I find a list of the language IDs?):

"prettier.disableLanguages": [
    "handlebar",
    "handlebars",
    "hbs",
]

Nothing works. Then I tried creating a custom .prettierignore file in my home folder (I am not allowed to add it to the project, nor to the project's .gitignore) and tried to add that file to prettier - but no joy

"prettier.ignorePath": "~/.prettierignore",

# ~/.prettierignore
**/*.hbs

Is there any way to make this work? The main reason to use this plugin is for the format on save. It would be a shame to have to ditch it because of Handlebars.

Thanks.

locked

Most helpful comment

Yes you are right - it was the standard formatter. In case someone else stumbles on this, I have solved it by adding the following to the user preferences:

"[handlebars]": { "editor.formatOnSave": false },

All 5 comments

As of [email protected], this is the list of languages ids prettier is enabled on:
["javascript","javascriptreact","typescript","typescriptreact","css","less","scss","graphql","json","markdown"]
I think you have an other formatter installed for handlebars (default one if any)

handlebars is the languageId for Handlebars by default at least

Yes you are right - it was the standard formatter. In case someone else stumbles on this, I have solved it by adding the following to the user preferences:

"[handlebars]": { "editor.formatOnSave": false },

Yes you are right - it was the standard formatter. In case someone else stumbles on this, I have solved it by adding the following to the user preferences:

"[handlebars]": { "editor.formatOnSave": false },

Very good, I also had it on fomatOnPaste.

Now:

"[handlebars]": {
    "editor.formatOnSave": false,
    "editor.formatOnPaste": false
  }

Just install this extension in your vs code and you are good to go
https://marketplace.visualstudio.com/items?itemName=mfeckies.handlebars-formatter

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings