Skip to content

untile/js-configs

Repository files navigation



A common configs and conventions for Untile projects.

Untile js-config is released under the MIT license. Follow @untiledigital

Setup

This project uses npm workspaces to manage multiple packages.

  • Node.js 20 or higher
  • npm 10.x or higher

Install dependencies

npm install

Run lint

npm run lint

Run full test suite

npm test

Git Hooks

This project uses Lefthook v2.0.0 to manage Git hooks.

Hooks configured:

  • pre-commit:
    • Sorts all package.json files (priority 1)
    • Runs ESLint on staged .js, .ts, .tsx files in parallel (priority 2)
    • Validates branch names (priority 3)
  • commit-msg:
    • Validates commit messages with commitlint

Setup

Hooks are automatically installed when you run npm install (via the prepare script).

To manually reinstall hooks:

npx lefthook install

Skip hooks temporarily

# Skip all hooks
LEFTHOOK=0 git commit -m "message"

# Skip specific command
LEFTHOOK_EXCLUDE=validate-branch git commit -m "message"

Debug hooks

npx lefthook run pre-commit --verbose

Adding new packages

To ensure that every part of the monorepo infrastructure works as intended, every package must be located within the ./packages/<new-package-name> folder.

Release setup

After creating a package, add a release script to the ./packages/<new-package-name>/package.json file, and another one to the main ./package.json file with:

  "release:<new-package-name>": "npm run release --workspace=@untile/<new-package-name>",

Changelog setup

When creating new packages, keep in mind that the auto labeler must have the new package added in .github/labeler, so that it can label its pull requests accordingly and they are included in the correct CHANGELOG.md. To add new packages to auto labeler run:

sh bin/auto-labeler.sh

Release & Publish

Make sure that you have configured GITHUB_TOKEN in your globals. This will also publish your packages that have changes to NPM.

npm run release:[<package-name>] [<new version> | major | minor | patch]
git push origin master && git push --tags