### Install Dependencies Source: https://github.com/microsoft/vscode-eslint/blob/main/contributing.md Installs the necessary project dependencies using npm. ```bash npm ci ``` -------------------------------- ### Install ESLint Globally Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Install ESLint globally on your system using npm, yarn, pnpm, or bun. ```bash # npm npm install -g eslint ``` ```bash # yarn yarn global add eslint ``` ```bash # pnpm pnpm add -g eslint ``` ```bash # bun bun add -g eslint ``` -------------------------------- ### Launch Extension Source: https://github.com/microsoft/vscode-eslint/blob/main/contributing.md Starts the extension in debug mode using the 'Launch Extension' configuration. ```bash npm run launch ``` -------------------------------- ### Flat ESLint Configuration Example (eslint.config.js) Source: https://context7.com/microsoft/vscode-eslint/llms.txt Example of a modern ESLint configuration file using JavaScript and the flat config format, supporting ESLint 8.57+ and 9.x. Includes imports for recommended rules, TypeScript plugin, and parser. ```javascript // eslint.config.js import js from '@eslint/js'; import tsPlugin from '@typescript-eslint/eslint-plugin'; import tsParser from '@typescript-eslint/parser'; export default [ js.configs.recommended, { files: ['**/*.ts', '**/*.tsx'], languageOptions: { parser: tsParser, parserOptions: { project: './tsconfig.json' } }, plugins: { '@typescript-eslint': tsPlugin }, rules: { '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/explicit-function-return-type': 'warn' } }, { ignores: ['dist/**', 'node_modules/**'] } ]; ``` -------------------------------- ### Legacy ESLint Configuration Example (.eslintrc.json) Source: https://context7.com/microsoft/vscode-eslint/llms.txt Example of a legacy ESLint configuration file using JSON format. This is supported for ESLint versions prior to 8.57. ```json // .eslintrc.json { "env": { "browser": true, "es2021": true, "node": true }, "extends": [ "eslint:recommended" ], "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" }, "rules": { "indent": ["error", 2], "linebreak-style": ["error", "unix"], "quotes": ["error", "single"], "semi": ["error", "always"] } } ``` -------------------------------- ### Install ESLint Locally Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Install ESLint as a development dependency in your project using npm, yarn, pnpm, or bun. ```bash # npm npm install --save-dev eslint ``` ```bash # yarn yarn add --dev eslint ``` ```bash # pnpm pnpm add --save-dev eslint ``` ```bash # bun bun add --dev eslint ``` -------------------------------- ### Configure ESLint Node Path in Multi-Workspace Setup Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md When using a multi-workspace setup, define the `eslint.nodePath` in the `code-workspace` file. The extension warns users if this setting is not configured correctly in this context. ```json { "folders": [ { "path": "project-a" }, { "path": "project-b" } ], "settings": { "eslint.nodePath": "myCustomNodePath" } } ``` -------------------------------- ### Customize ESLint Rule Severities Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This example sets 'no-' rules to 'info', downgrades other rules, and resets 'radix' to its default severity. ```json "eslint.rules.customizations": [ { "rule": "no-*", "severity": "info" }, { "rule": "!no-*", "severity": "downgrade" }, { "rule": "radix", "severity": "default" } ] ``` -------------------------------- ### Enable Git Symbolic Link Support Source: https://github.com/microsoft/vscode-eslint/blob/main/contributing.md Enables Git to use symbolic links, which is required for the development setup. ```bash git config core.symlinks true ``` -------------------------------- ### Specify Node.js Runtime for ESLint Source: https://context7.com/microsoft/vscode-eslint/llms.txt Configure the Node.js runtime path that ESLint will use. This is useful for managing different Node.js versions or custom installations. ```json // settings.json - Use system node { "eslint.runtime": "node" } ``` ```json // settings.json - Use specific node version { "eslint.runtime": "/usr/local/bin/node18" } ``` -------------------------------- ### Configure Monorepo Working Directories Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Specify the working directories for ESLint in a monorepo setup. This setting is crucial for the extension to correctly identify and lint files across different packages. ```json "eslint.workingDirectories": [ "./client", "./server" ] ``` -------------------------------- ### Keep Specific TypeScript ESLint Rules on Save Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This example keeps the 'indent' and 'semi' rules from TypeScript ESLint, disables all other TypeScript ESLint rules, and keeps the rest. ```json "eslint.codeActionsOnSave.rules": [ "@typescript-eslint/semi", "@typescript-eslint/indent", "!@typescript-eslint/*", "*" ] ``` -------------------------------- ### Configure ESLint Language Probing Source: https://context7.com/microsoft/vscode-eslint/llms.txt An array of language identifiers for which the extension should probe if ESLint support is installed. If validation fails for probed languages, the extension stays silent. ```json // settings.json { "eslint.probe": [ "javascript", "javascriptreact", "typescript", "typescriptreact", "html", "mdx", "vue", "markdown", "json", "jsonc" ] } ``` -------------------------------- ### Configure ESLint Validation Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Specify which file types ESLint should validate by setting the 'eslint.validate' option in your VS Code settings. This example limits validation to JavaScript files. ```json "eslint.validate": [ "javascript" ] ``` -------------------------------- ### Configure ESLint Rules in VS Code Source: https://github.com/microsoft/vscode-eslint/wiki/Visual-Studio-Code:--Setting-up-ESLint-Rules-(Beginner's-Introduction) Use the 'eslint.options' setting to define custom ESLint rules. This example disables specific JSDoc validation errors and turns off the 'no-extra-parens' rule. ```json { "eslint.options": { "rules": { "valid-jsdoc": [ "error", { "requireParamDescription": false, "requireReturnDescription": false, "requireReturn": false } ], "no-extra-parens": 0 } } } ``` -------------------------------- ### Enable ESLint Debug Mode Source: https://context7.com/microsoft/vscode-eslint/llms.txt Enable `eslint.debug` to true for troubleshooting ESLint configuration issues within VS Code. This setting helps diagnose problems with how the extension is interpreting your ESLint setup. ```json // settings.json { "eslint.debug": true } ``` -------------------------------- ### Initialize ESLint Configuration Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Generate a starter ESLint configuration file for your project. This command is recommended for new projects or when migrating to flat config. ```bash npx eslint --init ``` -------------------------------- ### Run Watch Task Source: https://github.com/microsoft/vscode-eslint/blob/main/contributing.md Compiles the client and server components of the extension using the 'watch' task. ```bash npm run watch ``` -------------------------------- ### Configure ESLint Constructor Options Source: https://context7.com/microsoft/vscode-eslint/llms.txt Options passed to the ESLint class constructor, allowing custom configuration file paths and other ESLint options. ```json // settings.json - Use custom config file { "eslint.options": { "overrideConfigFile": "./custom/.eslintrc.json" } } ``` ```json // settings.json - Ignore specific patterns { "eslint.options": { "ignorePath": "./.custom-eslintignore" } } ``` -------------------------------- ### Create ESLint Configuration File Command Source: https://context7.com/microsoft/vscode-eslint/llms.txt Use the 'ESLint: Create ESLint configuration' command to automatically generate a new ESLint configuration file by running `eslint --init` in a terminal. ```plaintext ESLint: Create ESLint configuration - Opens a terminal and runs 'eslint --init' to create a new configuration file ``` -------------------------------- ### Enable/Disable ESLint Rule Documentation Links Source: https://context7.com/microsoft/vscode-eslint/llms.txt Configure whether the 'Show documentation' quick fix option is available for ESLint rules. This helps users quickly access rule information. ```json // settings.json { "eslint.codeAction.showDocumentation": { "enable": true } } ``` -------------------------------- ### Configure ESLint Working Directories Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Specify how ESLint determines its working directories to correctly resolve configuration files. This is crucial when dealing with monorepos or complex project structures. ```json { "eslint.workingDirectories": [ "./client", "./server" ] } ``` ```json { "directory": "./client", "!cwd": true } ``` ```json { "pattern": "./packages/*/" } ``` -------------------------------- ### Configure ESLint Working Directories for Monorepos Source: https://context7.com/microsoft/vscode-eslint/llms.txt Define working directories for ESLint to correctly resolve configuration files in multi-root workspaces or monorepos. Supports explicit paths, glob patterns, and auto-detection. ```json // settings.json - Specify explicit directories { "eslint.workingDirectories": [ "./client", "./server" ] } ``` ```json // settings.json - Use glob patterns for monorepo { "eslint.workingDirectories": [ { "pattern": "./packages/*/" } ] } ``` ```json // settings.json - Auto-detect based on config file locations { "eslint.workingDirectories": [ { "mode": "auto" } ] } ``` ```json // settings.json - Directory without changing process CWD { "eslint.workingDirectories": [ { "directory": "./client", "!cwd": true } ] } ``` -------------------------------- ### Migrate ESLint Settings Command Source: https://context7.com/microsoft/vscode-eslint/llms.txt Use the 'ESLint: Migrate Settings' command to automatically convert old `eslint.autoFixOnSave` settings to the newer `editor.codeActionsOnSave` format. ```plaintext ESLint: Migrate Settings - Migrates old eslint.autoFixOnSave settings to editor.codeActionsOnSave ``` -------------------------------- ### Enable ESLint Flat Config Source: https://context7.com/microsoft/vscode-eslint/llms.txt Controls whether ESLint should use flat config files (`eslint.config.js`). Honored for ESLint 8.57+ with different defaults based on version. ```json // settings.json - Force flat config { "eslint.useFlatConfig": true } ``` ```json // settings.json - Force legacy config { "eslint.useFlatConfig": false } ``` -------------------------------- ### Specify Custom ESLint Config and Ignore Files Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Use this setting to point to a custom .eslintrc.json file and a custom .eslintignore file when running the lint task for the whole workspace. ```json { "eslint.lintTask.options": "-c C:/mydirectory/.eslintrc.json --ignore-path C:/mydirectory/.eslintignore ." } ``` -------------------------------- ### Configure ESLint Time Budgets for Performance Source: https://context7.com/microsoft/vscode-eslint/llms.txt Set time budgets for ESLint validation and fix operations. Warnings or errors will be shown if these budgets are exceeded, helping to manage performance. ```json // settings.json { "eslint.timeBudget.onValidation": { "warn": 4000, "error": 8000 }, "eslint.timeBudget.onFixes": { "warn": 3000, "error": 6000 } } ``` -------------------------------- ### Pass Arguments to Node.js Runtime for ESLint Source: https://context7.com/microsoft/vscode-eslint/llms.txt Provide additional arguments to the Node.js runtime when ESLint is executed. This can be used for performance tuning, such as increasing the heap size. ```json // settings.json - Increase heap size { "eslint.execArgv": ["--max-old-space-size=4096"] } ``` -------------------------------- ### Configure Code Actions on Save for Semicolon Rules Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Use this setting to specify which rules should be applied on save, focusing only on semicolon-related rules. ```json "eslint.codeActionsOnSave.rules": [ "*semi*" ] ``` -------------------------------- ### Enable Workspace Linting Task Source: https://context7.com/microsoft/vscode-eslint/llms.txt Enable the `eslint.lintTask.enable` setting to activate a VS Code task for linting the entire workspace. You can also specify custom options for the task. ```json // settings.json { "eslint.lintTask.enable": true, "eslint.lintTask.options": "--ext .js,.jsx,.ts,.tsx ." } ``` -------------------------------- ### Enable ESLint as a VS Code Formatter Source: https://context7.com/microsoft/vscode-eslint/llms.txt Configure VS Code to use ESLint for formatting code. This allows ESLint's auto-fix capabilities to be used directly within the editor. ```json // settings.json - Enable ESLint formatter { "eslint.format.enable": true } ``` ```json // settings.json - Set ESLint as default formatter for JavaScript { "eslint.format.enable": true, "[javascript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" } } ``` ```json // settings.json - Set ESLint as default formatter for TypeScript { "eslint.format.enable": true, "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" } } ``` -------------------------------- ### Customize ESLint Rules for Notebook Cells Source: https://context7.com/microsoft/vscode-eslint/llms.txt Apply specific rule severities to text cells within VS Code notebook documents. This allows for tailored linting behavior in notebooks. ```json // settings.json { "eslint.notebooks.rules.customizations": [ { "rule": "no-unused-vars", "severity": "off" } ] } ``` -------------------------------- ### Configure ESLint Code Actions on Save Mode Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Control how ESLint fixes problems when saving files. 'all' fixes all possible problems, while 'problems' fixes only non-overlapping ones for faster execution. ```json { "eslint.codeActionsOnSave.mode": "all" } ``` ```json { "eslint.codeActionsOnSave.mode": "problems" } ``` -------------------------------- ### Specify Custom Node Modules Path for ESLint Source: https://context7.com/microsoft/vscode-eslint/llms.txt Use the `eslint.nodePath` setting to specify a custom directory where ESLint should resolve its modules. This is useful for monorepos or non-standard project structures. ```json // settings.json { "eslint.nodePath": "/custom/path/to/node_modules" } ``` -------------------------------- ### Configure Auto-Fix on Save Source: https://context7.com/microsoft/vscode-eslint/llms.txt Configure automatic fixing of ESLint errors when saving files using VS Code's code actions on save feature. ```json // settings.json - Fix all auto-fixable ESLint problems on save { "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" } } ``` ```json // settings.json - Fix all problems from all providers { "editor.codeActionsOnSave": { "source.fixAll": "explicit" } } ``` ```json // settings.json - Disable ESLint fix on save while keeping others { "editor.codeActionsOnSave": { "source.fixAll": "explicit", "source.fixAll.eslint": "never" } } ``` ```json // settings.json - Disable for specific language (HTML) { "[html]": { "editor.codeActionsOnSave": { "source.fixAll.eslint": false } } } ``` -------------------------------- ### Override ESLint Config with CLIEngine API Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Configure ESLint to use a custom .eslintrc.json file using the CLIEngine API. This is used when ESLint version 7.x is present and `eslint.useESLintClass` is false. ```json { "eslint.options": { "configFile": "C:/mydirectory/.eslintrc.json" } } ``` -------------------------------- ### Trace ESLint Server Communication Source: https://context7.com/microsoft/vscode-eslint/llms.txt Configure `eslint.trace.server` to trace communication between VS Code and the ESLint language server. Use 'messages' for basic tracing or an object for verbose JSON output. ```json // settings.json - Basic message tracing { "eslint.trace.server": "messages" } ``` ```json // settings.json - Verbose tracing with JSON format { "eslint.trace.server": { "verbosity": "verbose", "format": "json" } } ``` -------------------------------- ### Override ESLint Config with ESLint Class API Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Configure ESLint to use a custom .eslintrc.json file using the ESLint class API. Ensure the working directory is specified if using a relative path for the config file. ```json { "eslint.options": { "overrideConfigFile": "C:/mydirectory/.eslintrc.json" } } ``` -------------------------------- ### Enable Auto Fix on Save for All Providers Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration enables Auto Fix for all providers, including ESLint, using VS Code's `editor.codeActionsOnSave` setting. ```json "editor.codeActionsOnSave": { "source.fixAll": "explicit" } ``` -------------------------------- ### Override All ESLint Rules to Warnings Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration overrides all ESLint rules to have a severity of 'warn'. ```json "eslint.rules.customizations": [ { "rule": "*", "severity": "warn" } ] ``` -------------------------------- ### Enable ESLint Rule Disabling in Quick Fix Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md Configure the quick fix menu to show an option for disabling ESLint rules. You can choose to place the disable comment on the same line or a separate line. ```json { "enable": true, "location": "sameLine" } ``` -------------------------------- ### Enable ESLint Validation Source: https://context7.com/microsoft/vscode-eslint/llms.txt Controls whether ESLint validation is enabled for the workspace. When disabled, no linting occurs. ```json // settings.json { "eslint.enable": true } ``` -------------------------------- ### Configure ESLint Disable Rule Comment Format Source: https://context7.com/microsoft/vscode-eslint/llms.txt Control the format and placement of comments generated when disabling ESLint rules via quick fixes. Options include line or block comments and insertion on the same or separate line. ```json // settings.json - Insert on separate line with line comments { "eslint.codeAction.disableRuleComment": { "enable": true, "location": "separateLine", "commentStyle": "line" } } ``` ```json // settings.json - Insert on same line with block comments { "eslint.codeAction.disableRuleComment": { "enable": true, "location": "sameLine", "commentStyle": "block" } } ``` -------------------------------- ### Control ESLint Validation Timing Source: https://context7.com/microsoft/vscode-eslint/llms.txt Controls when ESLint validation runs: on every keystroke (`onType`) or only when saving (`onSave`). ```json // settings.json - Run linting on save only { "eslint.run": "onSave" } ``` ```json // settings.json - Run linting on every keystroke (default) { "eslint.run": "onType" } ``` -------------------------------- ### Override Autofixable ESLint Rules to Info Severity Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration overrides all autofixable ESLint rules to have a severity of 'info'. ```json "eslint.rules.customizations": [ { "rule": "*", "fixable": true, "severity": "info" } ] ``` -------------------------------- ### Specify Languages for ESLint Validation Source: https://context7.com/microsoft/vscode-eslint/llms.txt An array of language identifiers that ESLint should validate. When specified, only files matching these languages are validated. ```json // settings.json - Validate specific languages { "eslint.validate": [ "javascript", "javascriptreact", "typescript", "typescriptreact", "html", "vue" ] } ``` -------------------------------- ### Filter ESLint Rules for Code Actions on Save Source: https://context7.com/microsoft/vscode-eslint/llms.txt Specify which ESLint rules to apply when code actions on save are triggered. Supports glob patterns and exclusions. ```json // settings.json - Only fix semicolon-related rules { "eslint.codeActionsOnSave.rules": [ "*semi*" ] } ``` ```json // settings.json - Exclude TypeScript ESLint rules, keep all others { "eslint.codeActionsOnSave.rules": [ "!@typescript-eslint/*", "*" ] } ``` ```json // settings.json - Keep specific TS rules, exclude rest, keep others { "eslint.codeActionsOnSave.rules": [ "@typescript-eslint/semi", "@typescript-eslint/indent", "!@typescript-eslint/*", "*" ] } ``` -------------------------------- ### Enable Auto Fix on Save Specifically for ESLint Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration enables Auto Fix exclusively for ESLint, utilizing the `source.fixAll.eslint` property within VS Code's `editor.codeActionsOnSave` setting. ```json "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" } ``` -------------------------------- ### Disable ESLint Auto Fix on Save Selectively Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration enables Auto Fix for all providers but selectively disables it for ESLint using the `source.fixAll.eslint: "never"` property within VS Code's `editor.codeActionsOnSave` setting. ```json "editor.codeActionsOnSave": { "source.fixAll": "explicit", "source.fixAll.eslint": "never" } ``` -------------------------------- ### Control ESLint Auto-Fix Mode Source: https://context7.com/microsoft/vscode-eslint/llms.txt Controls which problems are fixed during code actions on save: all possible problems or only known fixable problems. ```json // settings.json - Fix all possible problems (runs full ESLint --fix) { "eslint.codeActionsOnSave.mode": "all" } ``` ```json // settings.json - Fix only known fixable problems (faster) { "eslint.codeActionsOnSave.mode": "problems" } ``` -------------------------------- ### Suppress ESLint Warnings Source: https://context7.com/microsoft/vscode-eslint/llms.txt When enabled, ESLint ignores warnings and only reports errors. ```json // settings.json { "eslint.quiet": true } ``` -------------------------------- ### Override ESLint Rule Severity Source: https://context7.com/microsoft/vscode-eslint/llms.txt Customize the severity of ESLint rules within VS Code without altering your ESLint configuration files. Supports wildcard matching and specific rule overrides. ```json // settings.json - Override all rules to warnings { "eslint.rules.customizations": [ { "rule": "*", "severity": "warn" } ] } ``` ```json // settings.json - Complex severity customization { "eslint.rules.customizations": [ { "rule": "no-*", "severity": "info" }, { "rule": "!no-*", "severity": "downgrade" }, { "rule": "radix", "severity": "default" } ] } ``` ```json // settings.json - Customize only auto-fixable rules { "eslint.rules.customizations": [ { "rule": "*", "fixable": true, "severity": "info" } ] } ``` -------------------------------- ### Remove TypeScript ESLint Rules from Code Actions on Save Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This configuration removes all TypeScript ESLint specific rules from the code action on save pass while retaining all other rules. ```json "eslint.codeActionsOnSave.rules": [ "!@typescript-eslint/*", "*" ] ``` -------------------------------- ### Disable ESLint Code Actions on Save for HTML Files Source: https://github.com/microsoft/vscode-eslint/blob/main/README.md This setting disables the ESLint code actions on save feature specifically for HTML files. ```json "[html]": { "editor.codeActionsOnSave": { "source.fixAll.eslint": false } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.