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

Handle Syntax Error

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, node.js

調査の方向性

生成ファイルの SyntaxError を再現することから始め、node-source-map-support が通常の例外に対して現在どのように error.stack を処理しているかを調べます。生成された位置を含む最初のスタック行を追跡し、その後、SyntaxError の位置が既存の例外処理を変更せずに元のソースへ解決されることを確認します。

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

説明

First of all thank you for providing this project! It's a great help for my current project.

Regarding this issue: I would like to request that a special case be added that handles syntax errors so that the place of the original source is displayed when there is a syntax error in the generated file.

This is not very useful for projects like coffescript, typescript… which feature their own parsers (and thus do their own syntax error reporting); however it is useful for a use case like mine in which I just copy/past js source from one file into another where the input is not strictly tested for validity.

(I am building a tool that extracts examples from documentation and executes them as tests).

E.g. my errors are correctly resolved for normal exceptions, however when an (induced) syntax error happened, the output pasted below was the output. In there you can see the syntax error indicating the location in the generated file.

This could be solved by adding a special handler for syntax errors; extracting the generated location from the first line of error.stack…

/tmp/ferrum.doctest-ferrum.doctest-6d12dfba-331b-478f-94bf-862f4569da6/examples.test.js:10                                                  [158/14653]
    const foo = 42;
    ^^^^^

SyntaxError: Unexpected token 'const'
    at wrapSafe (internal/modules/cjs/loader.js:1050:16)
    at Module._compile (internal/modules/cjs/loader.js:1098:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/mocha.js:334:36
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/mocha.js:331:14)
    at Mocha.run (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/mocha.js:809:10)
    at Object.exports.singleRun (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/cli/run-helpers.js:108:16)
    at exports.runMocha (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/cli/run-helpers.js:142:13)
    at Object.exports.handler (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/lib/cli/run.js:292:3)
    at Object.runCommand (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/node_modules/yargs/lib/command.js:242:26)
    at Object.parseArgs [as _parseArgs] (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/node_modules/yargs/yargs.js:1087:28)
    at Object.parse (/home/karo/pr0j/adobe/ferrum.doctest/node_modules/mocha/node_modules/yargs/yargs.js:566:25)
主要言語
JavaScript
スター
2.2k
フォーク
221
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

evanw/node-source-map-support のほかの issue

evanw/node-source-map-support の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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