Files
zed/docs/src/languages/javascript.md
T
morgankrey 526c95d474 Improve internal links across documentation (#64481)
## Summary

- Adds 63 internal links across 41 documentation pages.
- Connects existing terms such as Agent Panel, semantic tokens, edit
predictions, and language-specific debugging to their detailed reference
pages.
- Uses existing wording for 60 links and makes three small wording
changes where a natural anchor did not already exist.

## Why this matters

Readers can now move from overview and configuration pages to the
relevant detailed guidance without searching the documentation manually.
The changes add navigation only. They do not change product behavior or
documented requirements.

## Jev experiment

This PR came from a local experiment using Jev to audit internal links
across the published documentation. The audit scripts are not included
in this PR.

- Code shortlisted 2,715 possible source and destination page pairs.
- Jev made two separate decisions for each pair: whether the link would
help the reader, and which exact existing phrase should become the
anchor.
- Five strong links without existing anchor text went to GPT-5.6 Luna
for minimal rewrite options. Jev then selected among those fixed
options.
- A local review interface surfaced the results for Pass or Fail
decisions before any files changed.

Human review approved 66 changes. Two no longer matched the current
`main` branch, and review removed one circular link, leaving the 63
links in this PR.

## Validation

- `pnpm dlx prettier@3.5.0 <changed docs> --check`
- `lychee --exclude '^http' './docs/src/**/*'` — 0 errors
- `mdbook build docs`
- Verified that the diff adds exactly 63 Markdown links

Release Notes:

- Improved links between related documentation pages.
2026-09-19 19:58:09 +00:00

7.7 KiB

title, description
title description
JavaScript Configure JavaScript language support in Zed, including language servers, formatting, and debugging.

JavaScript

JavaScript support is available natively in Zed.

Code formatting

Formatting on save is disabled by default for JavaScript.

To turn format-on-save on, you can enable the setting globally or for JavaScript or TypeScript specifically.

{
  "languages": {
    "JavaScript": {
      "format_on_save": "on"
    },
    "TypeScript": {
      "format_on_save": "on"
    }
  }
}

Many JavaScript projects use command-line code-formatting tools, such as Prettier. You can use one of these tools by specifying an external code formatter for JavaScript in your settings. See the configuration docs for more information.

For example, if you have Prettier installed and on your PATH, you can use it to format JavaScript files.

Configure formatting in Settings ({#kb zed::OpenSettings}) under Languages > JavaScript, or add to your settings file:

{
  "languages": {
    "JavaScript": {
      "formatter": {
        "external": {
          "command": "prettier",
          "arguments": ["--stdin-filepath", "{buffer_path}"]
        }
      }
    }
  }
}

JSX

Zed supports JSX syntax highlighting out of the box.

In JSX strings, the tailwindcss-language-server is used to provide autocompletion for Tailwind CSS classes.

JSDoc

Zed supports JSDoc syntax in JavaScript and TypeScript comments that match the JSDoc syntax. Zed uses tree-sitter/tree-sitter-jsdoc for parsing and highlighting JSDoc.

ESLint

You can configure Zed to format code using eslint --fix by running the ESLint code action when formatting.

Configure code actions on format in Settings ({#kb zed::OpenSettings}) under Languages > JavaScript, or add to your settings file:

{
  "languages": {
    "JavaScript": {
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  }
}

You can also only execute a single ESLint rule when using fixAll:

{
  "languages": {
    "JavaScript": {
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  },
  "lsp": {
    "eslint": {
      "settings": {
        "codeActionOnSave": {
          "rules": ["import/order"]
        }
      }
    }
  }
}

Note: the other formatter you have configured will still run, after ESLint. So if your language server or Prettier configuration doesn't format according to ESLint's rules, then they will overwrite what ESLint fixed and you end up with errors.

If you only want to run ESLint on save, you can configure code actions as the formatter.

Configure in Settings ({#kb zed::OpenSettings}) under Languages > JavaScript, or add to your settings file:

{
  "languages": {
    "JavaScript": {
      "formatter": [],
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  }
}

Configure ESLint's nodePath:

You can configure ESLint's nodePath setting:

{
  "lsp": {
    "eslint": {
      "settings": {
        "nodePath": ".yarn/sdks"
      }
    }
  }
}

Configure ESLint's problems:

You can configure ESLint's problems setting.

For example, here's how to set problems.shortenToSingleLine:

{
  "lsp": {
    "eslint": {
      "settings": {
        "problems": {
          "shortenToSingleLine": true
        }
      }
    }
  }
}

Configure ESLint's rulesCustomizations:

You can configure ESLint's rulesCustomizations setting:

{
  "lsp": {
    "eslint": {
      "settings": {
        "rulesCustomizations": [
          // set all eslint errors/warnings to show as warnings
          { "rule": "*", "severity": "warn" }
        ]
      }
    }
  }
}

Configure ESLint's workingDirectory:

You can configure ESLint's workingDirectory setting:

{
  "lsp": {
    "eslint": {
      "settings": {
        "workingDirectory": {
          "mode": "auto"
        }
      }
    }
  }
}

Using the Tailwind CSS Language Server with JavaScript

To get all the features (autocomplete, linting, etc.) from the Tailwind CSS language server in vanilla JavaScript files (.js), you can customize the classRegex field under it in your settings.json:

{
  "lsp": {
    "tailwindcss-language-server": {
      "settings": {
        "experimental": {
          "classRegex": [
            "\\.className\\s*[+]?=\\s*['\"]([^'\"]*)['\"]",
            "\\.setAttributeNS\\(.*,\\s*['\"]class['\"],\\s*['\"]([^'\"]*)['\"]",
            "\\.setAttribute\\(['\"]class['\"],\\s*['\"]([^'\"]*)['\"]",
            "\\.classList\\.add\\(['\"]([^'\"]*)['\"]",
            "\\.classList\\.remove\\(['\"]([^'\"]*)['\"]",
            "\\.classList\\.toggle\\(['\"]([^'\"]*)['\"]",
            "\\.classList\\.contains\\(['\"]([^'\"]*)['\"]",
            "\\.classList\\.replace\\(\\s*['\"]([^'\"]*)['\"]",
            "\\.classList\\.replace\\([^,)]+,\\s*['\"]([^'\"]*)['\"]"
          ]
        }
      }
    }
  }
}

Debugging

Zed supports debugging JavaScript code out of the box with vscode-js-debug. The following can be debugged without writing additional configuration:

  • Tasks from package.json
  • Tests written using several popular frameworks (Jest, Mocha, Vitest, Jasmine, Bun, Node)

Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks.

Note: Bun test is automatically detected when @types/bun is present in package.json.

Note: Node test is automatically detected when @types/node is present in package.json (requires Node.js 20+).

As for all languages, configurations from .vscode/launch.json are also available for debugging in Zed.

If your use-case isn't covered by any of these, you can take full control by adding debug configurations to .zed/debug.json. See below for example configurations.

Configuring JavaScript debug tasks

JavaScript debugging is more complicated than other languages because there are two different environments: Node.js and the browser. vscode-js-debug exposes a type field, that you can use to specify the environment, either node or chrome.

Debug the current file with Node

[
  {
    "adapter": "JavaScript",
    "label": "Debug JS file",
    "type": "node",
    "request": "launch",
    "program": "$ZED_FILE",
    "skipFiles": ["<node_internals>/**"]
  }
]

Launch a web app in Chrome

[
  {
    "adapter": "JavaScript",
    "label": "Debug app in Chrome",
    "type": "chrome",
    "request": "launch",
    "file": "$ZED_WORKTREE_ROOT/index.html",
    "webRoot": "$ZED_WORKTREE_ROOT",
    "console": "integratedTerminal",
    "skipFiles": ["<node_internals>/**"]
  }
]

See also