eslint-plugin-react-hooks: rules-of-hooks misses early-return violations in components with CJK (non-ASCII) names, and false-positives force disabling it
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, react
調査の方向性
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react/react のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
docToolchain/docToolchain#1705 ·
-
Timezone select lists one option per character; duplicate "Failed" reason; shared tracker popover id オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nightscout/nocturne#1414 ·
-
bug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
modelcontextprotocol/inspector#2458 · コメント 1 件 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
carbon-design-system/ibm-products#9907 ·