Search code examples
javascriptprettier

Prettier ignore handlebars


I have the following folder structure in my Meteor project.

> .meteor

>public

> client (dir)
>> foo.html &
>> foo.js

>> bar (dir: client/bar)
>>> bar.html &
>>> bar.js

> server
>> baz.js

I want to format all JS files inside of client directory

npx prettier --write 'client/**/*.js'

only formats files like bar.js. In reality I have up to 5 levels deep folders, and they need to be formatted too.

npx prettier --write 'client/**'

Works, but affects html (handlebar) files, I want to avoid that.

Any ideas? I can't find anything in the documentation, a part from manually adding an ignore to all .html files but that's an overkill.


Solution

  • You can add the following config to avoid handlebars (.hbs) formatting

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