|
| 1 | +# @naverpay/stylelint-config |
| 2 | + |
| 3 | +๋ค์ด๋ฒํ์ด ์คํ์ผ ๊ฐ์ด๋์ ๋ง๊ฒ stylelint-config ํจํค์ง๋ฅผ ์ ๊ณตํฉ๋๋ค. |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +**stylelint**, **@naverpay/stylelint-config** ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค. |
| 8 | + |
| 9 | +```bash |
| 10 | +npm install -D stylelint@^16 @naverpay/stylelint-config |
| 11 | +``` |
| 12 | + |
| 13 | +## Configure |
| 14 | + |
| 15 | +`stylelint.config.mjs` ํ์ผ์ ์์ฑํฉ๋๋ค. `defaultSeverity` ์ default ๊ฐ์ `warning` ์
๋๋ค. |
| 16 | + |
| 17 | +```js |
| 18 | +/** @type {import('stylelint').Config} */ |
| 19 | +const config = { |
| 20 | + extends: ['@naverpay/stylelint-config'], |
| 21 | + defaultSeverity: 'error', |
| 22 | + rules: {}, |
| 23 | +} |
| 24 | + |
| 25 | +export default config |
| 26 | +``` |
| 27 | + |
| 28 | +> pure esm ๋ง์ ์ง์ํฉ๋๋ค. `.mjs`๋ก ํ์ผ์ ๋ง๋์๊ฑฐ๋, `type: "module"`์ ์ถ๊ฐํด์ฃผ์ธ์. |
| 29 | +
|
| 30 | +## CLI |
| 31 | + |
| 32 | +package.json์ ์คํฌ๋ฆฝํธ๋ฅผ ์ถ๊ฐํ์ฌ format ๊ฒ์ฌ๋ฅผ ํ ์ ์์ต๋๋ค. |
| 33 | + |
| 34 | +```jsonc |
| 35 | +// package.json |
| 36 | +{ |
| 37 | + "scripts": { |
| 38 | + "stylelint": "stylelint '**/*.{css,scss}'", |
| 39 | + "stylelint:fix": "stylelint --fix '**/*.{css,scss}'", |
| 40 | + }, |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +> - `[email protected]` ๋ฒ์ ๋ถํฐ prettier ๊ฐ ํ ์ ์๋ ์ผ์ prettier ์ ์์ ํ๊ธฐ ๋๋ฌธ์, stylelint ๊ฐ ๊ฒ์ฌํ๋ ํ์ผ์ ๋ฐ๋์ `prettier`๋ ์คํํด์ผ ํฉ๋๋ค. <https://github.com/stylelint/stylelint/blob/1c17fb87a2f16f041632e380dd0d600cb3532337/docs/migration-guide/to-15.md> |
| 45 | +> - [lefthook](https://github.com/evilmartians/lefthook)์ ์ฌ์ฉํด์ commit ๋๋ push ์ ์ ์คํ์ผ ํ์ธ์ ์๋ํํ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค. |
| 46 | +
|
| 47 | +## Integrating with IDE |
| 48 | + |
| 49 | +### VSCode |
| 50 | + |
| 51 | +[Stylelint ํ์ฅ ํ๋ก๊ทธ๋จ][Stylelint]์ ํตํด ํ์ผ ์ ์ฅ ์ ์ผ๋ถ ์์ฑ์ ๋ํด ์๋์ผ๋ก ์์ ํ ์ ์์ต๋๋ค. |
| 52 | + |
| 53 | +> ์คํ์ผ๋ฆฐํธ๊ฐ ์ ์ฉ๋์ง ์์ ํ๋ก์ ํธ์์ ์๋ ์์ ์ด ๋๋ ๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํด ํ๋ก์ ํธ ๋ฃจํธ ํด๋์ `.vscode/settings.json` ์์ฑํฉ๋๋ค. |
| 54 | +
|
| 55 | +[Stylelint ํ์ฅ ํ๋ก๊ทธ๋จ][Stylelint]์ค์น ํ ํ๋ก์ ํธ ๋ฃจํธ ํด๋์ `.vscode/settings.json` ์ ์์ฑํฉ๋๋ค. |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "css.validate": false, |
| 60 | + "less.validate": false, |
| 61 | + "scss.validate": false, |
| 62 | + "[css]": { |
| 63 | + "editor.formatOnSave": false, |
| 64 | + "editor.codeActionsOnSave": { |
| 65 | + "source.fixAll.stylelint": true |
| 66 | + } |
| 67 | + }, |
| 68 | + "[scss]": { |
| 69 | + "editor.formatOnSave": false, |
| 70 | + "editor.codeActionsOnSave": { |
| 71 | + "source.fixAll.stylelint": true |
| 72 | + } |
| 73 | + }, |
| 74 | + "stylelint.validate": ["css", "scss"] |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +์ด์ `*.{css,scss}` ํ์ผ ์ ์ฅ ์ `stylelint --fix`๋ฅผ ์๋์ผ๋ก ์คํํฉ๋๋ค. |
| 79 | + |
| 80 | +[Stylelint]: https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint |
| 81 | + |
| 82 | +## Rules |
| 83 | + |
| 84 | +- [at-rule](./src/rules/stylelint/at-rule/README.md) |
| 85 | +- [block](./src/rules/stylelint/block/README.md) |
| 86 | +- [color](./src/rules/stylelint/color/README.md) |
| 87 | +- [comment](./src/rules/stylelint/comment/README.md) |
| 88 | +- [declaration](./src/rules/stylelint/declaration/README.md) |
| 89 | +- [font](./src/rules/stylelint/font/README.md) |
| 90 | +- [function](./src/rules/stylelint/function/README.md) |
| 91 | +- [general](./src/rules/stylelint/general/README.md) |
| 92 | +- [length](./src/rules/stylelint/length/README.md) |
| 93 | +- [media-feature](./src/rules/stylelint/media-feature/README.md) |
| 94 | +- [property](./src/rules/stylelint/property/README.md) |
| 95 | +- [rule](./src/rules/stylelint/rule/README.md) |
| 96 | +- [selector](./src/rules/stylelint/selector/README.md) |
| 97 | +- [unit](./src/rules/stylelint/unit/README.md) |
| 98 | +- [stylelint-order](./src/rules/stylelint-order/README.md) |
| 99 | +- [stylelint-scss](./src/rules/stylelint-scss/README.md) |
0 commit comments