Skip to content

docs: add package.json script guidelines and git hooks guidelines#51

Closed
rjmunro wants to merge 3 commits into
Sofie-Automation:mainfrom
rjmunro:rjmunro/package-json-guildelines
Closed

docs: add package.json script guidelines and git hooks guidelines#51
rjmunro wants to merge 3 commits into
Sofie-Automation:mainfrom
rjmunro:rjmunro/package-json-guildelines

Conversation

@rjmunro
Copy link
Copy Markdown
Contributor

@rjmunro rjmunro commented May 6, 2026

About the Contributor

This pull request is posted on behalf of SuperFly.tv.

Type of Contribution

This is a: Documentation improvement

Current Behaviour

There were no written conventions for how package.json scripts should be named and organised across Sofie Automation projects, leading to inconsistency between packages. Similarly, the recommended approach for Husky/git-hooks setup in published packages was not documented.

New Behaviour

Adds two guideline documents to this repo:

  • PACKAGE_SCRIPT_GUIDELINES.md — conventions for naming, namespacing, and organising package.json scripts across Sofie packages (lifecycle scripts, colons for namespacing, underscore prefix for internal scripts, etc.)
  • GIT_HOOKS_GUIDELINES.md — documents the options for Husky setup in packages that are also published to npm, and calls out that an RFC is needed to settle the standard approach.

Testing Instructions

  • No unit test changes are needed for this PR

Read both guideline documents and check they are accurate and consistent with current practice.

Affected areas

Documentation only — no code changes. Adds two new Markdown files to the repo root.

Time Frame

Not urgent. The git hooks section is intentionally left as an open question pending an RFC.

Other Information

The PACKAGE_SCRIPT_GUIDELINES.md content was aligned with RFC #1699 from sofie-core. The git hooks document is a placeholder to prompt the RFC discussion.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests have been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@rjmunro has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00ca2494-e1fb-4ad2-8ef5-e17870c89dbf

📥 Commits

Reviewing files that changed from the base of the PR and between 85e75b5 and 64ff923.

📒 Files selected for processing (2)
  • GIT_HOOKS_GUIDELINES.md
  • PACKAGE_SCRIPT_GUIDELINES.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rjmunro rjmunro marked this pull request as ready for review May 6, 2026 21:14
Comment thread GIT_HOOKS_GUIDELINES.md

- Simpler — no `pinst` dependency or pack scripts
- Only runs during actual development (when building or linting)
- Doesn't run when installed as library or from git
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But don't we need to do build the library when installing from git too?
I don't see a proposal for how that would be setup to avoid installing the hook

**Guidelines:**

- `clean` removes everything created by `build` (dist folder, generated files) but not data
- If your tool supports it, `clean --all` should also remove `node_modules`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Seems like ai wrote a lot of words in this file, without any proposal on how to achieve any of these things.
If this clean --all is wanted, there should be an example of it, which I suspect is going to be a wordy command

"scripts": {
"lint:raw": "eslint --ext .ts --ext .js --ignore-pattern dist",
"lint": "yarn lint:raw .",
"lint:fix": "yarn lint --fix"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're talking about what there should be, I've never seen much value in yarn lint:fix script, as the same can be achieved with yarn lint --fix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if it's doing something like:

"lint": "yarn lint:eslint && yarn lint:prettier --check"
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --save"

"test:unit": "jest",
"test:integration": "jest --config jest.integration.config.js",
"watch": "jest --watch",
"cov": "jest --coverage && open-cli coverage/lcov-report/index.html",
Copy link
Copy Markdown
Member

@Julusian Julusian May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would question whether these cov/cov:open should exist, I don't think I've used htem in years and open-cli is just another dependency that I'm not sure we need

The test/watch are maybe a bit confusing/harder to wrangle with vitest as it defaults to watch mode and you have to opt into single run. not a deal breaker, just a question of whether that should affect our standard

- `start` (in Standard Lifecycle Scripts above) starts in production mode — no hot reload, no source maps
- Only include `dev` and `start` in projects that have a server component

Root package.json in workspaces:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the heading of a section?

- Use `build:*` and `test:*` to target specific workspaces
- Keep convenience scripts like `build-sync-local` at workspace level

## Blueprint-Specific Scripts
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this section shouldnt be here; perhaps a recommendation in the bluepritn-tools is better?

- These are exceptions to the colon rule for developer convenience
- Keep these names for consistency with existing documentation

## Common Patterns to Avoid
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to feel like it is repeating itself now

```json
{
"scripts": {
"start": "docusaurus start --port 3030",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt this be dev?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I like these markdown files being in this repository like this, (probably shouldnt be loose at the root if they do remain).

@rjmunro rjmunro force-pushed the rjmunro/package-json-guildelines branch from 2348865 to 64ff923 Compare May 7, 2026 11:04
@rjmunro rjmunro marked this pull request as draft May 7, 2026 13:34
@rjmunro rjmunro closed this May 18, 2026
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

Successfully merging this pull request may close these issues.

3 participants