'How to setup a different path for ignored types for prettier file watcher in IntelliJ IDEA?

I have installed Prettier plugin in my IntelliJ IDEA and configured file watcher for it. At the beginning ignored types were defined in .prettierignore file in project root directory. However due to other plugins which also are using similar files to ignore, .prettierignore was moved to other directory with other config files and renamed: ./configs/.qualityignore.

Path in file watcher was updated appropriately. But due to some reason, when I use ctrl+alt+shift+P (plugin's key shortcut) Prettier besides to see path doesn't respect it and change ignored files.

File Watcher Settings
Program: $ProjectFileDir$\node_modules\.bin\prettier
Arguments: --write $FilePathRelativeToProjectRoot$ --ignore-path configs/.qualityignore
Output paths to refresh: $FilePathRelativeToProjectRoot$

Console output
cmd.exe /D /C call C:\Users\Bob\Projects\project-name\node_modules\.bin\prettier.cmd --write src\dashboard\common\ToolTipComponent.less.d.ts; --ignore-path configs\.qualityignore
[error] No matching files. Patterns tried: src\dashboard\common\ToolTipComponent.less.d.ts; !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**
Process finished with exit code 2

Is it a prettier plugin limitation/issue or I'm doing something wrong? Is there an other way to setup this updated path to Prettier plugin and it's file watcher?



Solution 1:[1]

Ok, I managed to solve this issue by myself, so now I would like to share my solution.

First of all - my File Watcher Settings were wrong. Correct version:
Program: $ProjectFileDir$\node_modules\.bin\prettier
Arguments: --write $FilePathRelativeToProjectRoot$ --ignore-path $ProjectFileDir$\configs\.qualityignore
Output paths to refresh:
Working directory: $ProjectFileDir$

Main changes:

  • a little bit different path for ignored files
  • no need any output paths to refresh
  • added working directory

If you have checked in Advanced options: Auto-save edited files to trigger the watcher, prettier will be fired every time when you will save your changes, so actually no need to use keyboard shortcut for Prettier: ctrl+alt+shift+P.

If for some reason you prefer to use keyboard shortcut and your file with ignored types is in the different location than root, in my opinion is better to uninstall Prettier plugin and create a new external tool with prettier script (you need to have installed prettier locally) and than you can give it whatever keyboard shortcut you want. I found this article really helpful in this matter: Run prettier in WebStorm or IntelliJ on Windows

Just in case, my settings to this second solution:
Program: $ProjectFileDir$\node_modules\.bin\prettier.cmd
Arguments: --write $FilePathRelativeToProjectRoot$ --ignore-path $ProjectFileDir$\configs\.qualityignore
Working directory: $ProjectFileDir$

IntelliJ IDEA version: 2021.2.3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rafal