0

I want to create a custom WebStorm Filewatcher rule that performs prettier-eslint on save for the currently edited file. For my arguments, is there a way to declare that the command should be used for only the current edited file? You can see below for the file watcher rule I'm trying to create. Thanks!

enter image description here

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Jimmy
  • 3,090
  • 12
  • 42
  • 99
  • 1
    *"...should be used for only the current edited file?"* Please note: the File Watcher can be triggered for the externally modified file (that option is enabled on your screenshot) as well or even manually (by triggering the [Run File Watchers actions](https://stackoverflow.com/a/20012655/783119). Therefore the "currently edited file" has a very broad meaning here... – LazyOne May 12 '21 at 19:21
  • 1
    Anyway: **1)** just click on the `+` icon in the `Arguments` filed -- it will show all available macro (https://www.jetbrains.com/help/webstorm/new-watcher-dialog.html#ws_file_watcher_dialog_tool_to_run_on_changes), e.g. `$FileName$`, `$FileNameWithoutExtension$` -- this will point to a specific (current) file. **2)** You can use `Current File` **Scope** -- https://www.jetbrains.com/help/webstorm/using-file-watchers.html#ws_filewatcher_type_and_location_of_input_files – LazyOne May 12 '21 at 19:25
  • 1
    **P.S.** 1) Use absolute file path in the `Program` field. Internally (in the config file) the IDE will store such path relative to the project root. 2) You may want to disable "Auto-save edited file" option otherwise file watcher will be run automatically ~1sec after the last keypress, regardless if you finished working or just keep thinking on what to write next. – LazyOne May 12 '21 at 19:30

1 Answers1

0

The config below can be used to have the filewatcher watch only the current file.

enter image description here

Jimmy
  • 3,090
  • 12
  • 42
  • 99