Introducing Prettier with Eslint

Michael Hsu
Apr 19, 2017 · 5 min read

Setup Prettier

$ npm i prettier -g
$ prettier — trailing-comma all — write ‘*.js’

Runs Prettier as Eslint Rules

當發了 PR,發現不合乎 Prettier 的規則就 Fail 掉該次的 CI Build。

{
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}

Resolve Conflict Rules

$ eslint --print-config .eslintrc | eslint-config-prettier-check

其他衝突解法


Badge

Formating Ignore


結論

Thanks to Lynn Lin

Michael Hsu

Written by

Front-End Developer | https://michaelhsu.tw/

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade