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

๐Ÿ“ฆ eslint-plugin

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

์„ค์น˜โ€‹

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

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

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

.eslintrc
{
"plugins": ["@docusaurus"]
}

๊ทธ๋ฆฌ๊ณ  ๋‹ค์Œ ์„ค์ • ์ค‘ ํ•˜๋‚˜๋ฅผ ํ™•์žฅํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: recommended ์„ค์ •).

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

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

.eslintrc
{
"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๋ฅผ ๊ฐ•์ œ๋กœ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.โœ…

โœ… = recommended

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

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

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