原理很简单,利用插件监听文件发现不合规范的自动更新即可。

有两步

1、打开webstorm,在Preferences中点选plugins,检查File Watchers是否已经安装

2、再次去到Preferences,在Preferences中点选Tools,找到File Watchers项,增加一个监听的任务。

按如下配置项进行配置:

File type: Any (or JavaScript)
Scope: Project files
Program: $ProjectFileDir$/node_modules/.bin/eslint
Arguments: --fix $FilePath$
Output paths to refresh: $FileDir$

点击确定即可生效。

参考:https://stackoverflow.com/questions/46641682/how-to-configure-eslint-auto-fix-on-save-in-webstorm-phpstorm

更多推荐