You can run eslint --fix on the currently open file in VSCode without using the ESLint extension by combining a task and a custom shortcut.
Create a .vscode/tasks.json file in your project and add the following:
pnpm install -g eslint
{
"version": "2.0.0",
"tasks": [
{
"label": "eslint-fix-current-file",
"type": "shell",
"command": "eslint --fix ${file}",
"problemMatcher": [],
"presentation": {
"reveal": "silent"
}
}
]
}Then open the Command Palette (Ctrl+Shift+P), search for Preferences: Open Keyboard Shortcuts (JSON), and add this:
{
"key": "cdm+k",
"command": "workbench.action.tasks.runTask",
"args": "eslint-fix-current-file",
"when": "editorTextFocus"
}Now when you press cdm+k, ESLint will fix only the current file — no extensions required.
✅ Works great with JS, TS, Vue, React
⚙️ Make sure ESLint is installed and properly configured
🛠️ Uses npx, so no global install required
🧼 Clean, focused, extension-free workflow