如何调试 angular 项目中损坏的 ng lint

Ani*_*pta 3 typescript tslint angular

在我的 angular 应用程序中,当我运行 nglint 时,我得到了这个异常

    Cannot read property 'check-regex' of undefined

[error] TypeError: Cannot read property 'check-regex' of undefined

    at Rule.getRuleOptions (node_modules\tslint\lib\rules\maxLineLengthRule.js:51:72)
    at Rule.isEnabled (node_modules\tslint\lib\rules\maxLineLengthRule.js:39:26)
    at Object.loadRules (node_modules\tslint\lib\ruleLoader.js:48:22)
    at Linter.getEnabledRules (node_modules\tslint\lib\linter.js:232:29)
    at Linter.lint (node_modules\tslint\lib\linter.js:107:33)
    at _lint (node_modules\@angular-devkit\build-angular\src\tslint\index.js:146:20)
    at async _run (node_modules\@angular-devkit\build-angular\src\tslint\index.js:60:29)
Run Code Online (Sandbox Code Playgroud)

有人知道如何调试吗。有没有办法像我们做代码(c#、javascript)一样调试它。

yur*_*zui 5

在浏览器中调试

打开Chrome浏览器(如果没有,请先安装)

Chrome 会自动打开浏览器,您可以像在浏览器中一样调试您的问题。

在此处输入图片说明

在 VS Code 中调试

  • 打开(或创建第一个)launch.json文件

  • 添加以下配置:

    {
      "type": "node",
      "request": "launch",
      "name": "Debug lint",
      "program": "${workspaceFolder}\\node_modules\\@angular\\cli\\bin\\ng",
      "cwd": "${workspaceFolder}",
      "args": ["lint"],
      "console": "integratedTerminal"
    }
    
    Run Code Online (Sandbox Code Playgroud)
  • node_modules\tslint\lib\rules\maxLineLengthRule.js:51:72那里放置断点

  • 运行调试 lint 配置

VS 代码应该命中该断点,您将能够对其进行调试。

在此处输入图片说明