Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

eslint-plugin-react-hooks: rules-of-hooks misses early-return violations in components with CJK (non-ASCII) names, and false-positives force disabling it

オープン
#37,665 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, react
領域
frontend, tooling

調査の方向性

Start with the rules-of-hooks component-detection heuristic in eslint-plugin-react-hooks and reproduce the minimal example using the CJK component name. Compare diagnostics with the ASCII-named version, including both the missed early-return violation and the reported false positives. Done means non-ASCII component names receive the expected hook-order diagnostics without forcing unrelated functions to be treated as components.

索引モデルが issue の本文から書いたものです。

説明

What version of eslint-plugin-react-hooks are you using?

7.0.0 (also reproducible on earlier versions)

What do you expect to happen?

react-hooks/rules-of-hooks should flag hook calls that appear after an early return inside a component whose name contains non-ASCII (CJK) characters — the same way it does for ASCII-named components.

What actually happens?

When the component name is a CJK identifier (common in our Chinese-language codebase), rules-of-hooks produces no diagnostics for early-return-followed-by-hooks. Worse, enabling the rule yields hundreds of false positives that look like "hook called outside a component" — presumably because the plugin's component-detection heuristic doesn't recognize non-ASCII function names as components.

This forced us to disable rules-of-hooks entirely, which removed static protection for exactly one class of real bug we shipped to production: a useCallback added after a loading-state early return crashed with React error #310 ("Rendered more hooks...") on the first render where the condition flipped. tsc and our eslint setup (rule off) could not catch it.

Reproduction
// 中文组件名 — rules-of-hooks stays silent on the violation below
export default function 双池视图() {
    const [切面, 设置切面] = useState<切面>('有待办');
    const [载荷, 设置载荷] = useState<载荷 | null>(null);
    if (三池查询.isPending || !载荷) return <p>正在读取…</p>;   // early return
    const 店名 = useCallback((id: number) => ids[id] ?? `店铺 ${id}`, []); // ← not flagged
    ...
}

Compare: renaming the component to PoolView makes the rule flag the useCallback after the early return as expected. A minimal standalone repro is available if useful.

Request

Support non-ASCII (at least CJK) identifiers in the component-detection heuristic used by rules-of-hooks, or expose an option to treat "hook called in a function whose name starts with use / a top-level function in a component module" as a component regardless of name script.

主要言語
JavaScript
スター
251k
フォーク
51.4k
平均マージ
2日 4時間
マージ済み PR(30日)
50

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react/react のほかの issue

react/react の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。