-
Notifications
You must be signed in to change notification settings - Fork 369
chore(repo): Run format through turbo #6291
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
Conversation
🦋 Changeset detectedLatest commit: c9bfd67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughThis change restructures the project's code formatting workflow. The Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
scripts/format-non-workspace.mjs (1)
1-91
: Add tests to cover the script functionality.According to the coding guidelines, tests should be added to cover changes. This script performs important build automation functionality and would benefit from testing.
Consider adding tests for:
getExistingFiles()
function with various file patternsformatNonWorkspaceFiles()
function with different command-line arguments- Error handling scenarios
- Integration tests for the complete formatting workflow
The tests could be placed in a
scripts/__tests__/
directory or similar location.
🧹 Nitpick comments (5)
scripts/1password-keys.mjs (1)
23-25
: Do not silently swallow 1Password CLI errorsRemoving the
err
parameter prevents any diagnostics from being surfaced ifop read
fails for reasons other than a non-zero exit code. Swallowing those details can turn debugging into guesswork.- .catch(() => { - return null; - }); + .catch(err => { + // Log once at debug level – keeps CI output clean but preserves the evidence. + console.debug('op read failed:', err?.stderr ?? err); + return null; + });Duplicating this change for both reads maintains parity.
No tests exercise this script; consider a small integration test that mocks
op
and asserts that the script propagates non-zero exit codes / stderr correctly.Also applies to: 35-37
.prettierignore (1)
11-14
: Tests for the new formatting workflow are missingNone of the changes that introduce
scripts/format-package.mjs
are covered by tests. A minimal check (e.g. spawning the script in--check
mode against a fixture) would prevent regressions.Happy to scaffold a Jest test harness that exercises the formatter end-to-end if helpful.
packages/localizations/package.json (1)
103-105
: Consider re-using the new formatter inside the existing “generate” script
You already added the package-levelformat
/format:check
scripts, but the “generate” task still calls Prettier directly. Switching to the new formatter keeps one single point of truth:- "generate": "tsc src/utils/generate.ts && node src/utils/generate.js && prettier --write src/*.ts", + "generate": "tsc src/utils/generate.ts && node src/utils/generate.js && pnpm run format",Optional, but it avoids diverging CLI flags/config in the future.
scripts/format-package.mjs (1)
7-9
: Consider adding --cache flag for consistency.The script uses
--cache
only in check mode but not in write mode. For consistency and performance, consider adding--cache
to both modes.const baseArgs = isCheck - ? ['prettier', '--cache', '--check', '--ignore-path', '../../.prettierignore'] - : ['prettier', '--write', '--ignore-path', '../../.prettierignore']; + ? ['prettier', '--cache', '--check', '--ignore-path', '../../.prettierignore'] + : ['prettier', '--cache', '--write', '--ignore-path', '../../.prettierignore'];This aligns with the pattern used in
scripts/format-non-workspace.mjs
where--cache
is used in both modes.scripts/format-non-workspace.mjs (1)
90-90
: Ensure proper exit code for unhandled errors.While the main function handles most errors internally, consider ensuring proper exit code for any unhandled errors at the top level.
-formatNonWorkspaceFiles().catch(console.error); +formatNonWorkspaceFiles().catch((error) => { + console.error(error); + process.exit(1); +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (32)
.prettierignore
(1 hunks).prettierrc
(0 hunks)package.json
(1 hunks)packages/agent-toolkit/package.json
(1 hunks)packages/astro/package.json
(1 hunks)packages/backend/package.json
(1 hunks)packages/chrome-extension/package.json
(1 hunks)packages/clerk-js/package.json
(1 hunks)packages/dev-cli/package.json
(1 hunks)packages/elements/package.json
(1 hunks)packages/expo-passkeys/package.json
(1 hunks)packages/expo/package.json
(1 hunks)packages/express/package.json
(1 hunks)packages/fastify/package.json
(1 hunks)packages/localizations/package.json
(1 hunks)packages/nextjs/package.json
(1 hunks)packages/nuxt/package.json
(1 hunks)packages/react-router/package.json
(1 hunks)packages/react/package.json
(1 hunks)packages/remix/package.json
(1 hunks)packages/shared/package.json
(1 hunks)packages/tanstack-react-start/package.json
(1 hunks)packages/testing/package.json
(1 hunks)packages/themes/package.json
(1 hunks)packages/types/package.json
(1 hunks)packages/upgrade/package.json
(1 hunks)packages/vue/package.json
(1 hunks)prettier.config.mjs
(1 hunks)scripts/1password-keys.mjs
(3 hunks)scripts/format-non-workspace.mjs
(1 hunks)scripts/format-package.mjs
(1 hunks)turbo.json
(1 hunks)
💤 Files with no reviewable changes (1)
- .prettierrc
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/remix/package.json
packages/chrome-extension/package.json
packages/express/package.json
packages/elements/package.json
packages/fastify/package.json
packages/agent-toolkit/package.json
packages/tanstack-react-start/package.json
packages/clerk-js/package.json
packages/dev-cli/package.json
packages/backend/package.json
packages/nuxt/package.json
packages/expo-passkeys/package.json
package.json
packages/astro/package.json
packages/testing/package.json
packages/upgrade/package.json
packages/expo/package.json
packages/nextjs/package.json
packages/localizations/package.json
packages/vue/package.json
turbo.json
packages/react-router/package.json
packages/react/package.json
packages/themes/package.json
packages/types/package.json
packages/shared/package.json
packages/*/package.json
📄 CodeRabbit Inference Engine (.cursor/rules/global.mdc)
All publishable packages should be placed under the packages/ directory
packages/*/package.json
: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.
Files:
packages/remix/package.json
packages/chrome-extension/package.json
packages/express/package.json
packages/elements/package.json
packages/fastify/package.json
packages/agent-toolkit/package.json
packages/tanstack-react-start/package.json
packages/clerk-js/package.json
packages/dev-cli/package.json
packages/backend/package.json
packages/nuxt/package.json
packages/expo-passkeys/package.json
packages/astro/package.json
packages/testing/package.json
packages/upgrade/package.json
packages/expo/package.json
packages/nextjs/package.json
packages/localizations/package.json
packages/vue/package.json
packages/react-router/package.json
packages/react/package.json
packages/themes/package.json
packages/types/package.json
packages/shared/package.json
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/remix/package.json
packages/chrome-extension/package.json
packages/express/package.json
packages/elements/package.json
packages/fastify/package.json
packages/agent-toolkit/package.json
packages/tanstack-react-start/package.json
packages/clerk-js/package.json
packages/dev-cli/package.json
packages/backend/package.json
packages/nuxt/package.json
packages/expo-passkeys/package.json
package.json
packages/astro/package.json
packages/testing/package.json
scripts/format-non-workspace.mjs
prettier.config.mjs
packages/upgrade/package.json
packages/expo/package.json
scripts/1password-keys.mjs
packages/nextjs/package.json
packages/localizations/package.json
packages/vue/package.json
turbo.json
packages/react-router/package.json
packages/react/package.json
packages/themes/package.json
packages/types/package.json
packages/shared/package.json
scripts/format-package.mjs
scripts/**
📄 CodeRabbit Inference Engine (.cursor/rules/global.mdc)
Build automation and utility scripts should be placed under the scripts/ directory
Files:
scripts/format-non-workspace.mjs
scripts/1password-keys.mjs
scripts/format-package.mjs
scripts/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Build and automation scripts must be located in the 'scripts/' directory.
Files:
scripts/format-non-workspace.mjs
scripts/1password-keys.mjs
scripts/format-package.mjs
packages/localizations/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Localization files must be placed in 'packages/localizations/'.
Files:
packages/localizations/package.json
🧬 Code Graph Analysis (1)
scripts/format-package.mjs (2)
scripts/format-non-workspace.mjs (2)
isCheck
(53-53)baseArgs
(55-57)scripts/notify.mjs (1)
process
(6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (30)
.prettierignore (1)
11-14
: LGTM – sensible ignore additionsAdding
*.map
,*.min.js
, and*.bundle.js
keeps Prettier from wasting cycles on generated artefacts, and the duplicatecoverage
entry is gone. ✅packages/clerk-js/package.json (1)
47-48
: Formatting scripts added – looks goodThe package now delegates to the shared formatter, ensuring consistent behaviour across the monorepo.
packages/remix/package.json (1)
70-71
: Formatting scripts added – looks goodConsistent with other packages and the new tooling.
packages/elements/package.json (1)
66-67
: Formatting scripts added – looks goodBrings the package in line with the monorepo-wide formatting workflow.
packages/backend/package.json (1)
96-97
: Formatting scripts added – LGTMThe
format
andformat:check
scripts correctly point two levels up to the sharedscripts/format-package.mjs
, ensuring package-local formatting is now unified with the monorepo’s new workflow. No issues spotted.packages/fastify/package.json (1)
58-60
: Consistent formatting workflow – looks goodThese new scripts mirror the pattern adopted across the repo and resolve to the root formatter without hard-coding Prettier flags in each package. No action needed.
packages/agent-toolkit/package.json (1)
42-44
: Unified format scripts – approvedScripts are correctly wired to the shared formatter, keeping the package in sync with monorepo conventions. Implementation is sound.
packages/express/package.json (1)
60-61
: Format commands added – looks correctThe relative path resolves cleanly from
packages/express
, and the separation between write and check modes matches other packages. All good.packages/chrome-extension/package.json (1)
41-42
: Formatting integration – no concerns
format
/format:check
scripts align with the new monorepo standard; pathing and flags are correct. ✅packages/themes/package.json (1)
37-38
: Add standardizedformat
/format:check
scripts – looks correctThe relative path (
../../scripts/format-package.mjs
) resolves correctly frompackages/themes
, and the flags mirror the convention adopted across the repo. No further action needed.packages/react-router/package.json (1)
75-76
: Formatting scripts aligned with monorepo convention – good to mergeThe added scripts are consistent with other workspaces and will pick up the centralized Prettier config. 👍
packages/upgrade/package.json (1)
22-23
: Consistent formatting hooks added – LGTMThe
format
andformat:check
targets match the new tooling pipeline; no issues spotted.packages/nuxt/package.json (1)
62-63
: Uniform Prettier scripts – implementation correctThe invocation path and
--check
flag are accurate; integrates cleanly with the updated workflow.packages/tanstack-react-start/package.json (1)
62-63
: Formatting scripts added successfullyScripts follow the shared pattern; confirms to monorepo standards.
packages/react/package.json (1)
82-83
: Consistent formatting scripts added – LGTMThe new
format
andformat:check
scripts follow the convention adopted across the monorepo and correctly reference the sharedscripts/format-package.mjs
. No issues spotted.packages/expo/package.json (1)
74-75
: Formatting scripts align with monorepo conventionThe added scripts are accurate and will resolve to the repo-root formatter from
packages/expo
. Looks good.packages/vue/package.json (1)
51-52
: Formatting scripts look correctPathing (
../../
) correctly reaches the repo root frompackages/vue
; nothing else to address.packages/expo-passkeys/package.json (1)
28-29
: LGTM – matches standardized formatter hookNo functional or structural issues detected with the added scripts.
packages/testing/package.json (1)
72-73
: Formatter scripts added correctlyScripts are consistent with the rest of the workspace and will keep package formatting in sync.
packages/dev-cli/package.json (1)
22-24
: Consistent formatting hook added – looks good
Scripts correctly point two levels up to the sharedscripts/format-package.mjs
, matching the repo layout and keeping formatting logic DRY.packages/shared/package.json (1)
134-136
: Formatting scripts added – alignment with monorepo workflow
Path and flags match the new shared formatter; nothing else to flag.packages/types/package.json (1)
37-39
: Formatting scripts added – looks correct
The package inherits Node 18 which supports.mjs
; scripts are consistent with the rest of the workspace.packages/nextjs/package.json (1)
72-74
: Formatting scripts integrated – all good
Correct relative path, consistent with other packages, no further action needed.packages/astro/package.json (1)
83-84
: LGTM! Consistent formatting script integration.The new formatting scripts correctly reference the shared
format-package.mjs
script and follow the established pattern with the--check
flag for format verification.prettier.config.mjs (1)
1-12
: Well-structured Prettier configuration.The ESM configuration correctly exports standard Prettier options with appropriate plugins for the repository's needs. The settings are reasonable and consistent with modern formatting practices.
scripts/format-package.mjs (1)
11-21
: Solid error handling and execution logic.The script properly handles both success and error cases with appropriate logging and exit codes. The use of zx for command execution is clean and the relative path handling is correct.
package.json (1)
15-16
: Well-designed two-phase formatting approach.The updated scripts effectively split formatting responsibilities: Turbo handles workspace packages (with caching and parallelization), while the separate script handles non-workspace files. This should achieve the PR's goal of improved formatting performance.
turbo.json (1)
146-194
: Comprehensive and well-structured turbo formatting tasks.The new
format
task and updatedformat:check
task have identical, comprehensive input patterns that appropriately cover all formattable file types while excluding generated files. Including the prettier configuration files in inputs ensures proper cache invalidation when formatting rules change.scripts/format-non-workspace.mjs (2)
1-12
: LGTM! Well-structured imports and file patterns.The shebang, ESM imports, and file pattern definitions are correctly implemented. The patterns appropriately target root-level files and non-workspace directories while covering relevant file extensions for formatting.
52-88
: Excellent implementation with comprehensive error handling.The function is well-structured with:
- Proper command-line argument parsing
- Informative user feedback with appropriate messaging
- Good error handling with proper exit codes
- Helpful verbose output for debugging
The use of zx's
$
template for command execution is appropriate and the prettier arguments are correctly configured for both check and write modes.
async function getExistingFiles() { | ||
const existingFiles = []; | ||
|
||
for (const pattern of ROOT_FILE_PATTERNS) { | ||
try { | ||
const matches = await globby(pattern, { | ||
ignore: ['node_modules/**', '**/node_modules/**', 'packages/**'], | ||
}); | ||
existingFiles.push(...matches); | ||
} catch { | ||
// Pattern didn't match any files, skip it | ||
} | ||
} | ||
|
||
for (const pattern of NON_WORKSPACE_PATTERNS) { | ||
try { | ||
const matches = await globby(pattern, { | ||
ignore: [ | ||
'node_modules/**', | ||
'**/node_modules/**', | ||
'**/dist/**', | ||
'**/build/**', | ||
'**/coverage/**', | ||
'**/.turbo/**', | ||
'**/.next/**', | ||
'**/.tsup/**', | ||
'**/.cache/**', | ||
], | ||
}); | ||
existingFiles.push(...matches); | ||
} catch { | ||
// Pattern didn't match any files, skip it | ||
} | ||
} | ||
|
||
return existingFiles.filter(Boolean); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve error handling specificity.
The try-catch blocks are too broad and will catch all errors, not just cases where patterns don't match files. This could hide legitimate errors like permission issues or invalid glob patterns.
Consider more specific error handling:
try {
const matches = await globby(pattern, {
ignore: ['node_modules/**', '**/node_modules/**', 'packages/**'],
});
existingFiles.push(...matches);
- } catch {
- // Pattern didn't match any files, skip it
+ } catch (error) {
+ // Only skip if it's a pattern matching issue, otherwise re-throw
+ if (error.code !== 'ENOENT' && !error.message.includes('no matches')) {
+ throw error;
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async function getExistingFiles() { | |
const existingFiles = []; | |
for (const pattern of ROOT_FILE_PATTERNS) { | |
try { | |
const matches = await globby(pattern, { | |
ignore: ['node_modules/**', '**/node_modules/**', 'packages/**'], | |
}); | |
existingFiles.push(...matches); | |
} catch { | |
// Pattern didn't match any files, skip it | |
} | |
} | |
for (const pattern of NON_WORKSPACE_PATTERNS) { | |
try { | |
const matches = await globby(pattern, { | |
ignore: [ | |
'node_modules/**', | |
'**/node_modules/**', | |
'**/dist/**', | |
'**/build/**', | |
'**/coverage/**', | |
'**/.turbo/**', | |
'**/.next/**', | |
'**/.tsup/**', | |
'**/.cache/**', | |
], | |
}); | |
existingFiles.push(...matches); | |
} catch { | |
// Pattern didn't match any files, skip it | |
} | |
} | |
return existingFiles.filter(Boolean); | |
} | |
async function getExistingFiles() { | |
const existingFiles = []; | |
for (const pattern of ROOT_FILE_PATTERNS) { | |
try { | |
const matches = await globby(pattern, { | |
ignore: ['node_modules/**', '**/node_modules/**', 'packages/**'], | |
}); | |
existingFiles.push(...matches); | |
} catch (error) { | |
// Only skip if it's a pattern-matching issue, otherwise re-throw | |
if (error.code !== 'ENOENT' && !error.message.includes('no matches')) { | |
throw error; | |
} | |
} | |
} | |
for (const pattern of NON_WORKSPACE_PATTERNS) { | |
try { | |
const matches = await globby(pattern, { | |
ignore: [ | |
'node_modules/**', | |
'**/node_modules/**', | |
'**/dist/**', | |
'**/build/**', | |
'**/coverage/**', | |
'**/.turbo/**', | |
'**/.next/**', | |
'**/.tsup/**', | |
'**/.cache/**', | |
], | |
}); | |
existingFiles.push(...matches); | |
} catch { | |
// Pattern didn't match any files, skip it | |
} | |
} | |
return existingFiles.filter(Boolean); | |
} |
🤖 Prompt for AI Agents
In scripts/format-non-workspace.mjs between lines 14 and 50, the current
try-catch blocks catch all errors broadly, which can mask real issues like
permission errors or invalid patterns. Refactor the error handling to catch only
the specific errors related to no matches found or handle the globby call
results without relying on exceptions for control flow. You can check if matches
are empty instead of using try-catch, or inspect error types before deciding to
ignore them, ensuring legitimate errors are not suppressed.
Description
The primary goal here is to speed up formatting of the repo code by only running the prettier commands on changed packages, instead of all of the non-ignored files in the repo. The total time of formatting the whole repo is about 15 seconds. Executed multiple times a day every day...
Fixes: USER-2409
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit