这是indexloc提供的服务,不要输入任何密码
Skip to content

turbo.jsonc does not play well with prettier #10499

@sdavids

Description

@sdavids

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Which canary version will you have in your reproduction?

2.5.3

Environment information

node 22.15.0
npm 10.9.2
prettier 3.5.3

Expected behavior

turbo.jsonc can be formatted with prettier defaults and is accepted by turbo.

Actual behavior

turbo.jsonc formatted with prettier defaults is not accepted by turbo.

To Reproduce

$ npx create-turbo@latest -e with-shell-commands -m npm test
$ cd test
$ npm i -D prettier
$ npx prettier --write .
$ turbo build
...
 Tasks:    5 successful, 5 total
Cached:    0 cached, 5 total
  Time:    1.934s
$ mv turbo.json turbo.jsonc
$ npx prettier --write .
$ turbo build
turbo_json_parse_error

  × Failed to parse turbo.json.
  ├─▶   × Expected a property but instead found '}'.
  │      ╭─[turbo.jsonc:7:5]
  │    6 │       "outputs": ["output-file.txt", "dist/**"],
  │    7 │     },
  │      ·     ─
  │    8 │     "prebuild": {},
  │      ╰────
  ├─▶   × Expected a property but instead found '}'.
  │       ╭─[turbo.jsonc:11:3]
  │    10 │     "check-types": {},
  │    11 │   },
  │       ·   ─
  │    12 │ }
  │       ╰────
  ╰─▶   × Expected a property but instead found '}'.
          ╭─[turbo.jsonc:12:1]
       11 │   },
       12 │ }
          · ─
          ╰────
$ cat turbo.jsonc
{
  "$schema": "https://turborepo.com/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["prebuild", "^build"],
      "outputs": ["output-file.txt", "dist/**"],
    },
    "prebuild": {},
    "lint": {},
    "check-types": {},
  },
}

Additional context

JSONC Specification

JSONC doesn’t allow trailing commas; however, we encourage parsers to be lenient and handle trailing commas gracefully where possible to reduce the risk of human edits introducing parsing errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugSomething isn't workingneeds: triageNew issues get this label. Remove it after triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions