Prettier
는 formatter고 eslint
는 linter이다. 두 개의 차이점과 사용법을 알아야 더 스마트하게 사용할 수 있다. 개취지만 포맷팅 안 된 코드 상종 안 한다. (SI 다닐때 정말 힘들었...)
결론부터 말하자면 오류를 잡으려면 린터, 스타일을 교정하려면 포맷터를 사용하자.
린터 룰은 크게 포맷팅(스타일) 룰과 코드 퀄리티 룰이라는 두가지 카테고리로 나눌 수 있다. 사용되지 않은 변수를 오류로 분류하는 no-unused-vars
같은 코드 퀄리티 룰은 prettier 같은 포맷터가 잡아낼 수 없다. prettier는 코드 포맷팅에 특화되어 있으므로 eslint가 할 수 없는 최대 글자 길이에 맞춘 자동 포맷팅을 할 수 있다.
그렇다면 prettie와 eslint를 동시에 사용하려면 어떻게 설정해야 할까?
예를 들면 facebook 팀에서 제공하는 eslint-config-react-app
(CRA
를 사용하면 기본적으로 세팅되어있는 eslint config)을 사용하는 경우 non-style 룰만 포함되어 있기 때문에 별다른 설정 없이 prettier를 같이 사용해도 문제가 안 된다.
그런데 일부 eslint config (e.g. eslint:recommended
)를 설치해서 사용하려는데 prettier와 충돌하는 경우 어떻게 해야할까? 여러가지 접근법이 있는데, prettier 실행 후 eslint를 실행하는 방법(prettier-eslint
)이 있고, 충돌하는 eslint 규칙을 전부 꺼주는 방법(eslint-config-prettier
)도 있다. 앞서 설명했다시피 두 개의 역할을 구분하는 것이 좋으므로 후자의 방법을 추천한다. prettier-eslint
의 메인테이너도 2017년에 이미 이 패키지를 사용하지 않는다고 밝혔다.
린터 rules인 것 처럼 prettier를 실행하는 플러그인인 eslint-plugin-prettier
는 사용하지 말자. 특정 상황에서 유용할 수도 있지만 prettier를 직접 실행하는 것 보다 느리다.
번호를 매겨 정리하자면 다음과 같다.
eslint-config-prettier
: eslint에서 prettier와 충돌할 수 있는 rule을 꺼버림 ✅
코드 오류를 잡는데는 eslint, 코드 포맷팅에는 prettier를 사용하는 방법이다.eslint-plugin-prettier
: prettier를 eslint의 rules로 동작하게 함
포맷팅 문제도 오류로 출력되어서 오류 메시지가 지나치게 많아지며 느리다.prettier-eslint
: prettier를 실행하고 나서 eslint --fix를 실행함
prettier를 단독으로 실행하는 것 보다 훨씬 느리다.
# CRA를 사용하는 경우 eslint는 이미 설치되어있으므로 prettier만 설치해도 된다
npm i -D eslint prettier
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
}
.prettierrc
에 prettier 설정을 작성한다..eslintrc
에 eslint 설정을 작성한다.eslint-config-prettier
를 설치하고 .eslintrc
에 추가한다.npm i -D eslint-config-prettier
{
"extends": [
"airbnb",
"prettier"
]
}
Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again.digital marketing agency near me
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.mahkota338
The on-line world might be bogged downwards with the help of counterfeit web logs without a proper personal message nonetheless put up was basically awesome not to mention value typically the read through. Regards for the purpose of showing this unique when camping. 79club
Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read.สล็อต168
Thank you so much for sharing this great blog.Very inspiring and helpful too.Hope you continue to share more of your ideas.I will definitely love to read.toro99
It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks.安全合规
This is certainly hence attractive plus artistic. I like a colorations plus whichever company may get them while in the mailbox might be smiling. thong underwear for women
Compete the great get the job done, As i browse small amount of content articles in this particular websites and even It looks like that your choice of word wide web web log is without a doubt realistic important and allows gotten forums in fabulous tips. 바다이야기 사이트
Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! 홍대노래방
Compete the great get the job done, As i browse small amount of content articles in this particular websites and even It looks like that your choice of word wide web web log is without a doubt realistic important and allows gotten forums in fabulous tips. nine bet casino
Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home.밤알바
Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home.메이저사이트
Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home.인계동하이퍼블릭
Thanks for providing recent updates regarding the concern, I look forward to read more.토토사이트
I read your blog frequently and I just thought I’d say keep up the amazing work!agenolx slot
I read your blog frequently and I just thought I’d say keep up the amazing work!situs togel
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. toto I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. Investment Scam That appears to be excellent however i am still not too sure that I like it. At any rate will look far more into it and decide personally! expert tested reviews I am constantly surprised by the amount of information accessible on this subject. What you presented was well researched and well written to get your stand on this over to all your readers. Thanks a lot my dear. 오피스타
I did benefit from browsing article content uploaded on this website. They're just notable and features numerous important material. Iron iptv
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. situs togel
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. toto lotre
That appears to be excellent however i am still not too sure that I like it. At any rate will look far more into it and decide personally! slot online
I am constantly surprised by the amount of information accessible on this subject. What you presented was well researched and well written to get your stand on this over to all your readers. Thanks a lot my dear. apollo tv
I love how versatile a water pump can be. From cars to homes to farms, they’re used everywhere. apollo tv
One thing I love about my new water pump is how easy it is to maintain. Cleaning and checking filters takes just minutes. دنس بت بدون فیلتر شکن
I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content.인계동호빠
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. bandar togel
I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy. rajabandot login
That appears to be excellent however i am still not too sure that I like it. At any rate will look far more into it and decide personally! agen toto macau
I am constantly surprised by the amount of information accessible on this subject. What you presented was well researched and well written to get your stand on this over to all your readers. Thanks a lot my dear. bandar toto macau
I love how versatile a water pump can be. From cars to homes to farms, they’re used everywhere. slot gacor
One thing I love about my new water pump is how easy it is to maintain. Cleaning and checking filters takes just minutes. paito togel
Thanks for the blog post buddy! Keep them coming... samuraitoto
Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. armadatoto
Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. slot resmi
If more people that write articles involved themselves with writing great content like you, more readers would be interested in their writings. I have learned too many things from your article. agen toto macau
New web site is looking good. Thanks for the great effort. casino88
Thanks for the blog post buddy! Keep them coming... bola hit
Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. 카지노솔루션 임대
Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. 프리서버 커뮤니티
If more people that write articles involved themselves with writing great content like you, more readers would be interested in their writings. I have learned too many things from your article. basket168 slot
New web site is looking good. Thanks for the great effort. bola hit
Thanks for the blog post buddy! Keep them coming... agen slot
Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. اپلیکیشن شرط بندی فوتبال فارسی
Thanks for the blog post buddy! Keep them coming...situs toto togelThanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.[https://wholesaleleathersupplier.com/pages/faqs](Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort.)link toto[If more people that write articles involved themselves with writing great content like you, more readers would be interested in their writings. I have learned too many things from your article.](bandar toto macau)[https://www.fromsecretarytoceo.com/the-latest/](New web site is looking good. Thanks for the great effort.)agen toto
플러그인들이 비슷한 이름이라 헷갈렸는데 차이점을 설명해주셔서 감사합니다~