0.0.6 โข Published 5 months ago
@squares/eslint-plugin
ESLint & Prettier plugin for Squares
๐พ Installation
npm
npm install -D @squares/eslint-plugin eslint prettier
yarn
yarn add -D @squares/eslint-plugin eslint prettier
๐จUsage
VSCode setting
// .vscode/setting.json, ํ์ผ ์ ์ฅ ์ ์๋ fix ์ฒ๋ฆฌ๋ฅผ ์ํด ์ค์ ์ถ๊ฐ
{
...
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
...
}
Your Project (.esilntrc.js)
module.exports = {
plugins: ["@squares"],
extends: ["plugin:@squares/auto"],
}
Your Project (.eslintrc.json)
{
plugins: ["@squares"],
extends: ["plugin:@squares/auto"],
}
๐ auto config ์ค๋ช
plugins
@squares
: ์ปค์คํ
ํ๊ฒ ์์ฑ ๋์ด์ง squares eslint ํ๋ฌ๊ทธ์ธ์ ๋ช
์ํฉ๋๋ค.
extends
plugin:@squares/base
: ๊ธฐ๋ณธ์ ์ธ js ํ๋ฌ๊ทธ์ธ๋ค๊ณผ rule์ ๊ด๋ฆฌํ๋ base config ๋ฅผ ๊ธฐ๋ณธ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
overrides
"**/*.ts?(x)"
: ts ํ์ผ์ typescript configa ์ค์ ์ ์ ์ฉํ๋๋ก override ํฉ๋๋ค."**/*.{jsx,tsx}"
: jsx, tsx ์ ๊ฐ์ ํ์ผ์ react config ์ค์ ์ ์ ์ฉํ๋๋ก override ํฉ๋๋ค."**/*.tsx"
: tsx ํ์ผ (react, typesciprt)์ ๋ํ ์ค์ ์ ์ ์ฐํ๊ฒ ์ ์ฉํ๊ธฐ ์ํด ๋ณ๋๋ก ๊บผ๋ด๋๊ณ ๋ฃฐ ์ ์ฉ
rules
option | value | description |
---|
react/prop-types | off | props์ ์ ํจ์ฑ ๊ฒ์ฌ๋ฅผ ํ๋๋ฐ ์ฌ์ฉ๋๋ ์ค์ ์ผ๋ก typescript๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ค๋ณต๋ ์ ํจ์ฑ ๊ฒ์ฌ๋ฅผ ์ํํ๊ฒ ๋๋ฏ๋ก off ์ฒ๋ฆฌ |
๐ base config ์ค๋ช
extends
plugin:import/errors
: import ํ๋ฌ๊ทธ์ธ์ ์ค๋ฅ๋ฅผ ๊ฒ์ฌํ๋ ๊ท์น ์ธํธ๋ฅผ ํ์ฅํฉ๋๋ค. ์ด ๊ท์น์ import ๊ตฌ๋ฌธ์ ์๋ชป๋ ์ฌ์ฉ ๋๋ ๋ฌธ์ ๋ฅผ ์๋ณํฉ๋๋คeslint:recommended
: ESLint์์ ๊ถ์ฅํ๋ ๊ท์น์ ์ฌ์ฉํฉ๋๋ค. ์ด๊ฒ์ ์ผ๋ฐ์ ์ผ๋ก ๊ถ์ฅ๋๋ ESLint์ ๊ธฐ๋ณธ ๊ท์น์ ์๋ฏธํฉ๋๋ค.prettier
: Prettier ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ์ฌ ESLint ๊ท์น์ ์ค์ ํฉ๋๋ค.
plugins
json-format
: JSON ํ์ผ์ ์ ํจ์ฑ์ ๊ฒ์ฌํ๋ ๊ท์น์ ํฌํจํฉ๋๋ค. ์ด ํ๋ฌ๊ทธ์ธ์ JSON ํ์ผ์ ํ์์ ํ์ธํ๊ณ ์ ํจํ์ง ์์ ๊ตฌ์กฐ๋ฅผ ๊ฒ์ถํฉ๋๋ค.prettier
: Prettier ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ์ฌ ์ฝ๋๋ฅผ ํฌ๋งทํฉ๋๋ค. Prettier๋ ์ฝ๋ ํฌ๋งทํ
์ ๋ด๋นํ์ฌ ์ค์ ๋ ๊ท์น์ ๋ฐ๋ผ ์ฝ๋๋ฅผ ์๋์ผ๋ก ์ ๋ฆฌํฉ๋๋ค.imple-import-sort
: import ๊ตฌ๋ฌธ์ ๊ฐ๋จํ๊ฒ ์ ๋ ฌํ๋ ๊ท์น์ ํฌํจํฉ๋๋ค. ์ด๋ import ๊ตฌ๋ฌธ์ ์ํ๋ฒณ์์ผ๋ก ์ ๋ ฌํ๊ณ ๋ด๋ถ์ ์ผ๋ก ํน์ ํ ํจํด์ ๋ฐ๋ฅด๋๋ก ๋์ต๋๋ค.
rules(prettier)
option | value | description |
---|
singleQuote | true | ์๋ฐ์ดํ ๋์ ํ๋ฐ์ดํ ์ฌ์ฉ |
semi | false | ๋ชจ๋ ๊ตฌ๋ฌธ ๋์ ์ธ๋ฏธ์ฝ๋ก ์๋ต |
tabWidth | 2 | ๋ค์ฌ์ฐ๊ธฐ ๊ณต๋ฐฑ ์ |
useTabs | false | ํญ ๋์ ๊ณต๋ฐฑ์ผ๋ก ๋ค์ฌ์ฐ๊ธฐ |
trailingComma | all | ๋ฐฐ์ด, ๊ฐ์ฒด๋ฑ์ ๋ง์ง๋ง ์์์ ์ฝค๋ง ์ฌ์ฉ (๊ฐ๋ฅํ ํํ ๋ชจ๋ ๊ณณ์ ์ฝค๋ง) |
printWidth | 80 | ์ค ๋ฐ๊ฟํ ๊ธธ์ด |
arrowParens | avoid | ํ์ค๋ก ์์ฑํ๋ ํจ์์ ๋งค๊ฐ๋ณ์ ๊ดํธ ์๋ต ๊ฐ๋ฅ, always: ๋ชจ๋ ํจ์ ๋งค๊ฐ๋ณ์์ ๊ดํธ ์ถ๊ฐ (2.0v ์ดํ ๊ธฐ๋ณธ ๊ฐ always) |
useTabs | false | ํ๋ก์ ํธ์ ๋จ์ ์๋ prettier ์ค์ ํ์ผ๊ณผ ์ถฉ๋์ ํผํ๊ธฐ ์ํด ํ์ฌ ์ค์ ํ eslint ์ค์ ๋ง ์ฌ์ฉํ๊ฒ ๋ค๋ ์ต์
์ผ๋ก false ์ฒ๋ฆฌ, true์ธ ๊ฒฝ์ฐ prettier์ค์ ์ ์ค์ ํ์ผ์ ๋ณ๋๋ก ์ธ์ํ์ฌ ์ฌ์ฉ ํ๋ค. |
๐ react config ์ค๋ช
plugins
react
: react์ ๊ธฐ๋ณธ ๊ท์น์ ํฌํจํ๋ ํ๋ฌ๊ทธ์ธ ์ ์react-hooks
: react hooks์ ๊ธฐ๋ณธ ๊ท์น์ ํฌํจํ๋ ํ๋ฌ๊ทธ์ธ ์ ์, hooks์ ํธ์ถ ์์น, ์์กด์ฑ ๋ฐฐ์ด(dependancy) ๋ฑ์ ์ฒดํฌjsx-a11y
: react component ์์์ ์น ์ ๊ทผ์ฑ ๊ด๋ จ ๊ท์น์ ํฌํจํ ํ๋ฌ๊ทธ์ธ์ ์ ์
rules
option | value | description |
---|
react-hooks/rules-of-hooks | error | react hooks๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ์ฐ์ง ๋ชปํ ๊ฒฝ์ฐ error ๋ฐ์ |
react-hooks/exhaustive-deps | warn | react hooks ์์ ์์กด์ฑ ๋ฐฐ์ด์ ๊ด๋ฆฌ๊ฐ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ warning ์ฒ๋ฆฌ, ์๋๋ ์์กด์ฑ ์ฒ๋ฆฌ๊ฐ ์์ ๊ฒฝ์ฐ๊ฐ ์๊ธฐ ๋๋ฌธ์ warning ๋ง ํ์ |
no-console | 0 | console ์ฌ์ฉ์ ์ํด off |
no-unused-vars | warn | ์ ์ ํ ์ฌ์ฉํ์ง ์๋ ๋ณ์๋ ๊ฒฝ๊ณ ๋ง ํ๊ธฐ |
๐ typescript config ์ค๋ช
parser
@typescript-eslint/parser
: TypeScript ํ์ผ์ ํ์ฑํ๊ธฐ ์ํด ์ฌ์ฉํ ํ์๋ฅผ ์ค์
extends
plugin:@typescript-eslint/recommended
: TypeScript ๊ด๋ จ ESLint ํ๋ฌ๊ทธ์ธ์ธ @typescript-eslint์ ๊ถ์ฅ ๊ท์น๋ค์ ์ฌ์ฉํ๋๋ก ์ค์
rules
option | detailed option | value | description |
---|
@typescript-eslint/consistent-type-imports | | error | TypeScript์์์ ์ผ๊ด๋ ํ์
์ํฌํธ๋ฅผ ์ ์งํ๋๋ก ํ๋ ์ค์ |
| prefer | type-imports | ํ์
์ํฌํธ(import type)๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๊ถ์ฅํ์
์ ๋ณด๋ฅผ ๋ช
ํํ๊ฒ ๋ถ๋ฆฌํ์ฌ ๊ตฌ๋ถํ ์ ์๋ ์ฅ์ ์ด ์์์์)export type { User } from './user'; |
| disallowTypeAnnotations | warn | react hooks ์์ ์์กด์ฑ ๋ฐฐ์ด์ ๊ด๋ฆฌ๊ฐ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ warning ์ฒ๋ฆฌ, ์๋๋ ์์กด์ฑ ์ฒ๋ฆฌ๊ฐ ์์ ๊ฒฝ์ฐ๊ฐ ์๊ธฐ ๋๋ฌธ์ warning ๋ง ํ์ |
๐ Squares Site
๐ License
This software is licensed under the MIT ยฉ Squares