A banner was created from here

ํŒŒ์ผ ๋์— ๊ฐœํ–‰์„ ํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๋ฅผ ํ•œ ์ค„๋กœ ์–˜๊ธฐํ•˜์ž๋ฉด
POSIX ์—์„œ ํ•˜๋‚˜์˜ ํ–‰์„ ์ •์˜ํ•˜๋Š” ํ‘œ์ค€์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค

๋ชจ๋“  ํ…์ŠคํŠธ ํŒŒ์ผ์—์„œ "ํ–‰" ์ด๋ผ๋Š” ๋‹จ์œ„๋Š” ๊ฐœํ•ญ๋ฌธ์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋งŒ๋“ค์–ด ์ง‘๋‹ˆ๋‹ค

์™œ๋ƒ๋ฉด, IEEE ๋ผ๋Š” ๋‹จ์ฒด์—์„œ UNIX ์˜ ํ‘œ์ค€์„ ๊ทธ๋ ‡๊ฒŒ ์ •์˜ํ•˜๊ณ  ์žˆ๊ฑฐ๋“ ์š”

3.206 Line
A sequence of zero or more non- <newline> characters plus a terminating <newline> character.

์•„๋ž˜์˜ IEEE ํ‘œ์ค€์— ๋‚˜์™€ ์ž‡๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ, ๋๋‚˜์ง€ ์•Š์€ ํ–‰์€
ํŒŒ์ผ ๋์— non-newline ๋ฌธ์ž๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ ์žˆ๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค

3.195 Incomplete Line
A sequence of one or more non- <newline> characters at the end of the file.

๋ง์„ ๋ฐ˜๋Œ€๋กœ ํ•ด์„œ ์ดํ•ดํ•˜๊ธฐ๊ฐ€ ์กฐ๊ธˆ ์–ด๋ ค์šด๋ฐ ๋ฐ”๊ฟ”๋งํ•˜๋ฉด
ํŒŒ์ผ ๋์— newline ๋ฌธ์ž๊ฐ€ ์—†์œผ๋ฉด ๋๋‚˜์ง€ ์•Š์€ ํ–‰์œผ๋กœ ๊ฐ„์ฃผํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค

๊ฐœํ–‰ ๋ฌธ์ž


์ด ๊ณณ์—๋Š” ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž ๋ถ„๋“ค๊ป˜์„œ ๋งŽ์ด ์„œ์‹ํ•˜๋‹ˆ๊นŒ
.prettierrc ํŒŒ์ผ์„ ์ž‘์„ฑ ํ•˜์‹ค๋•Œ์˜ ์˜ˆ๋ฅผ ๋“ค์–ด ์„ค๋ช…ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค

์•„๋ž˜ ํ‘œ๋Š” prettier ์„ค์ • ์ค‘ "endOfLine" ์˜ต์…˜์— ๊ด€ํ•œ ๊ฐ’์˜ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค

Default CLI Override API Override
"auto" --end-of-line <auto | lf | crlf | cr> endOfLine: "<auto | lf | crlf | cr>"

auto ๋Š” ๋ญ ์ ๋‹นํžˆ ์ž๋™์œผ๋กœ ํ•ด์ฃผ๊ฒ ๋‹ค๋Š” ์˜๋ฏธ๋กœ ์•Œ๊ฒ ๋Š”๋ฐ
lf, crlf, cr ์€ ๋Œ€์ฒด ๋ฌด์Šจ ์˜๋ฏธ์ผ๊นŒ์š”?

lf


Line Feed ์˜ ์ค„์ž„๋ง๋กœ, UNIX ์šด์˜ ์ฒด์ œ์—์„œ ๊ฐœํ–‰ ๋ฌธ์ž (์ค„๋ฐ”๊ฟˆ ๋ฌธ์ž) ๋กœ ์‚ฌ์šฉ ๋ฉ๋‹ˆ๋‹ค
ASCII ์—์„œ๋Š” 0x0A(10) ์ฝ”๋“œ ๋ฒˆํ˜ธ๋ฅผ ๊ฐ–์Šต๋‹ˆ๋‹ค. ๋‹ค๋“ค ์•Œ๊ณ  ๊ณ„์‹œ๋Š” \n ๋ฌธ์ž๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค

์–ด๋”˜๊ฐ€์— ๊ธ€์„ ์“ธ ๋•Œ ๊นœ๋นก์ด๋Š” ์ปค์„œ๋ฅผ ๋ณด์…จ๋‹ค๋ฉด
๊ทธ ์ปค์„œ๋ฅผ ํ•œ ์นธ ์•„๋ž˜๋กœ ๋‚ด๋ฆฌ๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค
์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ถœ์ด ์ถ”๊ฐ€๋˜๊ฒ ์ฃ ?

cr


Carriage Return ์˜ ์ค„์ž„๋ง๋กœ
๊ณผ๊ฑฐ MacOS (9 ๋ฒ„์ „ ์ดํ•˜) ์˜ ์šด์˜์ฒด์ œ์—์„œ๋Š” ์ค„ ๋ฐ”๊ฟˆ์„ ์‚ฌ์šฉ ํ–ˆ์Šต๋‹ˆ๋‹ค

ASCII ์—์„œ๋Š” 0x0D(13) ์ฝ”๋“œ ๋ฒˆํ˜ธ๋ฅผ ๊ฐ–์Šต๋‹ˆ๋‹ค. ์กฐ๊ธˆ ์ƒ์†Œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ
ํŒŒ์ด์ฌ์œผ๋กœ ์œˆ๋„์šฐ์—์„œ ๋„˜์–ด์˜จ ํ…์ŠคํŠธ ํŒŒ์ผ์„ ์ฒ˜๋ฆฌํ•  ์ผ์ด ์žˆ์œผ์‹  ๋ถ„๋“ค์€...
์•„์ฃผ ๊ท€์ฐฎ์€ ๋…€์„์ด์ฃ  ๐Ÿ”ฅ

Carriage Return ์˜ ์—ญํ• ์€, ์ปค์„œ๋ฅผ ํ˜„์žฌ ์ค„ ๋งจ ์•ž์œผ๋กœ ๊ฐ€์ ธ๊ฐ€๋Š” ๊ฒ๋‹ˆ๋‹ค

์œˆ๋„์šฐ ์šด์˜์ฒด์ œ๋Š” lf ์™€ cr ์„ ์กฐํ•ฉํ•˜์—ฌ ์ค„๋ฐ”๊ฟˆ์„ ์ฒ˜๋ฆฌ ํ•ฉ๋‹ˆ๋‹ค (ํ˜„์žฌ๋„)
์ด๋ฅผ ๋ณดํ†ต crlf ์˜ ํ˜•ํƒœ๋กœ ํ•˜๋Š”๋ฐ ๋ฌธ์ž๋กœ ํ‘œํ˜„ํ•˜๋ฉด \r\n ์˜ ์กฐํ•ฉ์ด ๋ฉ๋‹ˆ๋‹ค
์ปค์„œ๋ฅผ ๋งจ ์•ž์œผ๋กœ ์˜ฎ๊ธฐ๊ณ  ๊ทธ ์œ„์น˜์—์„œ ์•„๋ž˜๋กœ ํ•œ ์ค„ ์ถ”๊ฐ€ ํ•˜๋Š” ํ˜•ํƒœ๋กœ ๋™์ž‘ํ•˜๊ฒ ์ฃ 

lf, cr ์˜ ์˜๋ฏธ๋ฅผ ์•Œ์•˜์œผ๋‹ˆ prettier ๊ฐ€ ์˜๋„ํ•œ ์˜ต์…˜ ๊ฐ’์„ ์ด์ œ์•ผ ์ดํ•ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค
๋„ˆ์˜ ์šด์˜์ฒด์ œ์— ๋งž๊ฒŒ, EOL(end of line) ๊ฐ’์„ ๋ถ™์—ฌ์ค„๊ฒŒ. ์„ค์ •์„ ์•Œ๋ ค์ค˜!

๊ทธ๋Ÿฌ๋‹ˆ ์—ฌ๋Ÿฌ๋ถ„๋“ค์€ ์ž์‹ ์˜ ์šด์˜์ฒด์ œ์— ๋งž๋Š” EOL ์„ค์ •์„ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜
์•Œ์•„์„œ ์ž˜ ํ•ด์ค„๊ฑฐ๋ผ๊ณ  ๋ฏฟ๊ณ  auto๋กœ ๋‘์…”๋„ ๋ฉ๋‹ˆ๋‹ค!

๊ฐœํ–‰๋ฌธ์ž ๊ด€๋ จ ์‚ฌ์†Œํ•œ ์˜ค๋ฅ˜๋“ค


  1. ์šด์˜์ฒด์ œ์— ๋งž์ง€ ์•Š๋Š” ๊ฐœํ–‰ ๋ฌธ์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ, ํ…์ŠคํŠธ ์ค„ ๋ฐ”๊ฟˆ์ด ํ•˜๋‚˜๋„ ๋˜์ง€ ์•Š๊ฑฐ๋‚˜
  2. ์šด์˜์ฒด์ œ๋ณ„๋กœ EOL ์„ค์ •์ด ๋‹ฌ๋ผ, Git ์—์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒ

์ƒ๊ธฐํ•œ ๋ฌธ์ œ๋“ค์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

์˜ˆ๋ฅผ ๋“ค์–ด, python ์˜ ๊ฒฝ์šฐ๋Š” os.linesep ์ด๋ผ๋Š” ์†์„ฑ์œผ๋กœ, ์šด์˜์ฒด์ œ๋ณ„๋กœ ๊ฐœํ–‰๋ฌธ์ž๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค

MacOS

In [1]: import os

In [2]: os.linesep
Out[2]: '\n'

Windows 10(x64)

In [1]: import os

In [2]: os.linesep
Out[2]: '\r\n'

๊ฐœํ–‰ ๋ฌธ์ž๋ฅผ ํ•˜๋“œ์ฝ”๋”ฉ ํ•˜๊ธฐ ๋ณด๋‹ค๋Š”, os.linesep ์„ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ
์ข€ ๋” ๋ฐ”๋žŒ์ง ํ•˜๊ฒ ๋„ค์š”

Github ์€ ํŒŒ์ผ ๋งˆ์ง€๋ง‰์ด ๊ฐœํ–‰ ๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฉด
๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๋ฅผ ์•Œ๋ ค์ค๋‹ˆ๋‹ค (์ž ์žฌ์ ์ธ ๋ฌธ์ œ๊ฐ€ ๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—!)

image.png

Github ์—์„œ๋Š” ์ด๋Ÿฐ ๋ฌธ์ œ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด, ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ์ œ์‹œํ•ฉ๋‹ˆ๋‹ค

  1. ์‚ฌ์ „์— .gitattributes ํŒŒ์ผ์— ๊ฐœํ–‰ ๋ฌธ์ž๋ฅผ ์ •์˜ํ•˜๊ณ  ์ฒ˜๋ฆฌํ•˜๊ฑฐ๋‚˜
  2. global config ์— ๋ฏธ๋ฆฌ ์„ค์ •

์ž์„ธํ•œ ๋‚ด์šฉ์€ Github ๊ณต์‹ ๋ฌธ์„œ ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”

๋งˆ์น˜๋ฉฐ


๋ง‰์—ฐํ•˜๊ฒŒ, ์ค„ ๋ฐ”๊ฟˆ์ด ๋จนํžˆ์ง€ ์•Š์•„์„œ
\r\n ๋„ ํ•ด๋ณด๊ณ , \n ๋„ ํ•ด๋ณด๊ณ  ์ขŒ์ถฉ์šฐ๋Œ ๊ฐœ๋ฐœ ํ•˜๋˜ ์žฌ์ž‘๋…„์ด ์ƒ๊ฐ๋‚ฉ๋‹ˆ๋‹ค

๊ทธ ๋•Œ๋Š” ์™œ ์ด๊ฑธ ์ฐพ์•„๋ณด๊ณ  ์•Œ์•„์•ผ ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์„ ๋ชป ํ–ˆ์—ˆ๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ
์ง€๊ธˆ์ด๋ผ๋„ ์ •ํ™•ํ•˜๊ฒŒ ์•Œ ์ˆ˜ ์žˆ์–ด์„œ ๋‹คํ–‰์ž…๋‹ˆ๋‹ค

์ด์ œ๋Š” ์กฐ๊ธˆ ๋” POSIX ํ‘œ์ค€์„ ์ง€ํ‚ค๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ๋œ๊ฑธ๊นŒ์š”...?
์•„๋ฌดํŠผ ๊ธธ๊ณ  ์“ธ๋ฐ์—†๋Š” ๊ธ€ ์ฝ์–ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๐ŸŒˆ