Skip to content

Commit e35960f

Browse files
chore(repo): Align method prefixes, remove unused unstable methods (#7361)
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
1 parent f56b6b9 commit e35960f

File tree

81 files changed

+350
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+350
-432
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
"@clerk/clerk-js": major
3+
"@clerk/react": major
4+
"@clerk/nextjs": major
5+
"@clerk/vue": major
6+
"@clerk/astro": major
7+
"@clerk/expo": major
8+
"@clerk/chrome-extension": major
9+
"@clerk/shared": major
10+
"@clerk/ui": major
11+
---
12+
13+
Align experimental/unstable prefixes to use consistent naming:
14+
15+
- Renamed all `__unstable_*` methods to `__internal_*` (for internal APIs)
16+
- Renamed all `experimental__*` and `experimental_*` methods to `__experimental_*` (for beta features)
17+
- Removed deprecated billing-related props and `experimental__forceOauthFirst`
18+
- Moved `createTheme` and `simple` to `@clerk/ui/themes/experimental` export path (removed `__experimental_` prefix since they're now in the experimental export)
19+
20+
**Breaking Changes:**
21+
22+
### @clerk/clerk-js
23+
- `__unstable__environment``__internal_environment`
24+
- `__unstable__updateProps``__internal_updateProps`
25+
- `__unstable__setEnvironment``__internal_setEnvironment`
26+
- `__unstable__onBeforeRequest``__internal_onBeforeRequest`
27+
- `__unstable__onAfterResponse``__internal_onAfterResponse`
28+
- `__unstable__onBeforeSetActive``__internal_onBeforeSetActive` (window global)
29+
- `__unstable__onAfterSetActive``__internal_onAfterSetActive` (window global)
30+
31+
### @clerk/nextjs
32+
- `__unstable_invokeMiddlewareOnAuthStateChange``__internal_invokeMiddlewareOnAuthStateChange`
33+
34+
### @clerk/ui
35+
- `experimental_createTheme` / `__experimental_createTheme``createTheme` (now exported from `@clerk/ui/themes/experimental`)
36+
- `experimental__simple` / `__experimental_simple``simple` (now exported from `@clerk/ui/themes/experimental`)
37+
38+
### @clerk/chrome-extension
39+
- `__unstable__createClerkClient``createClerkClient` (exported from `@clerk/chrome-extension/background`)
40+
41+
### Removed (multiple packages)
42+
- `__unstable_manageBillingUrl` (removed)
43+
- `__unstable_manageBillingLabel` (removed)
44+
- `__unstable_manageBillingMembersLimit` (removed)
45+
- `experimental__forceOauthFirst` (removed)

docs/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ Read more about this in the [`clerk-docs` CONTRIBUTING.md](https://github.com/cl
195195

196196
Then, to preview how the `<Typedoc />` component renders, the `clerk-docs` PR will have a Vercel preview. Or to get local previews set up, see the [section in `clerk/clerk` about setting up local docs](https://github.com/clerk/clerk?tab=readme-ov-file#5-optional-set-up-local-docs).
197197

198+
### Experimental and internal APIs
199+
200+
In some cases, we might need to add new methods to our publicly exposed APIs that are meant for internal use, or as experimental releases before the APIs are stabilized. For internal methods or properties, use the `__internal_` prefix. For experimental methods or properties that are attached to existing APIs, use the `__experimental_` prefix. For new exports, it is also acceptable to export from an `/experimental` subpath. Exports from `/experimental` are not covered by regular SemVer guarantees.
201+
198202
## Opening a Pull Request
199203

200204
1. Search our repository for open or closed [Pull Requests](https://github.com/clerk/javascript/pulls) that relate to your submission. You don't want to duplicate effort.

eslint.config.mjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,61 @@ const noNavigateUseClerk = {
8989
},
9090
};
9191

92+
const noUnstableMethods = {
93+
meta: {
94+
type: 'problem',
95+
docs: {
96+
description: 'Disallow methods or properties starting with `__unstable_`',
97+
recommended: false,
98+
},
99+
messages: {
100+
noUnstable:
101+
'Do not define methods or properties starting with `__unstable_`. For internal APIs, use `__internal_`, for experimental APIs, use `__experimental_`.',
102+
},
103+
schema: [],
104+
},
105+
create(context) {
106+
return {
107+
MemberExpression(node) {
108+
if (
109+
node.property.type === 'Identifier' &&
110+
typeof node.property.name === 'string' &&
111+
node.property.name.startsWith('__unstable_')
112+
) {
113+
context.report({
114+
node: node.property,
115+
messageId: 'noUnstable',
116+
});
117+
}
118+
},
119+
Property(node) {
120+
if (
121+
node.key.type === 'Identifier' &&
122+
typeof node.key.name === 'string' &&
123+
node.key.name.startsWith('__unstable_')
124+
) {
125+
context.report({
126+
node: node.key,
127+
messageId: 'noUnstable',
128+
});
129+
}
130+
},
131+
MethodDefinition(node) {
132+
if (
133+
node.key.type === 'Identifier' &&
134+
typeof node.key.name === 'string' &&
135+
node.key.name.startsWith('__unstable_')
136+
) {
137+
context.report({
138+
node: node.key,
139+
messageId: 'noUnstable',
140+
});
141+
}
142+
},
143+
};
144+
},
145+
};
146+
92147
export default tseslint.config([
93148
{
94149
name: 'repo/ignores',
@@ -161,6 +216,11 @@ export default tseslint.config([
161216
{
162217
name: 'repo/global',
163218
plugins: {
219+
'custom-rules': {
220+
rules: {
221+
'no-unstable-methods': noUnstableMethods,
222+
},
223+
},
164224
'simple-import-sort': pluginSimpleImportSort,
165225
'unused-imports': pluginUnusedImports,
166226
turbo: pluginTurbo,
@@ -176,6 +236,7 @@ export default tseslint.config([
176236
},
177237
},
178238
rules: {
239+
'custom-rules/no-unstable-methods': 'error',
179240
'no-label-var': 'error',
180241
'no-undef-init': 'warn',
181242
'no-restricted-imports': [
@@ -359,11 +420,13 @@ export default tseslint.config([
359420
'custom-rules': {
360421
rules: {
361422
'no-navigate-useClerk': noNavigateUseClerk,
423+
'no-unstable-methods': noUnstableMethods,
362424
},
363425
},
364426
},
365427
rules: {
366428
'custom-rules/no-navigate-useClerk': 'error',
429+
'custom-rules/no-unstable-methods': 'error',
367430
},
368431
},
369432
{

integration/tests/update-props.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ testAgainstRunningApps({ withPattern: ['react.vite.withEmailCodes'] })('sign in
3131
await u.page.waitForFunction(async () => {
3232
// Emulate ClerkProvider being unmounted and mounted again
3333
// as updateProps is going to be called without the default options set by window.Clerk.load()
34-
await (window.Clerk as any).__unstable__updateProps({ options: {} });
34+
await (window.Clerk as any).__internal_updateProps({ options: {} });
3535
});
3636
await u.po.signIn.setIdentifier(fakeUser.email);
3737
await u.po.signIn.continue();

packages/astro/src/internal/create-clerk-instance.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ async function createClerkInstanceInternal<TUi extends Ui = Ui>(options?: AstroC
4545
clerkUiCtor = options?.clerkUiCtor
4646
? Promise.resolve(options.clerkUiCtor)
4747
: loadClerkUiScript(options).then(() => {
48-
if (!window.__unstable_ClerkUiCtor) {
48+
if (!window.__internal_ClerkUiCtor) {
4949
throw new Error('Failed to download latest Clerk UI. Contact support@clerk.com.');
5050
}
5151
// After the check, TypeScript knows it's defined
52-
return window.__unstable_ClerkUiCtor;
52+
return window.__internal_ClerkUiCtor;
5353
});
5454

5555
await clerkPromise;
@@ -106,8 +106,8 @@ function updateClerkOptions<TUi extends Ui = Ui>(options: AstroClerkUpdateOption
106106
options: { ...initOptions, ...options },
107107
appearance: { ...initOptions?.appearance, ...options.appearance },
108108
} as unknown as { options: ClerkOptions; appearance?: any };
109-
// `__unstable__updateProps` is not exposed as public API from `@clerk/types`
110-
void (clerk as any).__unstable__updateProps(updateOptions);
109+
// `__internal_updateProps` is not exposed as public API from `@clerk/types`
110+
void (clerk as any).__internal_updateProps(updateOptions);
111111
}
112112

113113
export { createClerkInstance, updateClerkOptions };

packages/astro/src/react/uiComponents.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const SignIn = withClerk(({ clerk, ...props }: WithClerkProp<SignInProps>
9595
<Portal
9696
mount={clerk?.mountSignIn}
9797
unmount={clerk?.unmountSignIn}
98-
updateProps={(clerk as any)?.__unstable__updateProps}
98+
updateProps={(clerk as any)?.__internal_updateProps}
9999
props={props}
100100
/>
101101
);
@@ -106,7 +106,7 @@ export const SignUp = withClerk(({ clerk, ...props }: WithClerkProp<SignUpProps>
106106
<Portal
107107
mount={clerk?.mountSignUp}
108108
unmount={clerk?.unmountSignUp}
109-
updateProps={(clerk as any)?.__unstable__updateProps}
109+
updateProps={(clerk as any)?.__internal_updateProps}
110110
props={props}
111111
/>
112112
);
@@ -117,7 +117,7 @@ export const UserButton = withClerk(({ clerk, ...props }: WithClerkProp<UserButt
117117
<Portal
118118
mount={clerk?.mountUserButton}
119119
unmount={clerk?.unmountUserButton}
120-
updateProps={(clerk as any)?.__unstable__updateProps}
120+
updateProps={(clerk as any)?.__internal_updateProps}
121121
props={props}
122122
/>
123123
);
@@ -128,7 +128,7 @@ export const UserProfile = withClerk(({ clerk, ...props }: WithClerkProp<UserPro
128128
<Portal
129129
mount={clerk?.mountUserProfile}
130130
unmount={clerk?.unmountUserProfile}
131-
updateProps={(clerk as any)?.__unstable__updateProps}
131+
updateProps={(clerk as any)?.__internal_updateProps}
132132
props={props}
133133
/>
134134
);
@@ -139,7 +139,7 @@ export const OrganizationProfile = withClerk(({ clerk, ...props }: WithClerkProp
139139
<Portal
140140
mount={clerk?.mountOrganizationProfile}
141141
unmount={clerk?.unmountOrganizationProfile}
142-
updateProps={(clerk as any)?.__unstable__updateProps}
142+
updateProps={(clerk as any)?.__internal_updateProps}
143143
props={props}
144144
/>
145145
);
@@ -150,7 +150,7 @@ export const OrganizationSwitcher = withClerk(({ clerk, ...props }: WithClerkPro
150150
<Portal
151151
mount={clerk?.mountOrganizationSwitcher}
152152
unmount={clerk?.unmountOrganizationSwitcher}
153-
updateProps={(clerk as any)?.__unstable__updateProps}
153+
updateProps={(clerk as any)?.__internal_updateProps}
154154
props={props}
155155
/>
156156
);
@@ -161,7 +161,7 @@ export const OrganizationList = withClerk(({ clerk, ...props }: WithClerkProp<Or
161161
<Portal
162162
mount={clerk?.mountOrganizationList}
163163
unmount={clerk?.unmountOrganizationList}
164-
updateProps={(clerk as any)?.__unstable__updateProps}
164+
updateProps={(clerk as any)?.__internal_updateProps}
165165
props={props}
166166
/>
167167
);

packages/astro/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ declare global {
5858
__astro_clerk_component_props: Map<string, Map<string, Record<string, unknown>>>;
5959
__astro_clerk_function_props: Map<string, Map<string, Record<string, unknown>>>;
6060
Clerk: BrowserClerk;
61-
__unstable_ClerkUiCtor?: ClerkUiConstructor;
61+
__internal_ClerkUiCtor?: ClerkUiConstructor;
6262
}
6363
}
6464

packages/chrome-extension/src/internal/clerk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export function createClerkClient({
9494
listener?.add();
9595
}
9696

97-
clerk.__unstable__onAfterResponse(responseHandler(jwt, { isProd }));
98-
clerk.__unstable__onBeforeRequest(requestHandler(jwt, { isProd }));
97+
clerk.__internal_onAfterResponse(responseHandler(jwt, { isProd }));
98+
clerk.__internal_onBeforeRequest(requestHandler(jwt, { isProd }));
9999

100100
return clerk;
101101
}

packages/chrome-extension/src/internal/utils/request-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Clerk } from '@clerk/clerk-js';
33
import { AUTH_HEADER } from '../constants';
44
import type { JWTHandler } from './jwt-handler';
55

6-
type Handler = Parameters<Clerk['__unstable__onBeforeRequest']>[0];
6+
type Handler = Parameters<Clerk['__internal_onBeforeRequest']>[0];
77
type Req = Parameters<Handler>[0];
88

99
/** Append the JWT to the FAPI request */

packages/chrome-extension/src/internal/utils/response-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Clerk } from '@clerk/clerk-js';
33
import { AUTH_HEADER } from '../constants';
44
import type { JWTHandler } from './jwt-handler';
55

6-
type Handler = Parameters<Clerk['__unstable__onAfterResponse']>[0];
6+
type Handler = Parameters<Clerk['__internal_onAfterResponse']>[0];
77
type Res = Parameters<Handler>[1];
88

99
/** Retrieve the JWT to the FAPI response */

0 commit comments

Comments
 (0)