rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
193 stars 29 forks source link

Print a message upon file watch trigger #188

Open mz8i opened 1 year ago

mz8i commented 1 year ago

Environment

Basic Description of the problem

It would be useful to output a log message when a file change is detected and linting is re-ran. Currently, there's only --clear but that obviously doesn't print anything. Printing a message on watch is rather standard practice, for example tsc --watch outputs [19:41:42] File change detected. Starting incremental compilation...

My particular use case and why this is not purely cosmetic is that I'm trying to use eslint-watch in VSCode to automatically detect linting problems in the whole workspace. Using problem matchers on terminal output, and specifically the Background / watching tasks functionality, you need to specify a regex pattern for where the output of a single re-run starts and where it ends. The end bit is simple, but the start is trickier without anything being printed; a regex to detect ANSI escape sequences doesn't seem to work.

The only change needed would be around https://github.com/rizowski/eslint-watch/blob/master/src/events/watch/index.js#L18

rizowski commented 1 year ago

I could see that being potentially useful. Just curious why you are using eslint-watch with VS-Code V.S. the supported eslint plugin for VS-Code? What is eslint-watch providing that the plugin doesn't?

mz8i commented 1 year ago

Interestingly, most plugins in VSCode like ESLint or Typescript don't provide whole-workspace analytics, they only list errors/warnings in open files (though the latter has an experimental feature for that, however the ESLint plugin maintainers don't seem like they're planning to implement something similar anytime soon). So using eslint-watch in a background task and extracting global problems from that is the best workaround for now, from what I can see.

mz8i commented 1 year ago

@rizowski any further thoughts? It seems the changes required are quite trivial, happy to submit a PR if you prefer to review