Skip to content

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

Merged
merged 7 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
.vscode
.yalc
/**/scripts/info.js
*.map
*.min.js
*.bundle.js
build
coverage
coverage
dist
/packages/nextjs/examples
node_modules
Expand Down
12 changes: 0 additions & 12 deletions .prettierrc

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"clean": "turbo clean",
"dev": "TURBO_UI=0 FORCE_COLOR=1 turbo dev --filter=@clerk/* --filter=!@clerk/clerk-expo --filter=!@clerk/tanstack-react-start --filter=!@clerk/elements --filter=!@clerk/remix --filter=!@clerk/chrome-extension",
"dev:js": "TURBO_UI=0 FORCE_COLOR=1 turbo dev:current --filter=@clerk/clerk-js",
"format": "prettier --write .",
"format:check": "prettier --cache --check .",
"format": "turbo format && node scripts/format-non-workspace.mjs",
"format:check": "turbo format:check && node scripts/format-non-workspace.mjs --check",
"preinstall": "npx only-allow pnpm",
"integration:secrets": "node ./scripts/1password-keys.mjs",
"lint": "node ./scripts/lint.mjs",
Expand Down
2 changes: 2 additions & 0 deletions packages/agent-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"build": "tsup --env.NODE_ENV production",
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile esm-only",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"build:dts": "tsc --emitDeclarationOnly --declaration",
"copy:components": "rm -rf ./components && mkdir -p ./components/ && cp -r ./src/astro-components/* ./components/ && cp ./src/types.ts ./",
"dev": "tsup --watch --onSuccess \"pnpm build:dts\"",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src env.d.ts",
"lint:attw": "attw --pack . --profile esm-only --ignore-rules internal-resolution-error",
"lint:publint": "pnpm copy:components && publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16 --ignore-rules false-cjs",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/chrome-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"dev:headless": "rspack serve --config rspack.config.js --env variant=\"clerk.headless.browser\"",
"dev:origin": "rspack serve --config rspack.config.js --env devOrigin=http://localhost:${PORT:-4000}",
"dev:sandbox": "rspack serve --config rspack.config.js --env devOrigin=http://localhost:${PORT:-4000} --env sandbox=1",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16 --ignore-rules named-exports",
"lint:publint": "publint || true",
Expand Down
2 changes: 2 additions & 0 deletions packages/dev-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"clerk-dev": "bin/cli.js"
},
"scripts": {
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src"
},
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"build:declarations": "tsc -p tsconfig.declarations.json",
"dev": "tsup --env.NODE_ENV development --watch",
"dev:example": "concurrently \"pnpm dev\" \"pnpm app:dev\"",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-passkeys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"open:android": "open -a \"Android Studio\" example/android",
"open:ios": "xed example/ios",
Expand Down
2 changes: 2 additions & 0 deletions packages/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"publish:local": "pnpm yalc push --replace --sig",
"test": "vitest run",
Expand Down
2 changes: 2 additions & 0 deletions packages/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"build": "tsup --env.NODE_ENV production",
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16 --ignore-rules unexpected-module-syntax",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/localizations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
"postbuild": "node ../../scripts/subpath-workaround.mjs localizations",
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"generate": "tsc src/utils/generate.ts && node src/utils/generate.js && prettier --write src/*.ts",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16"
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16 --ignore-rules unexpected-module-syntax",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile esm-only",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile esm-only",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"postinstall": "node ./scripts/postinstall.mjs",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
Expand Down
2 changes: 2 additions & 0 deletions packages/tanstack-react-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"dev:publish": "pnpm dev -- --env.publish",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile esm-only",
"lint:publint": "publint",
Expand Down
2 changes: 2 additions & 0 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"build": "tsup --env.NODE_ENV production",
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src"
},
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf ./dist",
"dev": "tsc -p tsconfig.build.json --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"build:declarations": "tsc -p tsconfig.declarations.json",
"clean": "rimraf ./dist",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile node16",
"publish:local": "pnpm yalc push --replace --sig"
Expand Down
2 changes: 2 additions & 0 deletions packages/upgrade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"build": "pnpm clean && NODE_ENV=production babel --keep-file-extension --out-dir=dist src --copy-files",
"clean": "rm -rf dist/*",
"dev": "babel --keep-file-extension --out-dir=dist --watch src --copy-files",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src/",
"lint:publint": "publint",
"test": "vitest run",
Expand Down
2 changes: 2 additions & 0 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"build": "tsup --onSuccess \"pnpm build:dts\"",
"build:dts": "vue-tsc --declaration --emitDeclarationOnly -p tsconfig.build.json",
"dev": "tsup --watch",
"format": "node ../../scripts/format-package.mjs",
"format:check": "node ../../scripts/format-package.mjs --check",
"lint": "eslint src",
"lint:attw": "attw --pack . --profile esm-only --ignore-rules internal-resolution-error",
"lint:publint": "publint",
Expand Down
12 changes: 12 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
arrowParens: 'avoid',
bracketSpacing: true,
jsxSingleQuote: true,
plugins: ['prettier-plugin-packagejson', 'prettier-plugin-tailwindcss', 'prettier-plugin-astro'],
printWidth: 120,
semi: true,
singleAttributePerLine: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};
5 changes: 3 additions & 2 deletions scripts/1password-keys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';

import { $ } from 'zx';

const is1PasswordInstalled = await $`op --version`.then(res => res.exitCode === 0).catch(() => false);
Expand All @@ -19,7 +20,7 @@ const envItem = await $`op read 'op://Shared/JS SDKs integration tests/add more/

return null;
})
.catch(err => {
.catch(() => {
return null;
});

Expand All @@ -31,7 +32,7 @@ const keysItem = await $`op read 'op://Shared/JS SDKs integration tests/add more

return null;
})
.catch(err => {
.catch(() => {
return null;
});

Expand Down
90 changes: 90 additions & 0 deletions scripts/format-non-workspace.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

import { globby } from 'globby';
import { $ } from 'zx';

const ROOT_FILE_PATTERNS = ['*.cjs', '*.js', '*.json', '*.md', '*.mjs', '*.ts', '*.yaml'];
const NON_WORKSPACE_PATTERNS = [
'docs/**/*.{js,jsx,ts,tsx,json,md,mdx}',
'integration/**/*.{js,jsx,ts,tsx,json,md,mdx}',
'playground/**/*.{js,jsx,ts,tsx,json,md,mdx}',
'scripts/**/*.{js,jsx,ts,tsx,json,md,mdx}',
];

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);
}
Comment on lines +14 to +50
Copy link
Contributor

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.

Suggested change
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.


async function formatNonWorkspaceFiles() {
const isCheck = process.argv.includes('--check');
const isVerbose = process.argv.includes('--verbose');
const baseArgs = isCheck
? ['prettier', '--cache', '--check', '--ignore-unknown', '--ignore-path', '.prettierignore']
: ['prettier', '--write', '--ignore-unknown', '--ignore-path', '.prettierignore'];

console.log(`${isCheck ? 'Checking' : 'Formatting'} non-workspace files...`);

try {
const existingFiles = await getExistingFiles();

if (existingFiles.length === 0) {
console.log('ℹ️ No non-workspace files found to format');
return;
}

console.log(`📁 Found ${existingFiles.length} files/directories to format`);

if (isVerbose) {
console.log('\n📄 Files to be formatted:');
existingFiles.forEach((file, index) => {
console.log(` ${index + 1}. ${file}`);
});
console.log('');
}

await $`pnpm ${baseArgs} ${existingFiles}`;
console.log(`✅ Non-workspace files ${isCheck ? 'check passed' : 'formatted successfully'}`);
} catch (error) {
console.error(`❌ Non-workspace files ${isCheck ? 'check failed' : 'formatting failed'}`);
if (error.stderr) {
console.error(error.stderr);
}
process.exit(1);
}
}

formatNonWorkspaceFiles().catch(console.error);
Loading
Loading