Skip to content

Commit

Permalink
Run hooks and tests for changed files only
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Jul 24, 2024
1 parent 0880057 commit 6411dbb
Show file tree
Hide file tree
Showing 8 changed files with 523 additions and 70 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
node_modules
temp
test-data
test-data
support/licenses
14 changes: 6 additions & 8 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ if [ "$NO_VERIFY" ]; then
exit 0
fi


echo '--- checking for consistent dependencies across packages'
echo '--- checking for consistent dependencies across packages ---'
pnpm lint-shared-versions

echo '--- run linting --- '
pnpm lint

echo '--- run prettier ---'
pnpm prettier-check
echo '--- check code style ---'
pnpm exec lint-staged

echo '--- run typescript check ---'
pnpm check-types

echo '--- run tests ---'
CI=1 pnpm test run # CI=1 disallows `.only` in tests
# CI=1 disallows `.only` in tests
# --changed only runs the tests affected by changed files
CI=1 pnpm exec vitest run --changed --passWithNoTests
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}": ["prettier --write --ignore-path .eslintignore", "eslint"],
"*.{md,json,css,scss,html}": ["prettier --write --ignore-path .eslintignore"]
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"tabWidth": 4,
"trailingComma": "none",
"singleQuote": false,
"quoteProps": "consistent",
"quoteProps": "preserve",
"printWidth": 100,
"overrides": [
{
Expand Down
10 changes: 6 additions & 4 deletions .syncpackrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ const ENFORCED_BY_ROOT_PACKAGE = [
"@open-pioneer/runtime",
"@open-pioneer/integration",
"@open-pioneer/test-utils",
"@open-pioneer/chakra-integration",
]
"@open-pioneer/chakra-integration"
];

module.exports = {
// Indent used in package.json files
indent: " ",


dependencyTypes: ["prod", "peer", "dev"],

// The first entry here forces all packages in the workspace to use the dependency version
// from the root package.json when the dependency name is listed in `ENFORCED_BY_ROOT_PACKAGE`.
// See https://jamiemason.github.io/syncpack/config/version-groups for advanced usage of version groups.
versionGroups: [
{
dependencies: ENFORCED_BY_ROOT_PACKAGE,
packages: ["**"], // packages where the pinned version is enforced
packages: ["**"], // packages where the pinned version is enforced
snapTo: [ROOT_PACKAGE_NAME] // package that defines the version to use
}
]
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 2024-07-24

- Improve the commit hooks (`.husky/pre-commit`).
Commit hooks run during `git commit` to check the code style and run tests.
Previously, all files within the project were checked for style issues and all unit tests were run.

With this update, only changed files will be checked (via [lint-staged](https://www.npmjs.com/package/lint-staged)) and only tests affected by changed files will be re-executed (via `vitest --changed`).
Also, prettier will now format staged files automatically -- it is no longer necessary to run `prettier` manually in most cases.

This change significantly improves the time it takes to commit a change.
Unfortunately, TypeScript will still run type checks on the entire code base.

- Update `syncpack`.

## 2024-07-23

- Update the license report script. It can now handle dependency license information returned by pnpm 9.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@
"husky": "^9.1.1",
"js-yaml": "^4.1.0",
"jsdom": "^24.1.1",
"lint-staged": "^15.2.7",
"prettier": "^3.3.3",
"rimraf": "^5.0.9",
"sass": "^1.77.8",
"syncpack": "10.5.1",
"syncpack": "12.3.0",
"tsx": "^4.16.2",
"typedoc": "^0.26.5",
"typescript": "~5.5.4",
Expand Down
Loading

0 comments on commit 6411dbb

Please sign in to comment.