skip to Main Content
$ npm run lint
/Users/john/test/src/index.ts
  274:35  warning  'event' is defined but never used  @typescript-eslint/no-unused-vars

2

Answers


  1. The terminal isn’t smart enough to do that. For it to hyperlink straight to a location in a file, the path would have to be immediately followed by a colon and the location, i.e. /Users/john/test/src/index.ts:274:35.

    Instead, you might consider installing a plugin, or configuring an existing one, to show lint results in the Problems view. VSCode will then link straight to the location. I don’t have any recommendations since I don’t work in TypeScript myself, but FWIW, the Python extension can do that, for example with the Pylama linter enabled.

    Login or Signup to reply.
  2. You may want to use a different formatter to have the problems printed in a way that lets you open the respective lines by clicking on a link in the terminal.

    This should work out of the box:

    npx run lint -- --format=visualstudio
    

    and print

    /Users/john/test/src/index.ts(274,35): warning @typescript-eslint/no-unused-vars : 'event' is defined but never used
    

    Or this one:

    npx run lint -- --format=unix
    

    which prints

    /Users/john/test/src/index.ts:274:35: 'event' is defined but never used [Warning/@typescript-eslint/no-unused-vars]
    

    To avoid specifying the formatter manually every time, you could add them directly to the "lint" script defined in the file package.json, e.g.:

       "scripts": {
         ...
         "lint": "eslint . --format=visualstudio",
         ...
       },
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search