Handle Syntax Error
还没有人认领这个 Issue。
评估
- 难度
- 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
evanw/node-source-map-support 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
evanw/node-source-map-support#344 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
evanw/node-source-map-support#343 ·
-
难度 3/5 1-2 天 新手友好度 35/100
evanw/node-source-map-support#337 ·
-
难度 4/5 3-5 天 新手友好度 20/100
evanw/node-source-map-support#333 ·
-
难度 4/5 3-5 天 新手友好度 28/100
evanw/node-source-map-support#330 · 2 条评论 · 9 个 reaction ·
查看 evanw/node-source-map-support 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
code-yeongyu/oh-my-openagent#10172 ·
维护者通常 1 天内回复
-
Phase 2 PSA Capability & Career Profile
难度 2/5 1-3 小时 新手友好度 62/100
bcgov/digital-journeys#2310 ·
-
难度 1/5 1 小时以内 新手友好度 82/100
nodejs/node#66743 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
OWASP/cve-lite-cli#1335 ·
维护者通常 1 天内回复
-
Channels status: needs triage
难度 2/5 1-3 小时 新手友好度 70/100
mastra-ai/mastra#27093 · 1 条评论 ·
维护者通常 1 天内回复