Eslint extension for coc.nvim
Published Package Summary
coc-eslint
Eslint language server extension for coc.nvim.
Forked from vscode-eslint.
Install
In your vim/neovim run the following command:
:CocInstall coc-eslint
eslint and a config file must be available, for example:
npm install eslint --global
Example config file, in the root of the project: eslint.config.mjs:
export default [
{
rules: {
"prefer-const": "error",
"no-undef": "error"
}
}
];
Important notice
- This extension may not work with files just created, save the file and execute
:CocCommand eslint.restarton that case. - The eslint config file should inside your workspace folder for project lint to
work
:h coc-workspace-folders. - Configuration
eslint.probeis ignored wheneslint.validateexists, configureeslint.validatefor your project is recommended. eslint.autoFixOnSaveis deprecated, use:CocCommand eslint.migrateSettingsfor migrate to new configuration by useeditor.codeActionsOnSaveconfiguration.eslint.useFlatConfigdefault to true and can't be turned off, consider migrate your old configuration to use flat config instead.
Features
- Lint
javascriptfiles using eslint. - Provide
codeActionsfor fixing lint issues. - Provide eslint commands:
eslint.lintProjectLint current project and set errors & warnings to vim's quickfix list.eslint.executeAutofixFix all auto-fixable Problemseslint.createConfigCreate ESLint configurationeslint.showOutputChannelShow Output Channeleslint.migrateSettingsMigrate Settingseslint.restartRestart ESLint Servereslint.revalidateRevalidate all open files
Differences with vscode-eslint
- Option
eslint.lintTask.enablenot exists, use:CocCommand eslint.lintProjectto run eslint for current project.
Auto-fixing
The extension supports automatic fixing of warnings to the extent that it is supported by eslint. For warnings which support an auto-fix. You can apply the quick fix by either:
- Configure
editor.codeActionsOnSavewith property"source.fixAll.eslint": true. Seteslint.autoFixOnSavetotrueand save your file- Trigger
<Plug>(coc-codeaction)with mapped keys, and select a fix action in the input list. - Run command
:CocCommand eslint.executeAutofix. - Trigger command
eslint.executeAutofixfrom:CocCommand.
Supporting
ESLint dependency
coc-eslint loads the ESLint library from the current workspace when possible;
it does not bundle ESLint or project-specific ESLint plugins and configurations.
Install eslint, its plugins, and shared configurations in the workspace that
contains the files being linted. If no workspace installation can be resolved,
the extension falls back to the global package location for the configured
eslint.packageManager. You can also set eslint.nodePath to the directory
that contains a resolvable ESLint installation.
License
MIT
- Eslint extension for coc.nvim
- *
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
Published with coc-eslint@3.1.2 as history.md.
3.1.2
- fix release.yml (994c937)
- not use npm whoami (b86f40d)
- improve npmignore (65d1a70)
3.1
- Added ESLint 10 flat-config support and related compatibility warnings.
- Added bulk suppressions diagnostics for ESLint ≥10.1.
- Added probing support for more languages and ESLint plugins.
- Added
eslint.useRealpathsfor improved symlink/path resolution. - Added
eslint.codeActionsOnSave.options. - Added
eslint.lintTask.commandfor custom project lint commands. - Fixed code actions being applied to the wrong rule, document, or version.
- Fixed duplicate listeners and status bars after ESLint restarts.
- Improved global ESLint lookup, including pnpm failure handling.
- Fixed
eslint.lintProjectquickfix population using JSON output. - Improved nested workspace, monorepo, and flat-config resolution.
- Added an automated release workflow; nothing has been pushed or published yet.
3.0.13
- Remove configuration
eslint.fixOnSaveTimeout - Add commands
eslint.migrateSettings,eslint.revalidate - Add configurations:
eslint.problems.shortenToSingleLineeslint.migration.2_xeslint.ignoreUntitledeslint.useFlatConfigeslint.timeBudget.onValidationeslint.timeBudget.onFixes
- Flat config is used by default, you may need to configure
eslint.config.jsin your home folder to make it works for all of your files.
Contributed Commands
All contributes.commands entries from the published package manifest for coc-eslint@3.1.2.
| Command (:CocCommand) | Description |
|---|---|
| eslint.executeAutofix | Fix all auto-fixable Problems |
| eslint.createConfig | Create ESLint configuration |
| eslint.showOutputChannel | Show Output Channel |
| eslint.migrateSettings | Migrate Settings |
| eslint.restart | Restart ESLint Server |
| eslint.revalidate | Revalidate all open files |
| eslint.lintProject | Lint current project and set errors & warnings to quickfix list of vim. |
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"enum": [
"onSave",
"onType"
],
"type": "string",
"scope": "resource",
"default": "onType",
"description": "Run the linter on save (onSave) or on type (onType)"
}Raw JSON Schema
{
"type": "boolean",
"scope": "window",
"default": false,
"markdownDescription": "Enables ESLint debug mode (same as `--debug` on the command line)"
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"scope": "resource",
"default": [
"astro",
"civet",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"css",
"glimmer-js",
"glimmer-ts",
"html",
"mdx",
"svelte",
"vue",
"markdown",
"json",
"jsonc",
"graphql"
],
"description": "An array of language ids for which the extension should probe if support is installed."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Turns on quiet mode, which ignores warnings and info diagnostics."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Controls whether eslint is enabled or not.",
"deprecationMessage": "Use configuration eslint.validate is recommended."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"scope": "resource",
"default": null,
"markdownDescription": "The value of `NODE_ENV` to use when running eslint tasks."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {},
"markdownDescription": "The eslint options object to provide args normally passed to eslint when executed from a command line (see https://eslint.org/docs/developer-guide/nodejs-api#eslint-class)."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"scope": "machine-overridable",
"default": null,
"markdownDescription": "The location of the node binary to run ESLint under."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"default": null,
"markdownDescription": "Additional exec argv argument passed to the runtime. This can for example be used to control the maximum heap space using --max_old_space_size"
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"scope": "machine-overridable",
"default": null,
"markdownDescription": "A path added to `NODE_PATH` when resolving the eslint module."
}Raw JSON Schema
{
"type": [
"array",
"null"
],
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"autoFix": {
"type": "boolean",
"description": "Whether auto fixes are provided for the language."
},
"language": {
"type": "string",
"description": "The language id to be validated by ESLint."
}
},
"deprecationMessage": "Auto Fix is enabled by default. Use the single string form."
}
]
},
"scope": "resource",
"default": null,
"description": "An array of language ids which should be validated by ESLint. If not installed ESLint will show an error."
}Raw JSON Schema
{
"anyOf": [
{
"enum": [
"off",
"messages",
"verbose"
],
"type": "string",
"default": "off"
},
{
"type": "object",
"properties": {
"format": {
"enum": [
"text",
"json"
],
"type": "string",
"default": "text"
},
"verbosity": {
"enum": [
"off",
"messages",
"verbose"
],
"type": "string",
"default": "off"
}
}
}
],
"scope": "window",
"default": "off",
"description": "Traces the communication between VSCode and the eslint linter service."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Whether ESLint should use real paths when resolving files. This is useful when working with symlinks or when the casing of file paths is inconsistent."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Turns auto fix on save on or off.",
"deprecationMessage": "Not used any more, use \"editor.codeActionsOnSave\" instead, use `CocCommand eslint.migrateSettings` to fix it."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Enables ESLint as a formatter."
}Raw JSON Schema
{
"enum": [
"off",
"on"
],
"type": "string",
"scope": "application",
"default": "on",
"description": "Whether ESlint should migrate auto fix on save settings."
}Raw JSON Schema
{
"type": [
"boolean",
"null"
],
"scope": "resource",
"default": null,
"markdownDescription": "Controls whether flat config should be used or not. This setting requires ESLint version 8.57 or later and is interpreted according to the [ESLint Flat Config rollout plan](https://eslint.org/blog/2023/10/flat-config-rollout-plans/). This means:\n\n - *8.57.0 <= ESLint version < 9.x*: setting is honored and defaults to false\n- *9.0.0 <= ESLint version < 10.x*: settings is honored and defaults to true\n- *10.0.0 <= ESLint version*: setting is ignored. Flat configs are the default and can't be turned off."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "If true, untitled files won't be validated by ESLint."
}Raw JSON Schema
{
"enum": [
"warn",
"off"
],
"type": "string",
"scope": "resource",
"default": "off",
"description": "Whether ESLint should issue a warning on ignored files."
}Raw JSON Schema
{
"enum": [
"npm",
"yarn",
"pnpm"
],
"type": "string",
"scope": "resource",
"default": "npm",
"description": "The package manager you use to install node modules."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Since version 7 ESLint offers a new API call ESLint. Use it even if the old CLIEngine is available. From version 8 on forward on ESLint class is available."
}Raw JSON Schema
{
"type": "boolean",
"scope": "application",
"default": false,
"description": "Always show the ESlint status bar item."
}Raw JSON Schema
{
"type": "integer",
"default": 1000,
"description": "Timeout in miliseconds when run auto fix on save."
}Raw JSON Schema
{
"type": [
"string",
"null"
],
"scope": "resource",
"default": null,
"description": "The command used to lint the whole workspace. When unset, coc-eslint detects the workspace ESLint executable."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"scope": "resource",
"default": [
"."
],
"description": "Command line options applied when running the task for linting the whole workspace (see https://eslint.org/docs/user-guide/command-line-interface)."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {
"warn": 3000,
"error": 6000
},
"properties": {
"warn": {
"type": "number",
"default": 3000,
"minimum": 0,
"markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing a warning."
},
"error": {
"type": "number",
"default": 6000,
"minimum": 0,
"markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing an error."
}
},
"markdownDescription": "The time budget in milliseconds to spend on computing fixes before showing a warning or error."
}Raw JSON Schema
{
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"required": [
"mode"
],
"properties": {
"mode": {
"enum": [
"auto",
"location"
],
"type": "string",
"default": "location"
}
}
},
{
"type": "object",
"required": [
"directory"
],
"properties": {
"!cwd": {
"type": "boolean",
"description": "Set to true if ESLint shouldn't change the working directory."
},
"directory": {
"type": "string",
"description": "The working directory to use if a file's path starts with this directory."
}
}
},
{
"type": "object",
"required": [
"pattern"
],
"properties": {
"!cwd": {
"type": "boolean",
"description": "Set to true if ESLint shouldn't change the working directory."
},
"pattern": {
"type": "string",
"description": "A glob pattern to match a working directory."
}
}
}
]
},
"scope": "resource",
"markdownDescription": "Specifies how the working directories ESLint is using are computed. ESLint resolves configuration files (e.g. `eslintrc`, `.eslintignore`) relative to a working directory so it is important to configure this correctly."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"rule": {
"type": "string"
},
"severity": {
"enum": [
"downgrade",
"error",
"info",
"default",
"upgrade",
"warn",
"off"
],
"type": "string"
}
}
},
"scope": "resource",
"description": "Override the severity of one or more rules reported by this extension, regardless of the project's ESLint config. Use globs to apply default severities for multiple rules."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Show file-level bulk-suppressed violations. Requires ESLint 10.1 or later."
}Raw JSON Schema
{
"enum": [
"all",
"problems"
],
"type": "string",
"scope": "resource",
"default": "all",
"enumDescriptions": [
"Fixes all possible problems in the file. This option might take some time.",
"Only fixes reported problems that have non overlapping textual edits. This options runs a lot faster."
],
"markdownDescription": "Specifies the code action mode. Possible values are 'all' and 'problems'."
}Raw JSON Schema
{
"type": "array",
"items": {
"type": "string"
},
"scope": "resource",
"default": null,
"markdownDescription": "The rules that should be executed when computing the code actions on save or formatting a file. Defaults to the rules configured via the ESLint configuration"
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {
"warn": 4000,
"error": 8000
},
"properties": {
"warn": {
"type": "number",
"default": 4000,
"minimum": 0,
"markdownDescription": "The time budget in milliseconds to spend on validation before showing a warning."
},
"error": {
"type": "number",
"default": 8000,
"minimum": 0,
"markdownDescription": "The time budget in milliseconds to spend on validation before showing an error."
}
},
"markdownDescription": "The time budget in milliseconds to spend on validation before showing a warning or error."
}Raw JSON Schema
{
"type": "string",
"scope": "resource",
"description": "Path to the suppressions file relative to the workspace."
}Raw JSON Schema
{
"enum": [
"error",
"warn",
"info",
"hint"
],
"type": "string",
"scope": "resource",
"default": "info",
"description": "Diagnostic severity for bulk-suppressed violations."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {},
"markdownDescription": "The ESLint options object to use on save. Rules configured with eslint.codeActionsOnSave.rules take priority."
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Enables support of experimental Flat Config (aka eslint.config.js, supported by ESLint version 8.21 or later).",
"deprecationMessage": "Use ESLint version 8.57 or later and eslint.useFlatConfig instead."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {
"enable": true
},
"properties": {
"enable": {
"type": "boolean",
"default": true,
"description": "Show the documentation code actions."
}
},
"markdownDescription": "Show open lint rule documentation web page in the quick fix menu.",
"additionalProperties": false
}Raw JSON Schema
{
"type": "boolean",
"scope": "resource",
"default": false,
"description": "Shortens the text spans of underlined problems to their first related line."
}Raw JSON Schema
{
"type": "object",
"scope": "resource",
"default": {
"enable": true,
"location": "separateLine"
},
"properties": {
"enable": {
"type": "boolean",
"default": true,
"description": "Show the disable code actions."
},
"location": {
"enum": [
"separateLine",
"sameLine"
],
"type": "string",
"default": "separateLine",
"description": "Configure the disable rule code action to insert the comment on the same line or a new line."
}
},
"markdownDescription": "Show disable lint rule in the quick fix menu.",
"additionalProperties": false
}