diff --git a/.changeset/quiet-lobsters-greet.md b/.changeset/quiet-lobsters-greet.md new file mode 100644 index 00000000000..7c7def9c34e --- /dev/null +++ b/.changeset/quiet-lobsters-greet.md @@ -0,0 +1,5 @@ +--- +"@clerk/shared": patch +--- + +Bump target/lib for `@clerk/shared` to ES2022 diff --git a/eslint.config.mjs b/eslint.config.mjs index dfe8215af35..8ad097edd9e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -445,6 +445,7 @@ export default tseslint.config([ 'jsdoc/require-description-complete-sentence': 'warn', 'jsdoc/require-param': ['warn', { ignoreWhenAllParamsMissing: true }], 'jsdoc/require-param-description': 'warn', + 'jsdoc/require-description-complete-sentence': 'off', 'jsdoc/require-returns': 'off', 'jsdoc/tag-lines': [ 'warn', diff --git a/packages/clerk-js/vitest.config.mts b/packages/clerk-js/vitest.config.mts index 5a720462cc5..c74923a9bfd 100644 --- a/packages/clerk-js/vitest.config.mts +++ b/packages/clerk-js/vitest.config.mts @@ -32,7 +32,7 @@ export default defineConfig({ }, test: { coverage: { - enabled: true, + enabled: false, provider: 'v8', reporter: ['text', 'json', 'html'], include: ['src/**/*.{ts,tsx}'], diff --git a/packages/clerk-js/vitest.setup.mts b/packages/clerk-js/vitest.setup.mts index d80af3586f9..2e81392e900 100644 --- a/packages/clerk-js/vitest.setup.mts +++ b/packages/clerk-js/vitest.setup.mts @@ -4,11 +4,40 @@ import * as crypto from 'node:crypto'; import { TextDecoder, TextEncoder } from 'node:util'; import { cleanup, configure } from '@testing-library/react'; -import { afterAll, afterEach, beforeAll, vi } from 'vitest'; +import { afterAll, afterEach, beforeAll, beforeEach, vi } from 'vitest'; configure({}); -afterEach(cleanup); +// Track all timers created during tests to clean them up +const activeTimers = new Set>(); +const originalSetTimeout = global.setTimeout; +const originalClearTimeout = global.clearTimeout; + +// Wrap setTimeout to track all timers +global.setTimeout = ((callback: any, delay?: any, ...args: any[]) => { + const timerId = originalSetTimeout(callback, delay, ...args); + activeTimers.add(timerId); + return timerId; +}) as typeof setTimeout; + +// Wrap clearTimeout to remove from tracking +global.clearTimeout = ((timerId?: ReturnType) => { + if (timerId) { + activeTimers.delete(timerId); + originalClearTimeout(timerId); + } +}) as typeof clearTimeout; + +beforeEach(() => { + activeTimers.clear(); +}); + +afterEach(() => { + cleanup(); + // Clear all tracked timers to prevent post-test execution + activeTimers.forEach(timerId => originalClearTimeout(timerId)); + activeTimers.clear(); +}); // Store the original method // eslint-disable-next-line @typescript-eslint/unbound-method @@ -43,6 +72,7 @@ if (typeof window !== 'undefined') { TextEncoder: { value: TextEncoder }, Response: { value: FakeResponse }, crypto: { value: crypto.webcrypto }, + isSecureContext: { value: true, writable: true }, }); // Mock ResizeObserver diff --git a/packages/shared/src/__tests__/deprecated.test.ts b/packages/shared/src/__tests__/deprecated.test.ts index 116770fca1d..d4986924ba8 100644 --- a/packages/shared/src/__tests__/deprecated.test.ts +++ b/packages/shared/src/__tests__/deprecated.test.ts @@ -191,7 +191,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => { test('deprecate class property shows warning', () => { class Example { - someProp: string; + declare someProp: string; constructor(someProp: string) { this.someProp = someProp; } @@ -234,7 +234,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => { test('deprecate class readonly property shows warning', () => { class Example { - readonly someReadOnlyProp: string; + declare readonly someReadOnlyProp: string; constructor(someReadOnlyProp: string) { this.someReadOnlyProp = someReadOnlyProp; } @@ -265,7 +265,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => { test('deprecate class readonly property does not show warning', () => { class Example { - readonly someReadOnlyPropInProd: string; + declare readonly someReadOnlyPropInProd: string; constructor(someReadOnlyPropInProd: string) { this.someReadOnlyPropInProd = someReadOnlyPropInProd; } @@ -293,7 +293,7 @@ describe('deprecatedProperty(cls, propName, warning, isStatic = false)', () => { test('deprecate class readonly property does not show warning', () => { class Example { - readonly someReadOnlyPropInProd: string; + declare readonly someReadOnlyPropInProd: string; constructor(someReadOnlyPropInProd: string) { this.someReadOnlyPropInProd = someReadOnlyPropInProd; } diff --git a/packages/shared/src/react/hooks/useOrganization.tsx b/packages/shared/src/react/hooks/useOrganization.tsx index cabd9472e3b..16219412a3b 100644 --- a/packages/shared/src/react/hooks/useOrganization.tsx +++ b/packages/shared/src/react/hooks/useOrganization.tsx @@ -1,4 +1,3 @@ -/* eslint-disable jsdoc/require-description-complete-sentence */ import type { ClerkPaginatedResponse, GetDomainsParams, diff --git a/packages/shared/src/react/hooks/useOrganizationList.tsx b/packages/shared/src/react/hooks/useOrganizationList.tsx index 7a140eca176..6cdc297c0f8 100644 --- a/packages/shared/src/react/hooks/useOrganizationList.tsx +++ b/packages/shared/src/react/hooks/useOrganizationList.tsx @@ -1,4 +1,3 @@ -/* eslint-disable jsdoc/require-description-complete-sentence */ import type { ClerkPaginatedResponse, CreateOrganizationParams, diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index c791a8f0a33..05919363e30 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2019", + "target": "ES2022", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, @@ -12,7 +12,7 @@ "outDir": "dist", "resolveJsonModule": true, "jsx": "react", - "lib": ["ES6", "DOM", "WebWorker"], + "lib": ["ES2022", "DOM", "WebWorker"], "allowJs": true }, "exclude": ["node_modules"], diff --git a/packages/shared/tsup.config.ts b/packages/shared/tsup.config.ts index 6515b9da11d..9d5b8e121c9 100644 --- a/packages/shared/tsup.config.ts +++ b/packages/shared/tsup.config.ts @@ -24,7 +24,7 @@ export default defineConfig(overrideOptions => { minify: false, sourcemap: true, dts: true, - target: 'es2020', + target: 'es2022', external: ['react', 'react-dom'], esbuildPlugins: [WebWorkerMinifyPlugin as any], define: {