no-ad-hoc-jsonl-parser: isLineSource doesn't traverse ConditionalExpression, missing live ad-hoc parse in conclusion_admission.c
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- eslint, github-actions, typescript
- 領域
- tooling
調査の方向性
eslint-factory/src/rules/no-ad-hoc-jsonl-parser.ts と no-ad-hoc-jsonl-parser.test.ts のテストから始め、isLineSource() と fromLine() が条件式をどのように解決するかを追ってください。issue に記載された合成の有効ケースと無効ケースを追加し、その後、ルールのテストを実行して actions/setup/js/conclusion_admission.cjs をこのルールで確認してください。目標は、三項演算子で分割するケースが報告され、無関係なドキュメント配列は警告されないことです。
索引モデルが issue の本文から書いたものです。
説明
Summary
no-ad-hoc-jsonl-parser's isLineSource() helper (eslint-factory/src/rules/no-ad-hoc-jsonl-parser.ts:76-98) only resolves a variable's "line-ness" through one hop of identifier-to-initializer resolution (Identifier → initializer()) and through a small whitelist of chained CallExpression methods (split, filter, slice, reverse, toReversed). It never unwraps a ConditionalExpression (ternary) to check whether either branch is itself a line source. Any line array built behind a ternary — a very ordinary "empty vs. split" guard — escapes detection entirely, including when it is subsequently JSON.parse'd per-element, which is exactly the ad-hoc-parsing idiom this rule exists to catch.
Live, grounded false negative
actions/setup/js/conclusion_admission.cjs:50-54:
const lines = compact.session === "" ? [] : compact.session.split("\n");
if (lines.at(-1) === "") lines.pop();
if ((!compact.session.endsWith("\n") && compact.session !== "") || lines.length !== compact.included_events) throw new AdmissionError();
try {
const projected = compactUnifiedSession(lines.map(line => JSON.parse(line)));
This is a manual split-by-newline followed by .map(line => JSON.parse(line)) — the canonical pattern the rule is designed to flag (compare to the rule's own invalid test case const lines = text.split((r/redacted)?\n/); ... JSON.parse(line)). It is not wrapped by iterateJsonl/iterateJsonlEvents/JsonlParser from jsonl_helpers.cjs, yet the rule produces zero diagnostic here.
Root cause
Tracing lines in isLineSource():
linesis anIdentifier→initializer(node)returns itsVariableDeclaratorinit, which is theConditionalExpressioncompact.session === "" ? [] : compact.session.split("\n").isLineSource(conditionalExpr)hitsif (node.type !== "CallExpression") return false;(line 83) immediately, sinceConditionalExpressionis neitherIdentifiernorCallExpression.- Because
isLineSource(lines)isfalse, theCallExpressionvisitor'slineArraycheck forlines.map(...)(arrayCallbacks.has("map") && isLineSource(node.callee.object)) never markslineas a line binding, so the laterJSON.parse(line)inside the map callback is never reported.
The same gap applies to fromLine() (used for the Program:exit cross-call propagation pass), which also only descends through Identifier/ArrayExpression/MemberExpression(computed)/a small CallExpression method whitelist — no ConditionalExpression handling there either.
Proposed fix
In isLineSource() (and ideally the equivalent place in fromLine()), add a branch: if (node.type === "ConditionalExpression") return isLineSource(node.consequent, seen) || isLineSource(node.alternate, seen);. This directly fixes the cond ? [] : x.split("\n") idiom; an empty-array consequent is harmless since an empty array can't ever actually be the source of a flagged JSON.parse call.
Acceptance criteria
-
isLineSource()recognizes aConditionalExpressionas a line source when at least one branch resolves to a line source (via recursiveisLineSourceonconsequent/alternate). - New invalid test case reproducing the live shape:
const lines = cond ? [] : text.split("\n"); lines.map(line => JSON.parse(line));must reportadHoc. - A valid-case test confirms a
ConditionalExpressionwhere neither branch is a line source (e.g.cond ? documents : otherDocuments) is still not flagged. -
conclusion_admission.cjs:54is verified to now be caught after the fix (run against the real file, not just the synthetic test). - No existing passing test in
no-ad-hoc-jsonl-parser.test.tsregresses.
Scope note
Out of scope for this issue: fixing conclusion_admission.cjs itself (app code, not rule code) — this is purely about closing the detection gap in the ESLint rule so a future regression or similar idiom elsewhere is caught.
Generated by 🤖 ESLint Refiner · claude · agent · 99.9 AIC · ⌖ 0.868 AIC · ⊞ 6K · ◷
Work6b99120dce1d760d9b16b2c32e2b3939143961ca50ff5820849e9da583d8e97f· Claimc_2d1370e23519794ff88ba3c5ce7e17ee202e9a6904e679f8ad827e073d503dae_3
- expires on Oct 28, 2026, 8:03 PM UTC-08:00
- 主要言語
- Go
- スター
- 5.4k
- フォーク
- 596
- 平均マージ
- 3時間 37分
- マージ済み PR(30日)
- 833
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/gh-aw のほかの issue
-
automated-analysis code-quality cookie testing
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
wgdonenotdeferred: parenthesized Done() statement escapes non-deferred detection (paren_unwrap_gap)オープンcookie sergo
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 5/5 1週間以上 初心者へのやさしさ 24/100
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
prime-radiant-inc/evener#5028 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
[BUG] v4.2.9 PostgreSQL 启动迁移失败:DROP INDEX CURRENT_SCHEMA() 语法错误対応中かも @renovate が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenListTeam/OpenList#3267 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
openpubkey/opkssh#670 ·
メンテナーはふだん 1 日以内に返信