编辑器集成

为了获得最佳的 turbo 体验,Turborepo 提供了一些实用程序,可与你的编辑器集成。

¥To get the best experience with turbo, Turborepo provides a few utilities for integrating with your editor.

turbo.json 的 JSON Schema

¥JSON Schema for turbo.json

Turborepo 使用 JSON Schema 为你的 turbo.json 文件提供自动补齐功能。通过在 turbo.json 中包含 $schema 键,你的编辑器能够在出现无效形状或缺少键的情况下提供完整的文档和代码检查。

¥Turborepo uses JSON Schema to give you auto-complete in your turbo.json file. By including the $schema key in your turbo.json, your editor is able to provide full documentation and linting in case you have invalid shapes or missing keys.

从网络采购

¥Sourcing from the web

可以通过以下 URL 访问 schema.json。这样做的好处是无需运行包管理器的安装命令即可查看编辑器内的验证。

¥A schema.json is accessible at the URL shown below. This has the advantage of not needing to run your package manager's install command to see in-editor validation.

Turborepo logo
./turbo.json
{
  "$schema": "https://turbo.nodejs.cn/schema.json"
}

还有一个主要版本的 schema.json 可用,遵循 https://turbo.nodejs.cn/schema.<version>.json 的格式。

¥There is also a major versioned schema.json available, following the format of https://turbo.nodejs.cn/schema.<version>.json.

Turborepo logo
./turbo.json
{
  "$schema": "https://turbo.nodejs.cn/schema.v1.json"
}

node_modules 采购

¥Sourcing from node_modules

从 Turborepo 2.4 开始,运行包管理器的安装命令后,schema.json 即可在 node_modules 中使用:

¥Starting in Turborepo 2.4, schema.json is available in node_modules once you've run your package manager's install command:

Turborepo logo
turbo.json
{
  "$schema": "./node_modules/turbo/schema.json"
}

node_modules location

我们建议将 turbo 安装在你的代码库的根目录下,这样 schema 的路径应该指向你代码库根目录下的 node_modules。在 软件包配置 中,你可能需要使用类似 ../../node_modules/turbo/schema.json 的路径。

¥We recommend installing turbo at the root of your repository, so the path for the schema should point to node_modules at the root of your repository. In Package Configurations, you may need to use a path like ../../node_modules/turbo/schema.json.

环境变量的 Linting

¥Linting for environment variables

处理环境变量是 Turborepo 中构建应用的重要组成部分。

¥Handling environment variables is an important part of building applications in a Turborepo.

eslint-config-turbo 软件包 扩展了你的 ESLint 设置,以帮助你确保已处理所有环境变量。

¥The eslint-config-turbo package extends your ESLint setup to help you make sure you've taken care of all of your environment variables.

Turborepo LSP

比 JSON Schema 提供的自动补齐和 linting 功能更强大,编辑器内提供无效 glob 的提示、对不存在的任务或包的引用,以及额外的仓库可见性工具。

¥Enable even more auto-complete and linting than provided by JSON Schema, with in-editor hinting for invalid globs, references to non-existent tasks or packages, and extra repository visibility tools.

访问 VSCode 扩展市场 进行安装。

¥Visit the VSCode Extension Marketplace to install.

Not using Visual Studio Code?

语言服务器可用于任何支持 语言服务器协议 的编辑器。在我们的 问题跟踪器 中记录请求以表达你的兴趣。

¥The language server can be used on any editors that support the Language Server Protocol. Log a request in our issue tracker to express your interest.