Cách sửa lỗi xung đột giữa VSCode organizeImports và Prettier

Đăng ngày 02 May 2022 05:52

Extension Prettier bị xung đột với cài đặt organizeImports trong VSCode khi bật tính năng tự động sắp xếp import khi lưu file.

xung đột organizeImports với prettier

Cách sửa lỗi xung đột giữa VSCode organizeImports và Prettier

Mở VSCode: Chọn View > Command Palette... > Nhập Preferences: Open Settings (JSON) và chỉnh sửa cấu hình như bên dưới:

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
   "source.fixAll.eslint": true,
   "source.organizeImports": true
},
"eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
],
"editor.formatOnSave": true