๋ฉ”์ธ ์ปจํ…์ธ ๋กœ ์ด๋™
๋ฒ„์ „: ๋ถˆ์•ˆ์ • ๐Ÿšง

๐Ÿ“ฆ eslint ํ”Œ๋Ÿฌ๊ทธ์ธ

ESLint๋Š” ์ฝ”๋“œ๋ฅผ ์ •์ ์œผ๋กœ ๋ถ„์„ํ•˜๊ณ  ๋ฌธ์ œ์ ์„ ๋ณด๊ณ ํ•˜๊ฑฐ๋‚˜ ํŽธ์ง‘๊ธฐ์—์„œ ์ฝ”๋“œ ํžŒํŠธ๋‚˜ ๋ช…๋ น์ค„์„ ํ†ตํ•ด ๋ชจ๋ฒ” ์‚ฌ๋ก€๋ฅผ ์ œ์•ˆํ•˜๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค๋Š” ์ตœ๊ณ ์˜ ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค ๊ฒฝํ—˜์„ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด ESLint ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

์„ค์น˜โ€‹

npm install --save-dev @docusaurus/eslint-plugin

์‚ฌ์šฉ๋ฒ•โ€‹

๊ถŒ์žฅ ์„ค์ •โ€‹

.eslintrc ์„ค์ • ํŒŒ์ผ์—์„œ extends ํ•ญ๋ชฉ์— plugin:@docusaurus/recommended๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

.eslintrc
{
"extends": ["plugin:@docusaurus/recommended"]
}

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด @docusaurus eslint ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ํ™œ์„ฑํ™”๋˜๊ณ  recommended ์„ค์ •์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ํ™œ์„ฑํ™”ํ•  ๊ทœ์น™ ๋ชฉ๋ก์€ ์•„๋ž˜ ์ง€์›ํ•˜๋Š” ๊ทœ์น™์„ ์ฐธ์กฐํ•˜์„ธ์š”.

์ˆ˜๋™ ์„ค์ •โ€‹

๋ณด๋‹ค ์„ธ๋ถ„ํ™”๋œ ์ œ์–ด๋ฅผ ์œ„ํ•ด ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ˆ˜๋™์œผ๋กœ ํ™œ์„ฑํ™”ํ•˜๊ณ  ์ง์ ‘ ์‚ฌ์šฉํ•  ๊ทœ์น™์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

.eslintrc
{
"plugins": ["@docusaurus"],
"rules": {
"@docusaurus/string-literal-i18n-messages": "error",
"@docusaurus/no-untranslated-text": "warn"
}
}

์ง€์›ํ•˜๋Š” ์„ค์ •โ€‹

  • Recommended: ํ™•์žฅ๋˜์–ด์•ผ ํ•˜๋Š” ๋Œ€๋ถ€๋ถ„์˜ ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค ์‚ฌ์ดํŠธ์— ๋Œ€ํ•œ ๊ถŒ์žฅ ๊ทœ์น™ ์ง‘ํ•ฉ๋‹ˆ๋‹ค.
  • All: ๋ชจ๋“  ๊ทœ์น™์ด ํ™œ์„ฑํ™”๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๋งˆ์ด๋„ˆ ๋ฒ„์ „ ๊ฐ„์— ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์˜ˆ๊ธฐ์น˜ ์•Š์€ ์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋ฐฉ์ง€ํ•˜๋ ค๋ฉด ํ•ด๋‹น ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์ง€ ๋งˆ์„ธ์š”.

์ง€์›ํ•˜๋Š” ๊ทœ์น™โ€‹

์˜ต์…˜๋ช…์„ค๋ช…
@docusaurus/no-untranslated-textJSX์˜ ํ…์ŠคํŠธ ๋ผ๋ฒจ์ด translate ํ˜ธ์ถœ๋กœ ๋ž˜ํ•‘๋˜๋„๋ก ์ ์šฉํ•ฉ๋‹ˆ๋‹ค
@docusaurus/string-literal-i18n-messages์ผ๋ฐ˜ ํ…์ŠคํŠธ ๋ผ๋ฒจ์— ๋Œ€ํ•ด ๋ฒˆ์—ญ API๋ฅผ ๊ฐ•์ œ๋กœ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.โœ…
@docusaurus/no-html-links<a> ํƒœ๊ทธ ๋Œ€์‹  @docusaurus/Link๊ฐ€ ์‚ฌ์šฉ๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.โœ…
@docusaurus/prefer-docusaurus-headingheading์— <hn> ํƒœ๊ทธ ๋Œ€์‹  @theme/Heading์ด ์‚ฌ์šฉ๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.โœ…

โœ… = recommended

์„ค์ • ์˜ˆ์‹œโ€‹

๋‹ค์Œ์€ ์„ค์ • ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

.eslintrc.js
module.exports = {
extends: ['plugin:@docusaurus/recommended'],
rules: {
'@docusaurus/no-untranslated-text': [
'warn',
{ignoredStrings: ['ยท', 'โ€”', 'ร—']},
],
},
};