VSCode 使用 StandardJS 自動格式化代碼

1、安裝 StandardJS 擴展,從 VSCode 的 Extensions 中安裝。

2、安裝 StandardJS。-D 是隻安裝在本地文件夾。

npm install -D standard

3、在 VSCode 中禁用 JavaScript 驗證。在 VSCode 的 settings.json 文件中添加如下配置。

"javascript.validate.enable": false,

4、設置保存時自動按 StandardJS 規則調整代碼。在 VSCode 的 settings.json 文件中添加如下配置。

"editor.formatOnSave": true,

"standard.autoFixOnSave": true,

"standard.enable": true,

 5、在 .eslintrc 文件中添加配置。讓 ESLint 使用 Standard 規則。

"extends": [

   "standard"

],

6、重啓 VSCode 後生效。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章