我正在尝试在PhpStorm中创建一个自定义文件监视器,它将在保存时自动修复ESLint错误.在“设置”中工具>文件监视器我使用以下设置创建了一个新的文件监视器:
>文件类型:任何
>范围:所有地方
>程序:/home/user/Projects/todo-app/eslint-autofix.sh
>参数:空白
>要刷新的输出路径:空白
>其他选项>工作目录:/ home / user / Projects / todo-app
eslint-autofix.sh:
#!/usr/bin/env bash ./node_modules/.bin/eslint --fix
然后我发出ESLint错误并按下Ctrl S保存.弹出以下错误:
/home/user/Projects/todo-app/eslint-autofix.sh /usr/bin/env: ‘node’: No such file or directory
如何解决这个错误?
解决方法
根据
this文章,设置应如下所示:
>文件类型:任何>范围:项目文件>程序:./ node_modules / .bin / eslint(如果需要,指定完整路径)>参数: – fix $FilePath $>刷新输出路径:$FileDir $