Skip to content

Commit

Permalink
Runs checks and tests only on changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Jul 24, 2024
1 parent e49f290 commit 90eec3d
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 22 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
node_modules
temp
test-data
support/licenses
13 changes: 6 additions & 7 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +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 prettier ---'
pnpm prettier-check

echo '--- run linting --- '
pnpm lint
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 @@ -29,20 +29,22 @@ const ENFORCED_BY_ROOT_PACKAGE = [
"@testing-library/dom",
"@testing-library/react",
"@testing-library/jest-dom",
"@testing-library/user-event",
]
"@testing-library/user-event"
];

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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build-packages": "pnpm run -r --aggregate-output build",
"build-docs": "typedoc",
"preview": "vite preview",
"lint": "eslint ./src --cache --ext .js,.ts,.jsx,.tsx,.mjs,.mts,.cjs,.cts",
"lint": "eslint ./src --ext .js,.ts,.jsx,.tsx,.mjs,.mts,.cjs,.cts",
"prettier-check": "pnpm prettier:common -c",
"prettier": "pnpm prettier:common -w",
"prettier:common": "prettier ./src ./docs --ignore-path .eslintignore --cache",
Expand All @@ -22,7 +22,7 @@
"update-shared-versions": "syncpack fix-mismatches",
"prepare": "husky",
"ci:test": "pnpm run clean && pnpm run lint && pnpm run check-types && vitest run",
"ci:version": "pnpm changeset version && pnpm prettier && pnpm install",
"ci:version": "pnpm changeset version && pnpm exec prettier './src/**/CHANGELOG.md' --write --ignore-path .eslintignore && pnpm install",
"ci:publish": "pnpm run clean && pnpm run build-packages && pnpm publish -r --access public && tag-current-versions"
},
"pnpm": {
Expand Down Expand Up @@ -107,10 +107,11 @@
"happy-dom": "^14.12.3",
"husky": "^9.1.1",
"js-yaml": "^4.1.0",
"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",
"typedoc": "^0.26.5",
"typescript": "~5.5.4",
"vite": "^5.3.4",
Expand Down
Loading

0 comments on commit 90eec3d

Please sign in to comment.