Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(eslint): enhance eslint config type safety #127

Merged
merged 8 commits into from
Feb 10, 2025

Conversation

froggy1014
Copy link
Contributor

@froggy1014 froggy1014 commented Feb 9, 2025

Changes

기존 설정에서 eslint-plugin-react이 제대로 실행이 안되는 것을 확인했습니다.

에 따라서 languageOptions에 필요한 패키지 설치 및 업데이트해서 제대로 동작하는 것을 확인했고, 각 플러그인마다 커스텀이 한눈에 들어오도록 분리해놨습니다.


flatConfig에 따라 타입 적용이 안된 플러그인 같은 경우는 @eslint/eslintrc 을 통해서 타입문제 없이 사용 가능한 것을 확인했습니다.
하지만 eslint-plugin-react-hooks 같은 경우는 아예 타입 선언이 안되있기 때문에 따로 추가해서 타입 에러는 잡았습니다.

import { FlatCompat } from '@eslint/eslintrc';
import hooksPlugin from 'eslint-plugin-react-hooks';

const compat = new FlatCompat();

...compat.extends("plugin:~"), 
{
   files: ['**/*.{ts,tsx}'],
   plugins: {
      'react-hooks': hooksPlugin,
    },
    rules: {
      ...hooksPlugin.configs.recommended.rules,
    },
}

필요없는

  • @storybook/addon-onboarding
  • @chromatic/storybook

을 모든 스토리북 Addon에서 삭제했습니다. ( 애초에 패키지에 설치 및 사용되고 있지않았습니다. )

Visuals

Checklist

  • Have you written the functional specifications?
  • Have you written the test code?

Reference

Summary by CodeRabbit

  • Chores
    • 린팅 설정과 개발 도구 의존성이 최신 버전으로 업데이트되어 TypeScript, React 및 Hooks 지원이 강화되었습니다.
    • 추가 타입 선언으로 개발자 도구 경험이 개선되었습니다.
  • Style
    • 스토리와 테스트 코드의 형식을 통일하여 코드 가독성과 일관성이 향상되었습니다.
  • Bug Fixes
    • Storybook 설정에서 onboarding 애드온이 제거되어 사용자 경험이 개선되었습니다.

Copy link

changeset-bot bot commented Feb 9, 2025

⚠️ No Changeset found

Latest commit: 68040e6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Feb 9, 2025

Warning

Rate limit exceeded

@froggy1014 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 21521b2 and 68040e6.

📒 Files selected for processing (8)
  • packages/Input/.storybook/main.ts (1 hunks)
  • packages/avatar/.storybook/main.ts (1 hunks)
  • packages/button/.storybook/main.ts (1 hunks)
  • packages/divider/.storybook/main.ts (1 hunks)
  • packages/radio-group/.storybook/main.ts (1 hunks)
  • packages/skeleton/.storybook/main.ts (1 hunks)
  • packages/tooltip/.storybook/main.ts (1 hunks)
  • packages/typography/.storybook/main.ts (1 hunks)

Walkthrough

이 풀 리퀘스트는 ESLint 구성, 패키지 의존성, 및 코드 형식 개선을 포함합니다. eslint.config.ts 파일에서는 Storybook 플러그인 대신 hooksPlugin을 도입하고 globals 임포트를 추가하며, TypeScript와 React 관련 규칙을 확장했습니다. 루트 package.json에서는 새로운 의존성("@eslint/eslintrc", "@types/eslint__eslintrc", globals) 추가와 eslint 버전 업데이트가 이루어졌습니다. 또한, grid 패키지의 package.json 및 스토리/테스트 파일 포맷이 개선되었으며, eslint-plugin-react-hooks에 대한 타입 선언 파일이 추가되었습니다.

Changes

파일 변경 내용
eslint.config.ts Storybook 플러그인 제거 후 hooksPlugin 도입, globals 임포트 추가, FlatCompat 활용, TypeScript 및 React 규칙 상세 설정 추가
package.json (루트) "@eslint/eslintrc", "@types/eslint__eslintrc", "globals" 의존성 추가, eslint 버전 ^9.18.0 → ^9.20.0 업데이트
packages/grid/package.json "files" 배열 필드를 멀티라인에서 단일라인 형식으로 변경
packages/grid/src/Grid.stories.tsx, Grid.test.tsx JSX 및 props, children 포맷을 단일라인으로 변경하여 가독성 개선
types/index.d.ts eslint-plugin-react-hooks 모듈에 대한 타입 선언 추가 (configs와 rules 객체)
packages/*/.storybook/main.ts 모든 스토리북 구성 파일에서 '@storybook/addon-onboarding' 제거

Poem

나는 깡총깡총 토끼, 코드 숲을 뛰네
ESLint 변화 속에 발자국 남기며…
새 의존성들이 봄바람 따라 피어나고,
규칙들은 깔끔한 줄로 춤추네.
달콤한 변화의 노래, 행복한 마음으로 🥕


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
eslint.config.ts (2)

17-32: 규칙 비활성화에 대한 주석 추가 필요

TypeScript ESLint 규칙들을 비활성화한 이유에 대한 설명이 있으면 좋을 것 같습니다.

다음과 같이 각 규칙 비활성화에 대한 설명을 추가하는 것을 제안합니다:

 rules: {
+  // TODO 주석을 허용하기 위해 비활성화
   '@typescript-eslint/ban-ts-comment': 'off',
+  // 미사용 변수 경고는 IDE에서 처리
   '@typescript-eslint/no-unused-vars': 'off',
+  // any 타입 사용이 필요한 경우가 있어 비활성화
   '@typescript-eslint/no-explicit-any': 'off',

70-75: Storybook 규칙 설정이 비어있는 이유 문서화 필요

Storybook 플러그인의 규칙 객체가 비어있는 이유에 대한 설명이 필요합니다.

다음과 같이 주석을 추가하는 것을 제안합니다:

   // * Storybook plugin configuration
   ...compat.extends('plugin:storybook/recommended'),
   {
     files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],
+    // 기본 recommended 설정만 사용하고 추가 규칙은 없음
     rules: {},
   },
packages/flex/.storybook/main.ts (1)

5-5: 설정 변경이 일관성 있게 적용되었습니다.

모든 패키지에서 동일한 변경사항이 적용되어 일관성이 유지되었습니다. 단, 컴포넌트 사용법에 대한 문서화를 README나 스토리 파일에 추가하는 것을 고려해보세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53a8f79 and 21521b2.

📒 Files selected for processing (16)
  • .templates/component/.storybook/main.ts (1 hunks)
  • eslint.config.ts (3 hunks)
  • packages/Input/.storybook/main.ts (0 hunks)
  • packages/avatar/.storybook/main.ts (0 hunks)
  • packages/button/.storybook/main.ts (0 hunks)
  • packages/checkbox/.storybook/main.ts (1 hunks)
  • packages/divider/.storybook/main.ts (0 hunks)
  • packages/flex/.storybook/main.ts (1 hunks)
  • packages/grid/.storybook/main.ts (1 hunks)
  • packages/icon/.storybook/main.ts (1 hunks)
  • packages/radio-group/.storybook/main.ts (0 hunks)
  • packages/reset/.storybook/main.ts (1 hunks)
  • packages/skeleton/.storybook/main.ts (0 hunks)
  • packages/switch/.storybook/main.ts (1 hunks)
  • packages/tooltip/.storybook/main.ts (0 hunks)
  • packages/typography/.storybook/main.ts (0 hunks)
💤 Files with no reviewable changes (8)
  • packages/skeleton/.storybook/main.ts
  • packages/divider/.storybook/main.ts
  • packages/Input/.storybook/main.ts
  • packages/typography/.storybook/main.ts
  • packages/radio-group/.storybook/main.ts
  • packages/avatar/.storybook/main.ts
  • packages/tooltip/.storybook/main.ts
  • packages/button/.storybook/main.ts
🔇 Additional comments (10)
eslint.config.ts (4)

1-1: FlatCompat와 필요한 의존성이 적절히 추가되었습니다.

레거시 ESLint 설정과의 호환성을 위해 FlatCompat을 사용하고, 브라우저와 서비스 워커 환경을 위한 globals를 추가한 것이 적절합니다.

Also applies to: 4-5, 8-8


34-56: React 설정이 최신 개발 환경에 맞게 잘 구성되었습니다.

React 17+ 및 TypeScript 환경에 맞춰 불필요한 규칙들을 비활성화하고, 브라우저 환경 설정을 추가한 것이 적절합니다.


77-80: 적절한 무시 패턴이 설정되었습니다.

빌드 출력물, node_modules, 설정 파일들에 대한 표준적인 무시 패턴이 잘 설정되어 있습니다.


58-68: React Hooks 플러그인 타입 호환성 확인 필요

React Hooks 플러그인 설정이 잘 되어있지만, 타입 선언 파일의 호환성을 확인해야 합니다.

다음 명령어로 타입 호환성을 확인해주세요:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# React Hooks 플러그인의 타입 선언 확인
npm ls @types/eslint-plugin-react-hooks

# package.json에서 peerDependencies 확인
npm info eslint-plugin-react-hooks peerDependencies

Length of output: 232


React Hooks 플러그인 타입 호환성 검증 완료

• npm ls 결과, 별도의 @types/eslint-plugin-react-hooks 패키지가 설치되어 있지 않으나, 이는 해당 플러그인이 별도 타입 패키지를 요구하지 않음을 의미합니다.
• npm info 명령어를 통해 확인한 peerDependencies에서는 eslint의 특정 버전 요구사항만 명시되어 있어 타입 호환성에는 문제가 없습니다.

packages/switch/.storybook/main.ts (1)

5-5: Storybook 애드온 구성이 적절히 정리되었습니다.

온보딩 애드온을 제거하고 필수 애드온만 유지한 것이 좋습니다. 타입 안전성도 잘 유지되고 있습니다.

packages/checkbox/.storybook/main.ts (1)

5-5: 일관된 Storybook 구성 변경이 확인되었습니다.

다른 패키지들과 동일하게 온보딩 애드온이 제거되었습니다.

packages/icon/.storybook/main.ts (1)

5-5: Storybook 구성이 프로젝트 표준을 따르고 있습니다.

온보딩 애드온 제거가 일관되게 적용되었습니다.

packages/reset/.storybook/main.ts (1)

5-5: 모든 패키지의 Storybook 구성이 통일되었습니다.

불필요한 온보딩 애드온을 제거하고 핵심 기능만 유지하는 방향으로 잘 정리되었습니다.

packages/grid/.storybook/main.ts (1)

5-5: 온보딩 애드온 제거에 대한 검토가 필요합니다.

@storybook/addon-onboarding이 제거되었습니다. 새로운 개발자들을 위한 대체 문서나 가이드가 있는지 확인해주세요.

✅ Verification successful

🌐 Web query:

What are the alternatives to @storybook/addon-onboarding for documenting component usage?

💡 Result:

When looking for alternatives to Storybook's Addon Onboarding for documenting component usage, several robust tools emerge that cater to different needs in component documentation and development workflows:

## Core Alternatives
1. **Docz**  
Uses MDX (Markdown + JSX) to create interactive documentation with live component examples. Integrates seamlessly with design systems and supports CSS/SCSS styling[2][3].  

2. **React Styleguidist**  
Generates style guides by combining Markdown documentation with live component examples directly in your project environment[9]. Example setup:  
```javascript
// Example Styleguidist config
module.exports = {
  components: 'src/components/**/[A-Z]*.js',
  webpackConfig: { /* Custom config */ }
};
```

3. **Histoire**  
A modern Vite-based alternative offering faster build times and a clean interface for component showcases[9].

## Specialized Tools
- **Zeroheight/Supernova**:  
  Dedicated design system platforms with Figma sync, token management, and health tracking[5].  
- **React Docgen**:  
  Extracts component metadata (props, descriptions) into JSON for automated docs[2].  

## Lightweight Options
- **Vitebook**:  
  Minimal-config solution using your existing Vite setup for component demos[6].  
- **In-App Docs**:  
  Embed documentation directly into your app via `/docs` routes using custom components[6].  

| Tool              | Key Features                          | Best For                     |
|-------------------|---------------------------------------|------------------------------|
| Docz              | MDX support, live examples            | Full-featured docs           |
| React Styleguidist | Integrated dev environment            | Code-focused teams           |
| Histoire          | Vite speed, modern UI                 | Fast iteration               |
| Zeroheight        | Design system collaboration           | Enterprise-scale systems     |

For teams already using Storybook but seeking complementary tools, consider integrating **React Docgen** for auto-generated props tables or **Zeroheight** for centralized design system management[2][5]. Smaller projects may prefer Vitebook or in-app docs to avoid configuration overhead[6][9].

Citations:

- 1: https://github.com/storybookjs/addon-onboarding
- 2: https://dev.to/giteden/6-tools-for-documenting-your-react-components-like-a-pro-1gml
- 3: https://blog.logrocket.com/storybook-js-adoption-guide/
- 4: https://classic.yarnpkg.com/en/package/@storybook/addon-onboarding
- 5: https://hike.one/insights/the-best-tools-for-documenting-design-system
- 6: https://haspar.us/tiny-alternative-to-storybook/
- 7: https://storybook.js.org/docs/get-started/frameworks/react-vite
- 8: https://swimm.io/learn/documentation-tools/documentation-generators-great-tools-you-should-know
- 9: https://www.dhiwise.com/post/top-alternatives-to-storybook-to-streamline-development
- 10: https://storybook.js.org/blog/future-of-storybook-2024

온보딩 애드온 제거 관련 검토 결과

  • packages/grid/.storybook/main.ts 파일에서 @storybook/addon-onboarding이 제거되었음을 확인했습니다.
  • 외부 자료에 따르면 Docz, React Styleguidist, Histoire 등 여러 대안이 있으며, 이들 도구는 컴포넌트 문서화를 위한 대체 옵션으로 적합합니다.
  • 새로운 개발자들을 위한 가이드와 문서 작성 전략 마련을 위해 팀 내에서 위 도구들을 검토하는 것을 권장합니다.
.templates/component/.storybook/main.ts (1)

5-5: 템플릿 파일이 다른 컴포넌트 설정과 일관성이 있습니다.

다른 컴포넌트의 Storybook 설정과 동일한 구조를 유지하고 있어 적절합니다.

@froggy1014 froggy1014 merged commit 5d14250 into main Feb 10, 2025
3 checks passed
@froggy1014 froggy1014 deleted the chore/eslint-seperate-each-plugin branch February 10, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants