VS Code ESLint Cheat Sheet
Sidebar
Programming · VS Code ESLint Cheat Sheet
The ESLint extension's settings and commands, plus the ESLint config file, inline comments and command line. Checked against the extension (3.0.34) installed here and ESLint's documentation. Sheet 17 in the VS Code series.
Setup & Commands
Extension IDdbaeumer.vscode-eslint (version 3.0.34 here); it uses the ESLint installed in your projectnpm init @eslint/configCreate a starter config file and install what it needsESLint: Fix all auto-fixable ProblemsCommand Palette: apply every automatic fix in the current fileESLint: Create ESLint configurationCommand Palette: start the config wizardESLint: Show Output ChannelOpen the extension's log: the first place to look when linting failsESLint: Restart ESLint ServerRestart after installing ESLint or editing the configESLint: Revalidate all open filesRe-run the linter on everything that is openESLint: Migrate SettingsConvert older eslint.autoFixOnSave-style settings to the current onesCtrl+. / F8 / Ctrl+Shift+MQuick fix / next problem / Problems panelCore Extension Settings (eslint.*)
eslint.enableTurn the extension on or off (default true)eslint.runLint onType (default) or onSaveeslint.validateLanguage IDs to lint; empty (default) means detect automaticallyeslint.probeLanguage IDs the extension checks for ESLint support (default includes JavaScript, TypeScript, Astro and more)eslint.quietShow errors only, hide warnings (default false)eslint.ignoreUntitledSkip files not yet saved (default false)eslint.onIgnoredFilesoff (default) or warn: warn when a file is ignored by ESLinteslint.problems.shortenToSingleLineUnderline only the first line of a multi-line problem (default false)eslint.packageManagernpm (default), yarn, pnpm: used to find ESLinteslint.nodePathFolder added to NODE_PATH when looking for ESLinteslint.runtime / eslint.execArgvWhich Node program runs ESLint, and extra arguments for it (such as a memory limit)eslint.nodeEnvValue of NODE_ENV while linting (default none)eslint.debug / eslint.trace.serverDebug output and tracing of the language server (defaults off)Configuration Discovery
eslint.useFlatConfigForce the flat config format on or off; null (default) follows your ESLint version (needs ESLint 8.57 or later)eslint.experimental.useFlatConfigOlder switch for ESLint 8.21 to 8.56 only (default false)eslint.workingDirectoriesWhich folders count as project roots, e.g. [{ "mode": "auto" }]; important in monoreposeslint.optionsExtra options passed to ESLint like command-line flags, e.g. { "overrideConfigFile": "path" } (default {})eslint.useESLintClassUse the newer ESLint class API with older ESLint versions (default false)eslint.useRealpathsResolve symlinks to real paths (default false)Fix on Save
editor.codeActionsOnSave{ "source.fixAll.eslint": "explicit" }: run ESLint fixes when you savevaluesexplicit (only when you save yourself), always (also on auto save), nevereslint.codeActionsOnSave.modeall (default) fixes everything fixable; problems fixes only reported problemseslint.codeActionsOnSave.rulesLimit save-time fixes to chosen rules (default: all rules in your config)eslint.codeActionsOnSave.optionsExtra ESLint options for save-time fixes (default {})eslint.format.enableUse ESLint as the document formatter (default false)eslint.autoFixOnSaveOld way to fix on save (default false); use editor.codeActionsOnSave insteadeslint.migration.2_xon (default): let Migrate Settings offer to convert old settingsQuick Fix Menu & Severity
eslint.codeAction.disableRuleCommentOffer Disable rule for this line; default { "enable": true, "location": "separateLine", "commentStyle": "line" }eslint.codeAction.showDocumentationOffer Show documentation for rule (default { "enable": true })eslint.rules.customizationsChange how severe a rule looks in the editor only, e.g. { "rule": "no-console", "severity": "warn" }eslint.notebooks.rules.customizationsThe same, for text cells in notebooksPerformance, Tasks & Suppressions
eslint.timeBudget.onValidationTime allowed for linting before a warning / an error, in ms (default { "warn": 4000, "error": 8000 })eslint.timeBudget.onFixesThe same for computing fixes (default { "warn": 3000, "error": 6000 })eslint.lintTask.enableAdd a task that lints the whole workspace (default false)eslint.lintTask.command / lintTask.optionsThe command and arguments for that task (defaults eslint and .)eslint.bulkSuppression.enableShow bulk-suppressed violations from eslint-suppressions.json (default false; needs ESLint 10.1 or later)eslint.bulkSuppression.severityinfo (default), error, warn, hintConfig File (eslint.config.*)
File nameseslint.config.js, .mjs, .cjs, .ts, .mts, .cts in the project root (TypeScript needs jiti or Node 22.13+)StructureExport an array of config objects; defineConfig([ … ]) from eslint/config is the helperfiles / ignoresGlob patterns a config object applies to / excludesglobalIgnores([…])A config object with only ignores applies to the whole project, e.g. dist/extendsConfigs to build on, such as a plugin's recommended setlanguageOptionsecmaVersion, sourceType, globals, parser, parserOptionslinterOptionsreportUnusedDisableDirectives, noInlineConfig, reportUnusedInlineConfigsplugins / processor / settingsAdd plugins, a processor for non-JS files, and shared settingsrules{ "semi": ["error", "never"] }: a severity, optionally in an array with optionsSeverity values"off" or 0, "warn" or 1, "error" or 2Inline Comments
// eslint-disable-next-line ruleSkip a rule for the next line (omit the rule name to skip all rules)// eslint-disable-line ruleSkip a rule on this line/* eslint-disable rule */ … /* eslint-enable rule */Skip a rule for a block of code/* eslint-disable */At the top of a file: skip everything in it-- reasonAdd an explanation after two or more dashes, e.g. // eslint-disable-next-line no-alert -- demo only/* eslint rule: "error" */Set a rule's level in one filereportUnusedDisableDirectivesReports disable comments that no longer do anything (default warn)Command Line (npx eslint …)
. --fixLint the project and fix what can be fixed--max-warnings 0Exit with an error if there are any warnings (useful in CI)--cacheRemember results so the next run is faster--format jsonChoose an output format (also stylish, html)--config pathUse a specific config file--no-warn-ignoredDo not warn about files that are ignored--debugPrint detailed debugging output--print-config fileShow the settings ESLint would use for one fileA Reasonable Starter Set (my suggestions, not defaults)
"editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" }Fix on save without reformatting your code"eslint.run": "onType"Instant feedback (the default)"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }]Show every rule as a warning in the editor while learning"eslint.workingDirectories": [{ "mode": "auto" }]Helps when your project has several packageseslint-config-prettierAdd it to your config so ESLint does not fight Prettier over layoutESLint isn't doing anything? Check these in order
1) Is ESLint installed in the project (npm ls eslint)? The extension uses the project's copy. 2) Is there a config file (eslint.config.js or similar)? 3) Run ESLint: Show Output Channel: errors about the config or about a missing module show up there. 4) After installing or changing config, run ESLint: Restart ESLint Server. 5) In a project with several packages, set eslint.workingDirectories. 6) Make sure the language is covered by eslint.validate or eslint.probe.
ESLint and Prettier together
Let Prettier do the layout (spacing, line breaks) and ESLint find real problems. Use eslint-config-prettier to switch off the ESLint rules that would argue with Prettier, keep eslint.format.enable off, and use source.fixAll.eslint on save for ESLint's automatic fixes. With both on save, check the result once: the two should not keep changing each other's output.