Skip to content

ESLintを設定する #17

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

Merged
merged 10 commits into from
Mar 8, 2025
Merged

ESLintを設定する #17

merged 10 commits into from
Mar 8, 2025

Conversation

XeicuLy
Copy link
Owner

@XeicuLy XeicuLy commented Mar 8, 2025

close #2

Summary by CodeRabbit

  • Chores
    • GitHub Actions のワークフローに ESLint チェックを追加し、品質管理を強化しました。
    • コード保存時に自動修正が適用される設定を導入し、開発体験を向上させました。
    • ESLint の設定および関連パッケージの更新により、コードの一貫性と保守性を改善しました。
    • 新しいスクリプトを追加し、Linting 機能を強化しました。

@XeicuLy XeicuLy added the 開発環境 開発環境の構築に関連する label Mar 8, 2025
@XeicuLy XeicuLy self-assigned this Mar 8, 2025
Copy link

coderabbitai bot commented Mar 8, 2025

"""

Walkthrough

この変更は、複数ファイルにわたって ESLint の統合を実施し、CI やローカル開発環境におけるコード品質チェックを強化しています。GitHub Actions の quality-check.yml に ESLint ジョブを追加し、ビルドジョブの依存関係に組み込むとともに、VSCode の設定で保存時に ESLint による自動修正が走るようにしました。また、ESLint の設定ファイル (eslint.config.mjs) や Nuxt 用設定 (nuxt.config.ts)、そして package.json で関連スクリプトおよび依存関係が追加・更新されています。

Changes

ファイル 変更内容
.github/workflows/quality-check.yml 新たな eslint ジョブの追加と、build ジョブの依存関係に eslint ジョブを追加
.vscode/settings.json "editor.codeActionsOnSave" 設定を追加し、ESLint の自動修正 (source.fixAll.eslint: "explicit") を有効化
eslint.config.mjs Vue.js と TypeScript 用の ESLint 設定、プラグイン、パーサーの導入
nuxt.config.ts ESLint 用 Nuxt モジュール (@nuxt/eslint) を modules 配列に追加
package.json ESLint 関連の新スクリプト、devDependencies の追加、および "packageManager": "[email protected]" の指定

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 開発者
    participant GH as GitHub Actions
    participant ESLint as ESLint チェック
    participant Build as ビルドプロセス

    Dev->>GH: コードをプッシュ
    GH->>ESLint: ESLint ジョブ実行
    ESLint-->>GH: チェック結果返送
    GH->>Build: Build ジョブ開始(依存関係チェック済み)
    Build-->>GH: ビルド完了
Loading
sequenceDiagram
    participant User as 開発者
    participant VSCode as VSCode
    participant ESLint as ESLint 自動修正

    User->>VSCode: ファイル保存
    VSCode->>ESLint: 自動修正実行要求
    ESLint-->>VSCode: 修正案適用
Loading

Possibly related PRs

  • 👷 ci: GitHub Actions追加 #15
    GitHub Actions の quality-check.yml における ESLint 統合変更と関連し、CI プロセスの強化が共通しています。

Poem

🐇 うさぎが跳ねる、コードの森で
🐇 ESLint の風がそよぎ、自動修正の魔法
🐇 プッシュすれば、チェックが走り
🐇 CI とエディタがハーモニー奏でる
🐇 新たな一歩に、未来の光を感じる
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between d11c638 and d7caec4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: XeicuLy
PR: XeicuLy/how-to-coding-vitest-for-nuxt#17
File: package.json:10-11
Timestamp: 2025-03-08T11:55:56.432Z
Learning: XeicuLyさんは、ESLintの警告の厳格なチェックをローカルスクリプトではなくGitHub Actionsで担保する方針を取っており、将来的にlint-stagedを追加して事前コミットチェックも強化する予定。
package.json (1)
Learnt from: XeicuLy
PR: XeicuLy/how-to-coding-vitest-for-nuxt#17
File: package.json:10-11
Timestamp: 2025-03-08T11:55:56.432Z
Learning: XeicuLyさんは、ESLintの警告の厳格なチェックをローカルスクリプトではなくGitHub Actionsで担保する方針を取っており、将来的にlint-stagedを追加して事前コミットチェックも強化する予定。
🔇 Additional comments (8)
package.json (8)

10-11: ESLint ローカルスクリプトの追加について
新たに "lint": "eslint ." および "lint:fix": "eslint . --fix" が追加されています。
GitHub Actionsでの厳格な警告チェック方針に沿っており、ローカル実行用の設定としては適切です。


14-14: ESLint 設定検査スクリプトの追加について
"eslint-rule-check": "npx @eslint/config-inspector" を追加することで、ESLint の設定状態を手軽に検査できるようになっています。
npx コマンドはプロジェクト内の依存関係を優先するため、既存の固定バージョン(1.0.2)も問題なく利用されると考えられます。


16-16: CI 用 ESLint スクリプトの追加について
"ci:eslint": "eslint ." が追加され、CI環境で ESLint チェックを実行する仕組みが整備されています。
この設定により、CI 上でのコード品質チェックが強化される点は良好です。


27-28: ESLint 関連依存パッケージの追加について
"@eslint/config-inspector": "1.0.2""@nuxt/eslint": "1.1.0" が devDependencies に追加されています。
これにより ESLint の構成検査や Nuxt との統合が強化され、プロジェクト全体の静的解析品質が向上します。


30-31: TypeScript および Vue 用 ESLint プラグインの追加について
"@typescript-eslint/parser": "8.26.0""@vue/eslint-config-prettier": "10.2.0" が追加され、TypeScriptの解析と Prettier との競合解消が図られています。
これにより ESLint の解析精度が向上するため、問題ありません。


35-36: ESLint 本体と globals の依存関係について
"eslint": "9.22.0""globals": "16.0.0" が適切なバージョンで追加されています。
これらは、ESLint の実行およびグローバル変数の管理に必要な依存関係として正しく設定されています。


38-40: Prettier、TypeScript、および vue-eslint-parser の更新について
"prettier": "3.5.3", "typescript": "5.8.2", および "vue-eslint-parser": "10.1.1" の追加により、ESLint と Prettier の連携がさらに強化されます。
これによりコードフォーマットと解析の一貫性が保たれるため、適切です。


53-54: Volta と packageManager の設定追加について
Volta セクションで Node.js と pnpm のバージョンが明示され、さらに "packageManager": "[email protected]" が追加されています。
これにより、パッケージマネージャーのバージョンが一貫して管理され、リポジトリの再現性が向上します。


🪧 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 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.

@XeicuLy XeicuLy changed the title Feature/add eslint ESLintを設定する Mar 8, 2025
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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 1e9d2c2 and d11c638.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • eslint.config.mjs (1 hunks)
  • package.json (3 hunks)
🔇 Additional comments (9)
package.json (3)

16-16: CIスクリプトに ESLint 追加は妥当です
CIパイプラインでリントを実行することで、コード品質が恒常的に保たれます。


52-53: pnpm のバージョン固定は管理の一貫性に寄与します
"pnpm": "9.15.7" としてバージョン指定するのは、開発環境の再現性確保に有効です。


27-27:

❓ Verification inconclusive

追加されたESLint関連の依存パッケージを一通り検証してください
複数のESLint拡張 / パーサが導入されていますが、互いのバージョン互換性や設定競合が生じていないかを確認することを推奨します。

以下のコマンドを実行すると依存関係の状況がわかります:

Also applies to: 29-30, 34-35, 37-39


🏁 Script executed:

#!/bin/bash
pnpm ls --depth=0

Length of output: 327


ESLint関連依存パッケージのバージョン互換性および設定競合の再確認をお願いします

実行された pnpm ls --depth=0 の結果から、以下のESLint関連パッケージが追加され、各バージョンも出力されていることを確認しました:

  • @nuxt/eslint 1.1.0
  • @typescript-eslint/parser 8.26.0 ※ ESLint 9.22.0との互換性について、公式ドキュメント等で再確認をお願いします
  • @vue/eslint-config-prettier 10.2.0
  • eslint 9.22.0
  • vue-eslint-parser 10.1.1

上記パッケージ同士やその他の依存関係(例:globals 等)との間で、バージョン互換性や設定競合が発生していないか、再度ご確認ください。

また、同様の検証は以下の箇所にも適用されます:

  • 行 29-30
  • 行 34-35
  • 行 37-39
eslint.config.mjs (6)

1-9: ESLint用のモジュールインポートは整合性があります
Vue / TypeScript での開発をサポートするパーサやプラグインが適切に追加されています。


11-14: ファイルパスを動的に取得する実装は問題ありません
__filename__dirname の扱いで、ESモジュール環境下でも正しいパスを得られます。


15-18: .cz-config.cts を無視する設定は妥当です
コミットメッセージ関連のファイルを除外することで、リント対象の誤爆を防げます。


31-85: インポート順序の厳密なルール設定は良好です
複数のグループ分けやアルファベットソートにより、可読性と保守性が向上します。


87-88: Prettier設定との競合がないか最終確認してください
vuePrettierConfig を追加することでフォーマットとLintが同居しますが、競合するルールがないか注意が必要です。


19-30:

❓ Verification inconclusive

パーサ設定と tsconfig.json の整合を確認してください
parserOptions.project によって TypeScript の型検証が行われるため、tsconfig.json の配置や設定が正しいかを再度ご確認ください。

下記コマンドで tsconfig.json の所在をチェックできます:


🏁 Script executed:

#!/bin/bash
fd tsconfig.json

Length of output: 53


注意: ESLint のパーサ設定と tsconfig.json の整合性の確認

  • eslint.config.mjs 内では、parserOptions.project./tsconfig.json を指定しており、リポジトリルートにある tsconfig.json が利用される設定になっています。
  • 実行された fd tsconfig.json の結果から、リポジトリルートの他に server/tsconfig.json も存在することが確認されました。想定している TypeScript 設定ファイルが正しく参照されているか、再度ご確認ください。

@XeicuLy XeicuLy merged commit 11eeafd into main Mar 8, 2025
6 checks passed
@XeicuLy XeicuLy deleted the feature/add-eslint branch March 8, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
開発環境 開発環境の構築に関連する
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESLintを追加する
1 participant