Skip to content

Add ESLint Language Server Support #1410

@morgvanny

Description

@morgvanny

It currently only provides TypeScript/JavaScript diagnostics through the TypeScript language server, but doesn't show ESLint errors

Something like this could add ESLint language server support similar to other language servers:

export const ESLint: Info = {
  id: "eslint",
  root: NearestRoot([
    "eslint.config.js",
    "eslint.config.mjs",
    "eslint.config.cjs",
    ".eslintrc.js",
    ".eslintrc.cjs",
    ".eslintrc.yaml",
    ".eslintrc.yml",
    ".eslintrc.json",
    ".eslintrc",
    "package.json"
  ]),
  extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs",
".mts", ".cts"],
  async spawn(app, root) {
    // Check if ESLint is available in the project
    const eslintPath = await Bun.resolve("eslint", root).
catch(() => {})
    if (!eslintPath) {
      log.info("ESLint not found in project, skipping ESLint
language server")
      return
    }

    const proc = spawn(BunProc.which(), ["x", "vscode-eslint-
language-server", "--stdio"], {
      cwd: root,
      env: {
        ...process.env,        BUN_BE_BUN: "1",
      },
    })
    return {
      process: proc,
      initialization: {
        nodePath: process.execPath,
        workspaceFolders: [
          {
            uri: `file://${root}`,
            name: path.basename(root),
          },
        ],
      },
    }
  },
}

vscode-eslint-language-server is the same LSP used by VSCode's ESLint extension, so it should be well-tested and maintained

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions