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

How line and column of `SourceNode` instance related to the contained chunk(s)?

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
documentation

調査の方向性

SourceNode API とリンクされている source-map PR #163 から始めてください。chunk に改行が含まれる場合にコンストラクターの行と列の値がどのように扱われるかを確認し、観察された動作と複数行の chunk に対する推奨される扱いを文書化してください。

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

説明

Working on the PR that enables support of source-maps for peggyjs parsers I found that high-level SourceNode API is not documented enough. In particular, it is non-obvious would SourceNode constructor automatically recalculate lines if chunk parameter is a multi-line string?

I have the following simplified code for generating source-map:

let userSourceCodeInGrammar = `potentially
   multi
   line
   string`;
// Actual SourceNode used for mapping is behind a hierarchy of SourceNodes
let node = new SourceNode(
  null, null, grammarSource,
  [
    "some code before",
    // actual mapping
    new SourceNode(
      line, column, grammarSource,
      userSourceCodeInGrammar
    ),
    "some code after",
  ]
);

let { code, map } = node.toStringWithSourceMap();

In the result, the code contains content of the userSourceCodeInGrammar as-is, but map maps all strings in it to the (line, column) supplied to the SourceNode constructor.

How to correctly work with multi-line code chunks?

主要言語
JavaScript
スター
3.7k
フォーク
370
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

mozilla/source-map のほかの issue

mozilla/source-map の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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