最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Prettier ignore handlebars - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question asked Aug 24, 2021 at 11:01 AlexAlex 1,4204 gold badges22 silver badges40 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Add a .prettierignore file to your project root to ignore handlebars files, e. g.:

*.handlebars

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

"[handlebars]": {
    "editor.formatOnSave": false,
    "editor.formatOnPaste": false
}
发布评论

评论列表(0)

  1. 暂无评论