Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Registering Root Tasks - Incorrect/Unclear example #8972

Closed
nickfujita opened this issue Aug 9, 2024 · 1 comment
Closed

Docs: Registering Root Tasks - Incorrect/Unclear example #8972

nickfujita opened this issue Aug 9, 2024 · 1 comment

Comments

@nickfujita
Copy link

nickfujita commented Aug 9, 2024

What is the improvement or update you wish to see?

The current documentation seems to suggest that by creating the lint:root script in the root package.json file, and the //#lint:root: {} task in turbo.json alongside lint: {} task, running turbo run lint should execute the lint script in all packages in the repo, along with the lint:root script in the root package.json. At least that's how I understood it to mean.

Is there any context that might help us understand?

Registering Root Tasks

Existing

Running pnpm lint only runs lint scripts in packages, but not the root level lint:root script.

turbo.json

{
  "tasks": {
    "lint": {
      "dependsOn": ["^lint"]
    },
    "//#lint:root": {} 
  }
}

package.json

{
  "scripts": {
    "lint": "turbo run lint",
    "lint:root": "eslint ."
  }
}

Correction - Option 1

Runs lint:root in addition to lint scripts in all packages, by separately calling lint:root in the turbo run statement

turbo.json

{
  "tasks": {
    "lint": {
      "dependsOn": ["^lint"]
    },
    "//#lint:root": {} 
  }
}

package.json

{
  "scripts": {
    "lint": "turbo run lint lint:root",
    "lint:root": "eslint ."
  }
}

Correction - Option 2

Runs lint:root in addition to lint scripts in all packages by removing :root suffix from the script in the root package.json, and making the script the calls turbo run lint be named something else (eg. lint-abcdef, lint-all)

turbo.json

{
  "tasks": {
    "lint": {
      "dependsOn": ["^lint"]
    },
    "//#lint": {} 
  }
}

package.json

{
  "scripts": {
    "lint-all": "turbo run lint",
    "lint": "eslint ."
  }
}

Does the docs page already exist? Please link to it.

https://turbo.build/repo/docs/crafting-your-repository/configuring-tasks#registering-root-tasks

anthonyshew added a commit that referenced this issue Sep 2, 2024
### Description

@nickfujita in #8972 pointed
out that the docs were confusing about how to use a Root Task, so making
sure to clarify that here.

### Testing Instructions

👀
@anthonyshew
Copy link
Contributor

Fixed in #9098. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants