Skip to content

VuexとVue.jsを完全に削除#9095

Closed
komagata wants to merge 8 commits intomainfrom
chore/remove-checkable-js
Closed

VuexとVue.jsを完全に削除#9095
komagata wants to merge 8 commits intomainfrom
chore/remove-checkable-js

Conversation

@komagata
Copy link
Copy Markdown
Member

@komagata komagata commented Aug 26, 2025

以下の作業を実施:

  • check-stamp.jsからVuexストアの使用を削除
  • Vuex関連ファイル(check-store.js、checkable.js)を削除
  • 未使用のVueコンポーネント3ファイルを削除
  • app/views/companies/users/_user.html.slimのv-ifディレクティブをRubyの条件分岐に置き換え
  • WebpackのVue.js設定を削除
  • package.jsonからVue.js関連パッケージ(vue、vuex、vue-loader等)を削除

Summary by CodeRabbit

  • Refactor

    • クライアント側の状態管理(store/mixin)と関連するチェック機能・API連携を削除
    • 読み込みプレースホルダー、ページャー等のVue UIコンポーネントを削除
    • 一部表示制御をクライアント側(v-if)からサーバー側レンダリングへ移行
  • Style

    • Vueタグ入力ウィジェット用のSassスタイルを削除
  • Chores

    • Vue/Pug 関連の依存・Webpack/ESLint設定を除外、lint/formatスクリプトから .vue を除外
    • Select2 初期化とCSRFトークン取得処理の軽微な実装調整

以下の作業を実施:
- check-stamp.jsからVuexストアの使用を削除
- Vuex関連ファイル(check-store.js、checkable.js)を削除
- 未使用のVueコンポーネント3ファイルを削除
- app/views/companies/users/_user.html.slimのv-ifディレクティブをRubyの条件分岐に置き換え
- WebpackのVue.js設定を削除
- package.jsonからVue.js関連パッケージ(vue、vuex、vue-loader等)を削除
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 26, 2025

Walkthrough

Vue と Pug 関連のフロントエンド資産と設定を削除・簡素化。Vuex ストアと複数の Vue SFC/ミックスイン、Pug ローダー、関連依存を除去し、check-stamp.js の Vuex 依存を削除して一部処理を直接 DOM/vanilla JS に移行した。

Changes

Cohort / File(s) Summary of changes
チェック関連の削除/簡素化
app/javascript/check-stamp.js, app/javascript/check-store.js, app/javascript/checkable.js
check-stamp.js から Vuex import/dispatch を削除。check-store.jscheckable.js を削除(Vuex ストア、computed/methods、チェック関連のサーバ通信・UIロジックを撤去)。
Vue SFC(UI)削除
app/javascript/loading-list-placeholder.vue, app/javascript/loading-list-item-placeholder.vue, app/javascript/pager.vue
ローディングプレースホルダーとページャーの Vue コンポーネントを削除(テンプレート/スクリプトを除去)。
スタイル/インポート削除
app/javascript/stylesheets/shared/blocks/form/_vue-tags-input.sass, app/javascript/stylesheets/_common-imports.sass
Vue Tags Input 用の SASS を削除し、共通インポートから該当スタイルの import を除去。
Webpack / ローダー設定除去
config/webpack/environment.js, config/webpack/loaders/vue.js, config/webpack/loaders/pug.js
VueLoaderPlugin/vue-loader/pug-plain-loader の読み込みと登録を削除し、.vue/.pug のローダー設定を撤去。
パッケージ & Lint 設定更新
package.json, .eslintrc.json
vuepug 関連依存と eslint-plugin-vue を削除。lint/prettier スクリプトから .vue を除外し、.eslintrc.jsonplugin:vue/recommended を削除、browser 環境を追加。
サーバーサイド描画へ移行
app/views/companies/users/_user.html.slim
クライアント側 v-if をサーバー側 Ruby 条件 - if user.student_or_trainee に変更(条件をサーバー側で判定してレンダリング)。
DOMユーティリティ/CSRF/Select2 変更
app/javascript/js-select2.js, app/javascript/reaction.js
Select2 初期化を要素単位へ変更。reaction.js の CSRF 取得を jQuery から meta タグへ変更し、トークン未取得時は処理中止するガードを追加。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as ユーザー
  participant CheckStamp as check-stamp.js
  participant API as /api/checks
  participant DOM as DOM

  User->>CheckStamp: スタンプ操作クリック
  CheckStamp->>API: GET /api/checks?checkable_type=...&checkable_id=...
  API-->>CheckStamp: JSON 応答
  alt check present
    CheckStamp->>DOM: 直接 DOM を更新(checked 状態)
  else no check
    CheckStamp->>DOM: 直接 DOM を更新(unchecked→checked 等)
  end
  note right of CheckStamp #e6f4ea: Vuex dispatch 削除 — 直接 DOM 操作へ移行
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

雑事

Suggested reviewers

  • kushimegu
  • e-yanagita-gs
  • kitarou888

Poem

ふわふわ跳ねるうさぎの舞、古いコンポーネントは風に舞い、
スタンプは直にぽんと光る、コードは軽く、画面は晴れ。
ぴょんと喜ぶ小さな更新、春の草の匂いを運ぶよ 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8c58a37 and 8819452.

📒 Files selected for processing (1)
  • app/views/companies/users/_user.html.slim (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/views/companies/users/_user.html.slim
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/remove-checkable-js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions github-actions bot requested a review from okuramasafumi August 26, 2025 15:05
Vue.jsでしか使用していなかったpugとその関連パッケージを削除:
- Webpack設定からpugローダー設定を削除
- package.jsonからpug、pug-plain-loader、@prettier/plugin-pugを削除
Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/views/companies/users/_user.html.slim (2)

76-84: 「コメント」欄のゼロ判定が products を参照しており誤り

「コメント」の表示分岐で user.products.count.zero? を参照しているため、コメントが0でもプロダクト数に依存してリンク表示になる不具合が発生します。user.comments.count.zero? に修正してください。

適用差分:

-                  - if user.products.count.zero?
+                  - if user.comments.count.zero?

20-24: Vueの動的クラス束縛が残存(:class, roleClass/joiningStatusClass)し、Vue撤去後は機能しません

span(:class='["a-user-role", roleClass, joiningStatusClass]') は Vue の構文です。Vue を外した現状では期待するクラスが付与されず、スタイルや状態表示が崩れます。サーバー側でクラス名を決定するように置き換えてください。

最小修正案(ビューファイル側のみの変更例。後述のヘルパ実装が別途必要):

-                span(:class='["a-user-role", roleClass, joiningStatusClass]')
+                span class="a-user-role #{role_class(user)} #{joining_status_class(user)}"

補助ヘルパ(例。既存フロントのロジックに合わせてマッピングをご調整ください):

# app/helpers/users_helper.rb
module UsersHelper
  # 例: 役割に応じたクラス名を返す
  def role_class(user)
    # TODO: 旧Vue側のroleClassロジックに合わせて実装
    case user.role
    when 'student'  then 'is-student'
    when 'trainee'  then 'is-trainee'
    when 'graduate' then 'is-graduate'
    else ''
    end
  end

  # 例: 参加状況に応じたクラス名を返す
  def joining_status_class(user)
    # TODO: 旧Vue側のjoiningStatusClassロジックに合わせて実装
    user.respond_to?(:joining_status) ? "is-#{user.joining_status}" : ''
  end
end

必要であれば、旧Vue実装から正確な条件式の移植までこちらで対応します。

🧹 Nitpick comments (5)
app/views/companies/users/_user.html.slim (3)

4-4: 論理演算子の優先順位を括弧で明示してください(可読性のため)

現在の条件は Ruby の優先順位により current_user.mentor || (current_user.admin && user.student_or_trainee) と解釈されます。意図がそれで正しい場合でも括弧で明示すると保守性が上がります(挙動は不変)。

-      - if current_user.mentor || current_user.admin && user.student_or_trainee
+      - if current_user.mentor || (current_user.admin && user.student_or_trainee)

41-50: user.discord_profilenil の場合の安全性を確認してください

user.discord_profile.times_url / .account_name を直接参照しています。discord_profile が未設定のユーザーが存在し得るなら、&. の安全ナビゲーションでの防御を推奨します。仕様上必ず存在するならこのままで問題ありません。

候補:

-                      - if user.discord_profile.times_url
-                        = link_to user.discord_profile.times_url, class: 'a-meta'
+                      - if user.discord_profile&.times_url
+                        = link_to user.discord_profile&.times_url, class: 'a-meta'
...
-                          | #{user.discord_profile.account_name}
+                          | #{user.discord_profile&.account_name}

確認用の観点:

  • 既存DBに discord_profile 未設定ユーザーがいない前提か?
  • もし未設定があり得る場合、表示は非表示にするのか、ダミー表示にするのか?

52-104: 同一アソシエーションに対する .count の重複呼び出しが多く、描画1回あたりのクエリが増えます

各項目で .count を2回ずつ使用しているため、ユーザー1人あたり最大10回の COUNT クエリが発生し得ます(レイジーロード時)。局所変数に一度だけ代入して使い回すと、同一描画内の重複クエリを抑制できます。counter cache があればそれを使用してください。

例(方針のみ):

  • - reports_count = user.reports.count として使い回し
  • counter cache があれば user.reports_count を参照
  • 一覧画面なら N+1 回避のための preload/counter_cache を検討
package.json (2)

5-5: Prettier のグロブはクォートで囲んでおくとクロスプラットフォームで堅牢です(微調整)

現在の app/javascript/**/*.{js,jsx} はシェルによるグロブ展開に依存します。ESLint側と同様にクォートして揃えることをおすすめします(挙動は基本不変)。

-    "lint:prettier": "prettier app/javascript/**/*.{js,jsx} --check"
+    "lint:prettier": "prettier 'app/javascript/**/*.{js,jsx}' --check"

47-49: 依存関係と設定のクリーンアップ: Pug関連の削除検討

以下を確認・対応してください。

  • 不要依存の削除
    • package.json から以下の行を削除検討
      - "pug": "^3.0.3",
      - "pug-plain-loader": "^1.0.0",
      - "@prettier/plugin-pug": "^2.0.0",
  • Webpack 設定の整理
    • config/webpack/loaders/pug.js でまだ loader: 'pug-plain-loader' を参照しています。Pugテンプレートが一切使われていない場合は、当該ファイルの削除もしくは読み込み設定からの除外を行ってください 。
  • Prettier 設定の確認
    • .prettierrc*prettier.config.js(存在する場合)に plugin-pug の記述がないか確認し、不要であれば設定からも削除してください 。
  • ソース内の残存チェック
    • .vue/.pug ファイルや lang="pug" 記述がプロジェクト内に見当たらないことは既に確認済みです 。

以上の対応後、Pug関連の依存と設定が完全に削除され、ビルドやコードスタイルに影響がないことをご確認ください。

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5fb4026 and ba323d6.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (11)
  • app/javascript/check-stamp.js (0 hunks)
  • app/javascript/check-store.js (0 hunks)
  • app/javascript/checkable.js (0 hunks)
  • app/javascript/loading-list-item-placeholder.vue (0 hunks)
  • app/javascript/loading-list-placeholder.vue (0 hunks)
  • app/javascript/pager.vue (0 hunks)
  • app/javascript/stylesheets/shared/blocks/form/_vue-tags-input.sass (0 hunks)
  • app/views/companies/users/_user.html.slim (1 hunks)
  • config/webpack/environment.js (0 hunks)
  • config/webpack/loaders/vue.js (0 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (9)
  • app/javascript/stylesheets/shared/blocks/form/_vue-tags-input.sass
  • app/javascript/check-stamp.js
  • app/javascript/loading-list-item-placeholder.vue
  • config/webpack/environment.js
  • config/webpack/loaders/vue.js
  • app/javascript/check-store.js
  • app/javascript/pager.vue
  • app/javascript/loading-list-placeholder.vue
  • app/javascript/checkable.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (2)
app/views/companies/users/_user.html.slim (1)

52-54: サーバー側条件への切替は方針に合致しています

- if user.student_or_trainee.card-counts 全体をサーバー側で制御するのは、Vue撤去に伴う責務移行として妥当です。

package.json (1)

4-5: ESLint/Prettier の対象から .vue を外した変更は妥当です

Vue撤去に伴い .js/.jsx のみに絞るのは整合的です。

@komagata komagata removed the request for review from okuramasafumi August 26, 2025 15:14
Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
package.json (2)

7-63: config/webpacker.yml から .vue 拡張子設定を削除してください

Vue/Pug 系の依存を除去した後でも、Webpacker の設定に .vue 拡張子が残っているので、ビルド時に不要な処理が走る可能性があります。以下を修正してください。

  • config/webpacker.yml の 38 行目にある
      - .vue
    を削除

また、念のため他の設定ファイルやローダー定義に .pug や Vue 関連のリファレンスが残っていないか横断的にチェックしてください。


64-78: .eslintrc.json から Vue プラグイン設定を削除してください

CI が通らない原因は、devDependencies から eslint-plugin-vue を外したにもかかわらず、設定ファイルに以下が残っているためです。該当行を削除してください。

  • ファイル:.eslintrc.json
  • 行番号:5
  • 削除対象設定:"plugin:vue/recommended"
.eslintrc.json
-    "plugin:vue/recommended",

他の ESLint/Prettier 設定ファイル(.eslintrc*eslint.*.prettierrc*prettier.*)には Vue または Pug 関連の記述は検出されませんでした。問題が解消することを確認のうえ、再度 CI を実行してください。

🧹 Nitpick comments (1)
package.json (1)

67-67: @webpack-cli/serve は不要な依存のため削除を推奨

現状、本プロジェクトでは以下の理由により @webpack-cli/serve が利用されておらず、かつ互換性の面でリスクがあります。削除を検討してください。

  • dev サーバー起動は bin/webpack-dev-serverwebpack-dev-server@3)経由で行っており、webpack serve の呼び出しがスクリプト内に存在しません。
  • @webpack-cli/servewebpack-cli@4 用サブコマンドであり、現在の webpack-cli@3.3.12 とは組み合わせ非推奨です。

▼ 削除案(package.json の該当行を削除)

   "devDependencies": {
     "@babel/plugin-transform-nullish-coalescing-operator": "^7.22.11",
     "@babel/plugin-transform-optional-chaining": "^7.23.0",
-    "@webpack-cli/serve": "^2.0.1",
     "eslint": "^7.24.0",
     "eslint-config-prettier": "^8.2.0",
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba323d6 and 6c25c10.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • config/webpack/environment.js (0 hunks)
  • config/webpack/loaders/pug.js (0 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (2)
  • config/webpack/loaders/pug.js
  • config/webpack/environment.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (2)
package.json (2)

4-5: lint スクリプトのクォートをダブルクォートに統一しましょう

Windows 環境の npm-run* ではシングルクォートが解釈されないケースがあるため、以下のようにダブルクォートへ統一することをおすすめします。また、Prettier の glob もシェル展開に依存するため、こちらもダブルクォートで囲むほうが安全です。

–––––––––––––––––––––––––––––––––––––
最小修正例:

-  "lint:eslint": "eslint 'app/javascript/**/*.{js,jsx}' --max-warnings=0",
-  "lint:prettier": "prettier app/javascript/**/*.{js,jsx} --check"
+  "lint:eslint": "eslint \"app/javascript/**/*.{js,jsx}\" --max-warnings=0",
+  "lint:prettier": "prettier \"app/javascript/**/*.{js,jsx}\" --check"

より堅牢な例(シェル展開非依存/ESLint 推奨の --ext オプション使用):

-  "lint:eslint": "eslint \"app/javascript/**/*.{js,jsx}\" --max-warnings=0",
+  "lint:eslint": "eslint --ext .js,.jsx app/javascript --max-warnings=0",
-  "lint:prettier": "prettier \"app/javascript/**/*.{js,jsx}\" --check"
+  "lint:prettier": "prettier --check \"app/javascript/**/*.{js,jsx}\""

–––––––––––––––––––––––––––––––––––––

あわせてご確認ください

  • Vue を完全廃止している場合、config/webpacker.yml 等に残る .vue の設定も不要かもしれません。不要であれば削除をご検討ください。
  • 修正後、ローカル環境(Windows/macOS/Linux)で npm run lint:eslint および npm run lint:prettier が通ることを必ずご確認ください。

79-81: Node v20 と webpacker@5/webpack@4 の互換性確認(Yarn 利用)
package.jsonyarn.lock が存在するため、以下の手順でローカル/本番ビルドを確認してください。Node 20 では古いローダや watcher 周りで警告・エラーが出るケースがあるため、CI 通過に加え、実際に動くかを確実に担保しましょう。

  • Yarn を使った依存解決
  • ローカル/CI での検証例
#!/bin/bash
set -e

# Node/Yarn バージョン確認
node -v      # v20.x.x
yarn -v      # 1.x.x or 3.x.x など

# 依存関係のインストール(lockfileに厳密に従う)
yarn install --frozen-lockfile

# ESLint/Prettier を含む lint 実行
yarn lint

# Webpacker の本番ビルド確認
# (Rails 環境で必要に応じて Bundler 経由で実行)
RAILS_ENV=production bin/webpack

# 本番アセットプリコンパイル確認
bundle exec rails assets:precompile --trace

上記いずれもエラーなく完了すればマージ OK です。ステージング環境でもビルド・動作確認するとさらに安心です。

以下の変更を実施:
- .eslintrc.jsonからplugin:vue/recommendedを削除
- browser環境をESLint設定に追加してブラウザのグローバル変数を認識
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (3)
.eslintrc.json (3)

16-22: browser 環境の追加により一部 globals は冗長です(任意のクリーンアップ)

env.browser: truewindow/Event/FormData/FileReader などは既に定義されるため、個別の globals 指定は省略できます(fetch は残すのが無難)。設定の重複を避けるため、次のようなクリーンアップを検討してください。

   "globals": {
-    "window": true,
     "fetch": true,
-    "FileReader": true,
-    "Event": true,
-    "FormData": true
+    "FormData": true
   },

注: FormData は env.browser に含まれますが、古い ESLint/型定義環境での誤検知を避けたい場合は残しても問題ありません。必要に応じて完全削除も可能です。


24-26: ES 構文サポートの見直し(最新指定と JSX パースの明示化を推奨)

プロジェクトがモダン構文や JSX を扱う場合、ecmaVersionlatest にし、ecmaFeatures.jsx を明示するのが堅実です(現状 2020 固定)。副作用なく将来の構文を取り込みやすくなります。

   "parserOptions": {
-    "ecmaVersion": 2020
+    "ecmaVersion": "latest",
+    "sourceType": "module",
+    "ecmaFeatures": {
+      "jsx": true
+    }
   },

28-36: React 17+ の新 JSX Transform では react/jsx-uses-react は不要

extends: "plugin:react/jsx-runtime" を使う前提なら、react/jsx-uses-react は冗長です(React をスコープに入れなくても良いため)。ルール削除で設定を簡素化できます。

   "rules": {
     "no-unused-vars": [
       "error",
       {
         "args": "all",
         "argsIgnorePattern": "^_"
       }
     ],
-    "react/jsx-uses-react": "error",   
     "react/jsx-uses-vars": "error" 
   }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6c25c10 and df81f67.

📒 Files selected for processing (1)
  • .eslintrc.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (2)
.eslintrc.json (2)

12-15: browser 環境の追加は妥当です

ブラウザ向けフロントエンドのみを前提にする整理(Vue撤去)と整合しています。


8-10: eslint-plugin-react が package.json に存在することを確認しました

  • devDependencies"eslint-plugin-react": "^7.31.8" が含まれています。

.eslintrc.jsonplugins: ["react"] 設定はそのままで問題ありません。

Comment on lines 11 to 15
"env": {
"browser": true,
"jquery": true,
"node": true
},
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Aug 26, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

env.jquery の扱いを要確認

ESLint コアには jquery 環境は存在しません。プラグイン未導入だと「未定義の環境」として無視 or エラーになる可能性があります。もし jQuery を使っているだけであれば、環境ではなく globals$/jQuery を readonly で追加する方が無難です。

検証用スクリプト(eslint-plugin-jquery なしで env.jquery が有効かを確認):

プラグインに依存しない形へ置き換える差分例:

   "env": {
     "browser": true,
-    "jquery": true,
     "node": true
   },
   "globals": {
+    "$": "readonly",
+    "jQuery": "readonly",
     "fetch": true,
     "FormData": true
   },

🏁 Script executed:

#!/bin/bash
# .eslintrc.json がある前提で、ESLint が jquery 環境を認識しているか確認
# 代表的な JS ファイルを 1 つ指定(なければ空ファイルを一時作成)
target="$(fd -t f -e js | head -n1)"
if [ -z "$target" ]; then
  target=".tmp_eslint_probe.js"
  echo "/* probe */" > "$target"
fi

# 有効な設定を出力(エラーに 'Environment key "jquery" is unknown' が出ないか確認)
npx -y eslint --print-config "$target" >/dev/null
rc=$?
[ "$target" = ".tmp_eslint_probe.js" ] && rm -f "$target"
exit $rc

Length of output: 752


以下のスクリプトで .eslintrc.json を明示的に指定し、env.jquery が有効かどうか再検証してください。

この結果をもとに、env.jquery が未定義として扱われるかどうかをご確認ください。


🏁 Script executed:

#!/bin/bash
# リポジトリ内の .eslintrc.json を検出
config=$(fd -HI .eslintrc.json | head -n1)
if [ -z "$config" ]; then
  echo "Error: .eslintrc.json が見つかりませんでした" >&2
  exit 1
fi

# 検証対象の JS ファイルを取得。なければ一時ファイルを作成
target=$(fd -t f -e js | head -n1)
if [ -z "$target" ]; then
  target=".tmp_eslint_probe.js"
  echo "/* probe */" > "$target"
fi

# 明示的に --config を指定して ESLint の設定を出力
npx -y eslint --print-config "$target" --config "$config" >/dev/null 2>&1
rc=$?

# 一時ファイルをクリーンアップ
[ "$target" = ".tmp_eslint_probe.js" ] && rm -f "$target"

exit $rc

Length of output: 363


以下のスクリプトで、実際に .eslintrc.jsoneslint-plugin-jquery のプラグイン設定があるか、また package.json に依存が記述されているかを確認してください。


🏁 Script executed:

#!/bin/bash
# .eslintrc.json のパスを取得
config=$(fd -HI .eslintrc.json | head -n1)
if [ -z "$config" ]; then
  echo "Error: .eslintrc.json が見つかりませんでした" >&2
  exit 1
fi

echo "=== $config ==="
# ファイル全体を表示(plugin セクションを確認)
sed -n '1,200p' "$config"

echo
# package.json に eslint-plugin-jquery の依存があるかを検索
if [ -f package.json ]; then
  echo "=== package.json (eslint-plugin-jquery の依存確認) ==="
  grep -R '"eslint-plugin-jquery"' -n package.json || echo "eslint-plugin-jquery は見つかりませんでした"
else
  echo "Error: package.json が見つかりませんでした" >&2
  exit 1
fi

Length of output: 1063


要対応: .eslintrc.jsonenv.jquery は ESLint コア環境に存在せずエラーとなるため、削除しグローバル変数として定義してください。

現状、.eslintrc.json に jQuery 環境を有効化するプラグイン設定(eslint-plugin-jquery)がなく、実際に npx eslint --print-config 実行時に「環境キー ‘jquery’ が不明」となりプロセスが終了しています。以下のように修正をお願いします。

• 修正箇所

  • ファイル: .eslintrc.json
  • 該当行: 11–13 行目あたりの env セクション

• 修正例(diff)

   "env": {
     "browser": true,
-    "jquery": true,
     "node": true
   },
   "globals": {
+    "$": "readonly",
+    "jQuery": "readonly",
     "window": true,
     "fetch": true,
     "FileReader": true,
     "Event": true,
     "FormData": true
   },

この変更により、ESLint が jQuery のグローバル変数を正しく認識しつつ、未定義環境エラーを解消できます。

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"env": {
"browser": true,
"jquery": true,
"node": true
},
"env": {
"browser": true,
"node": true
},
"globals": {
"$": "readonly",
"jQuery": "readonly",
"window": true,
"fetch": true,
"FileReader": true,
"Event": true,
"FormData": true
},
🤖 Prompt for AI Agents
.eslintrc.json around lines 11–15: remove the non-existent "jquery" key from the
"env" section (causes ESLint unknown environment error) and instead declare
jQuery globals under a top-level "globals" section; add entries for "$" and
"jQuery" (set to "readonly" or true) so ESLint recognizes them without enabling
a nonexistent env or requiring eslint-plugin-jquery.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@CodeRabbit 修正しました。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@komagata ありがとうございます!ESLintの設定修正を確認いたしました。これでenv.jqueryによる「未定義環境」エラーが解消され、jQueryのグローバル変数が適切に認識されるようになります。


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

以下の変更を実施:
- js-select2.js: jQueryセレクタをquerySelectorAllに置き換え
- reaction.js: CSRFトークン取得をmeta要素から直接取得に変更
- .eslintrc.json: jquery環境設定を削除
Copy link
Copy Markdown

@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: 3

🧹 Nitpick comments (1)
app/javascript/reaction.js (1)

42-48: (任意)headers/credentials の整理

  • credentials: 'same-origin' は現在の Fetch 仕様ではデフォルトが same-origin のため省略可能です(方針として明示したい場合はそのままでOK)。
  • Request.JS へ移行した場合、'X-Requested-With'X-CSRF-Token は自動付与されるため手動指定は不要になります。(github.com, guides.rubyonrails.org)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between df81f67 and 44779e9.

📒 Files selected for processing (3)
  • .eslintrc.json (1 hunks)
  • app/javascript/js-select2.js (1 hunks)
  • app/javascript/reaction.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .eslintrc.json
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit configuration file

**/*.js: - どうしても避けられない時以外に新規にVue.js, Reactのコードを追加しない。

  • fetchメソッドの代わりにrequest.jsを使う。

Files:

  • app/javascript/js-select2.js
  • app/javascript/reaction.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test

Comment on lines +2 to +6
const select2Elements = document.querySelectorAll('.js-select2')
select2Elements.forEach(element => {
window.$(element).select2({
closeOnSelect: true
})
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Aug 26, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Turbo遷移でも確実に初期化されるようにし、二重初期化を防いでください

現在はDOMContentLoadedのみで初期化しているため、Turbo Drive 使用時にページ遷移後の再描画では Select2 が未初期化になる恐れがあります。また、同一ノードに対して複数回 .select2() が呼ばれると二重初期化になります。初期化関数を分離し、turbo:load/turbo:frame-load でも呼び出し、かつ data('select2') で多重初期化を回避するのを推奨します。必要なら jQuery の存在チェックも追加しておくと堅牢です。

適用例(該当範囲内を書き換え):

-document.addEventListener('DOMContentLoaded', () => {
-  const select2Elements = document.querySelectorAll('.js-select2')
-  select2Elements.forEach(element => {
-    window.$(element).select2({
-      closeOnSelect: true
-    })
-  })
-})
+function initSelect2() {
+  const nodes = document.querySelectorAll('.js-select2')
+  nodes.forEach((el) => {
+    const $ = window.$ || window.jQuery
+    if (!$) return
+    const $el = $(el)
+    if ($el.data('select2')) return // prevent double-init
+    $el.select2({ closeOnSelect: true })
+  })
+}
+
+document.addEventListener('DOMContentLoaded', initSelect2)
+document.addEventListener('turbo:load', initSelect2)
+document.addEventListener('turbo:frame-load', initSelect2)

Turbo Drive を採用しているかの確認用スクリプトです(Turbo を使っている場合は上記対応が必須になります)。


🏁 Script executed:

#!/bin/bash
# Turbo の利用状況を確認
rg -n -C2 -S -g '!**/node_modules/**' -e "@hotwired/turbo-rails" -e "turbo:load" -e "turbo:frame-load" -e "Turbo\\.visit" -e "data-turbo"

Length of output: 382


Turbo Drive 利用検出済み: Select2 初期化を Turbo イベントにもフックし、二重初期化を防止してください

以下の点を踏まえて、app/javascript/js-select2.js の初期化処理を修正してください。

  • 現状は DOMContentLoaded のみで初期化しているため、Turbo Drive ページ遷移後に Select2 が未初期化のまま残る可能性があります(他ファイルで turbo:load が使用されているのを確認済みです)
  • 同一要素に対して何度も .select2() を呼ぶと二重初期化となり、不具合やパフォーマンス低下を招きます

修正例

-function initializeSelect2() {
-  const select2Elements = document.querySelectorAll('.js-select2')
-  select2Elements.forEach(element => {
-    window.$(element).select2({
-      closeOnSelect: true
-    })
-  })
-}
-
-document.addEventListener('DOMContentLoaded', initializeSelect2)
+function initSelect2() {
+  const nodes = document.querySelectorAll('.js-select2')
+  nodes.forEach((el) => {
+    const $ = window.$ || window.jQuery
+    if (!$) return                      // jQuery がなければ何もしない
+    const $el = $(el)
+    if ($el.data('select2')) return      // 二重初期化を回避
+    $el.select2({ closeOnSelect: true })
+  })
+}
+
+// Turbo Drive でも確実に初期化
+document.addEventListener('DOMContentLoaded', initSelect2)
+document.addEventListener('turbo:load',     initSelect2)
+document.addEventListener('turbo:frame-load', initSelect2)
  • initSelect2 関数を切り出し、DOMContentLoadedturbo:loadturbo:frame-load の各イベントで呼び出す
  • window.$ または window.jQuery の存在チェックを追加し、非同期ロード時のエラーを防止
  • $el.data('select2') による二重初期化チェックを確実に行う

以上の対応により、Turbo ページ遷移後も確実に Select2 が初期化され、かつ不要な二重初期化が防止できます。

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const select2Elements = document.querySelectorAll('.js-select2')
select2Elements.forEach(element => {
window.$(element).select2({
closeOnSelect: true
})
function initSelect2() {
const nodes = document.querySelectorAll('.js-select2')
nodes.forEach((el) => {
const $ = window.$ || window.jQuery
if (!$) return // jQuery がなければ何もしない
const $el = $(el)
if ($el.data('select2')) return // 二重初期化を回避
$el.select2({ closeOnSelect: true })
})
}
// Turbo Drive でも確実に初期化
document.addEventListener('DOMContentLoaded', initSelect2)
document.addEventListener('turbo:load', initSelect2)
document.addEventListener('turbo:frame-load', initSelect2)
🤖 Prompt for AI Agents
In app/javascript/js-select2.js around lines 2 to 6, the current initialization
runs only on DOMContentLoaded and may miss Turbo Drive page/frame loads and can
double-initialize Select2; refactor by extracting an initSelect2 function that
first verifies window.$ or window.jQuery exists, then iterates
document.querySelectorAll('.js-select2') and for each element gets a jQuery
wrapper and checks wrapper.data('select2') to skip elements already initialized
before calling .select2({ closeOnSelect: true }); finally, call initSelect2 on
DOMContentLoaded, and also attach it to the turbo:load and turbo:frame-load
events so Select2 is reliably initialized after Turbo navigations without
causing double initialization.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@CodeRabbit このサイトではTurbo Driveは使っていません。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@komagata 了解しました。Turbo Driveを使用していないとのことでしたら、turbo:loadturbo:frame-loadのイベントリスナーは不要ですね。

現在のコードはDOMContentLoadedで適切に初期化されているので、基本的には問題ありません。二重初期化の防止については、このスクリプトが複数回実行される可能性がある場合のみ考慮すれば十分です。

現在の実装で特に問題が発生していなければ、そのままで大丈夫です。


✏️ Learnings added
Learnt from: komagata
PR: fjordllc/bootcamp#9095
File: app/javascript/js-select2.js:2-6
Timestamp: 2025-08-26T16:37:21.463Z
Learning: このサイト(bootcamp)ではTurbo Driveは使用していない。

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

CSRFトークンが見つからない場合の処理を修正:
- undefinedがX-CSRF-Tokenヘッダーに設定されることを防止
- CSRFトークンが見つからない場合は早期リターンでリクエストを中止
- エラーログを出力して問題を特定しやすくする
webpackエラーを修正:
- _common-imports.sassから削除済みのvue-tags-input.sassのimportを削除
- webpackビルドが正常に完了するようになった
Userモデルのメソッド名がstudent_or_trainee?(クエスチョンマーク付き)なのに
テンプレートでstudent_or_traineeとして呼び出していたエラーを修正。
@komagata komagata closed this Aug 27, 2025
@komagata komagata deleted the chore/remove-checkable-js branch August 27, 2025 17:43
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.

1 participant