Skip to content

Instantly share code, notes, and snippets.

@productdevbook
Last active May 16, 2025 14:06
Show Gist options
  • Save productdevbook/4c5ac5df50244736fb910b469c23d55d to your computer and use it in GitHub Desktop.
Save productdevbook/4c5ac5df50244736fb910b469c23d55d to your computer and use it in GitHub Desktop.
vscode

🧠 VSCode Tip: Format Current File with ESLint (No Plugin Needed)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment