如何在package-scripts.js中发表评论以显示在package.json中?

问题描述

目标

我想像这样在package-scripts.js显示来自package.json的nps命令的注释:

desired comment in package.json

尝试

我实际上不知道此叠加层的内容(“通过'npm test'命令运行”)是从哪里来的(vscode,npm,nps?)。我查找了他们所有的GitHub存储库,都没有成功。

我尝试通过以下方式添加评论,但没有结果:

// package-scripts.js  
module.exports = {
  scripts: {
    /** Build image */
    build: "docker build"
  }
}
// package.json
{
  scripts: {
    "build": "nps build"
  }
}

有可能吗?显示评论是如何制作的?

解决方法

这似乎适用于:

    vscode设置中的
  • json模式或
  • 在vscode中切换到jsonc模式

两者均在此处记录:https://code.visualstudio.com/docs/languages/json

我建议扩展package.json模式https://json.schemastore.org/package来满足您的需求,但是我对在vscode中显示注释作为工具提示没有任何经验。