Skip to content

Commit 09cd0de

Browse files
committed
fix: remove globalThis not compatible with next
1 parent 1a1df89 commit 09cd0de

File tree

38 files changed

+303
-300
lines changed

38 files changed

+303
-300
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ jobs:
323323
mv /tmp/docs/.buildx-cache-new /tmp/docs/.buildx-cache
324324
325325
e2e:
326-
timeout-minutes: 10
326+
timeout-minutes: 20
327327
runs-on: ubuntu-latest
328328
needs: [typecheck, format]
329329
env:

.oxlintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
],
2929
"overrides": [
3030
{
31-
"files": ["**/__stories__/**/*.{ts,tsx}", "**/__tests__/**/*.{ts,tsx}"],
31+
"files": ["**/__stories__/**/*.{ts,tsx}", "**/__tests__/**/*.{ts,tsx}", ".storybook/**/*.{ts,tsx}"],
3232
"rules": {
3333
"eslint/no-console": "off",
3434
"eslint/no-alert": "off",
35-
"import/no-anonymous-default-export": "off"
35+
"import/no-anonymous-default-export": "off",
36+
"import/no-unassigned-import": "off"
3637
}
3738
},
3839
{
@@ -267,12 +268,13 @@
267268
"react/no-unknown-property": "error",
268269
"react/react-in-jsx-scope": "off",
269270
"react/require-render-return": "error",
271+
"react/no-danger": "off",
270272
"unicorn/no-instanceof-builtins": "error",
271273
"unicorn/prefer-array-index-of": "off",
272274
"unicorn/prefer-array-find": "off",
273275
"unicorn/no-for-loop": "off",
274276
"unicorn/prefer-object-from-entries": "off",
275-
"unicorn/prefer-global-this": "error",
277+
"unicorn/prefer-global-this": "off",
276278
"unicorn/catch-error-name": "error",
277279
"unicorn/empty-brace-spaces": "error",
278280
"unicorn/error-message": "off",

.storybook/components/DocsContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Global, ThemeProvider } from '@emotion/react'
2+
import type {
3+
DocsContainerProps as BaseContainerProps} from '@storybook/addon-docs/blocks';
24
import {
35
DocsContainer as BaseContainer,
4-
DocsContainerProps as BaseContainerProps,
56
Unstyled,
67
} from '@storybook/addon-docs/blocks'
78
import { consoleLightTheme as lightTheme } from '@ultraviolet/themes'
8-
import { ReactNode, cloneElement, isValidElement, useState } from 'react'
9+
import type { ReactNode} from 'react';
10+
import { cloneElement, isValidElement, useState } from 'react'
911
import { globalStyles } from './globalStyle'
1012
import '@ultraviolet/fonts/fonts.css'
1113
import { GlobalAlert } from '@ultraviolet/ui'
@@ -49,7 +51,7 @@ const DocsContainer = ({ children, context }: DocsContainerProps) => {
4951

5052
if (
5153
import.meta.env['STORYBOOK_ENVIRONMENT'] === 'production' &&
52-
globalThis.location.hostname === 'storybook.ultraviolet.scaleway.com'
54+
window.location.hostname === 'storybook.ultraviolet.scaleway.com'
5355
) {
5456
fetch('https://api.github.com/repos/scaleway/ultraviolet/branches/beta')
5557
.then((data) => {
@@ -68,7 +70,7 @@ const DocsContainer = ({ children, context }: DocsContainerProps) => {
6870
{isBeta ?
6971
<GlobalAlert
7072
buttonText="Access to Beta"
71-
onClickButton={() => globalThis.top?.location.assign('https://beta.storybook.ultraviolet.scaleway.com')}
73+
onClickButton={() => window.top?.location.assign('https://beta.storybook.ultraviolet.scaleway.com')}
7274
closable={false}
7375
>
7476
A Beta version is available. Please use this version if your dependencies include the Beta release.

examples/next/src/pages/_app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ const App = ({ Component, pageProps }: AppProps) => {
5757
} as const
5858

5959
useEffect(() => {
60-
if (typeof globalThis !== 'undefined') {
60+
if (typeof window !== 'undefined') {
6161
const storageTheme = localStorage.getItem('theme')
6262
if (storageTheme) {
6363
setTheme(storageTheme as 'light' | 'dark')
6464
} else {
65-
const isThemeDark = globalThis.matchMedia(
65+
const isThemeDark = window.matchMedia(
6666
'(prefers-color-scheme: dark)',
6767
).matches
6868

packages/nextjs/src/ThemeRegistry.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export const ThemeRegistry = ({ children, theme }: ThemeRegistryProps) => {
5151

5252
return (
5353
<style
54-
// eslint-disable-next-line react/no-danger
5554
dangerouslySetInnerHTML={{
5655
__html: styles,
5756
}}

packages/plus/src/components/ContentCard/__tests__/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import illustration from '../assets/illustration.png'
66
describe('ContentCard', () => {
77
beforeEach(() => {
88
vi.useFakeTimers()
9-
vi.spyOn(globalThis.Math, 'random').mockReturnValue(0.4155913669444804)
9+
vi.spyOn(global.Math, 'random').mockReturnValue(0.4155913669444804)
1010
})
1111

1212
afterEach(() => {
1313
vi.useRealTimers()
14-
vi.spyOn(globalThis.Math, 'random').mockRestore()
14+
vi.spyOn(global.Math, 'random').mockRestore()
1515
})
1616

1717
test('renders correctly with required title', () => {

packages/plus/src/components/ContentCardGroup/__tests__/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { ContentCardGroup } from '..'
44

55
describe('ContentCardGroup', () => {
66
beforeEach(() => {
7-
vi.spyOn(globalThis.Math, 'random').mockReturnValue(0.4155913669444804)
7+
vi.spyOn(global.Math, 'random').mockReturnValue(0.4155913669444804)
88
})
99

1010
afterEach(() => {
11-
vi.spyOn(globalThis.Math, 'random').mockRestore()
11+
vi.spyOn(global.Math, 'random').mockRestore()
1212
})
1313

1414
test('renders correctly with required title & hread', () =>

packages/plus/src/components/EstimateCost/__tests__/__snapshots__/CustomUnitInput.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ exports[`EstimateCost - CustomUnitInput > render default values 1`] = `
488488
class="emotion-14 emotion-1"
489489
>
490490
<div
491+
aria-controls="«r2»"
491492
aria-expanded="false"
492-
aria-haspopup="listbox"
493493
class="emotion-16 emotion-17"
494494
data-disabled="false"
495495
data-dropdownvisible="false"

packages/plus/src/components/EstimateCost/__tests__/__snapshots__/Item.test.tsx.snap

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ exports[`EstimateCost - Item > render with labelTextVariant 1`] = `
19681968
class="emotion-56 emotion-57"
19691969
data-size="medium"
19701970
data-testid="unit-input"
1971-
id="«rq»"
1971+
id="«rs»"
19721972
max="9007199254740991"
19731973
min="1"
19741974
name="iteration-value"
@@ -1983,8 +1983,8 @@ exports[`EstimateCost - Item > render with labelTextVariant 1`] = `
19831983
class="emotion-58 emotion-59 emotion-60"
19841984
>
19851985
<div
1986-
aria-controls="«rs»"
1987-
aria-describedby="«rs»"
1986+
aria-controls="«ru»"
1987+
aria-describedby="«ru»"
19881988
class="emotion-61 emotion-62"
19891989
data-container-full-width="true"
19901990
tabindex="-1"
@@ -1993,8 +1993,8 @@ exports[`EstimateCost - Item > render with labelTextVariant 1`] = `
19931993
class="emotion-63 emotion-1"
19941994
>
19951995
<div
1996+
aria-controls="«ru»"
19961997
aria-expanded="false"
1997-
aria-haspopup="listbox"
19981998
class="emotion-65 emotion-66"
19991999
data-disabled="false"
20002000
data-dropdownvisible="false"
@@ -3189,8 +3189,8 @@ exports[`EstimateCost - Item > render with noPrice and noBorder 1`] = `
31893189
class="emotion-63 emotion-1"
31903190
>
31913191
<div
3192+
aria-controls="«r5»"
31923193
aria-expanded="false"
3193-
aria-haspopup="listbox"
31943194
class="emotion-65 emotion-66"
31953195
data-disabled="false"
31963196
data-dropdownvisible="false"
@@ -5286,7 +5286,7 @@ exports[`EstimateCost - Item > render with notice 1`] = `
52865286
class="emotion-59 emotion-60"
52875287
data-size="medium"
52885288
data-testid="unit-input"
5289-
id="«r21»"
5289+
id="«r26»"
52905290
max="9007199254740991"
52915291
min="1"
52925292
name="iteration-value"
@@ -5301,8 +5301,8 @@ exports[`EstimateCost - Item > render with notice 1`] = `
53015301
class="emotion-61 emotion-62 emotion-63"
53025302
>
53035303
<div
5304-
aria-controls="«r23»"
5305-
aria-describedby="«r23»"
5304+
aria-controls="«r28»"
5305+
aria-describedby="«r28»"
53065306
class="emotion-64 emotion-65"
53075307
data-container-full-width="true"
53085308
tabindex="-1"
@@ -5311,8 +5311,8 @@ exports[`EstimateCost - Item > render with notice 1`] = `
53115311
class="emotion-66 emotion-1"
53125312
>
53135313
<div
5314+
aria-controls="«r28»"
53145315
aria-expanded="false"
5315-
aria-haspopup="listbox"
53165316
class="emotion-68 emotion-69"
53175317
data-disabled="false"
53185318
data-dropdownvisible="false"
@@ -7402,7 +7402,7 @@ exports[`EstimateCost - Item > render with priceText 1`] = `
74027402
class="emotion-56 emotion-57"
74037403
data-size="medium"
74047404
data-testid="unit-input"
7405-
id="«r16»"
7405+
id="«r19»"
74067406
max="9007199254740991"
74077407
min="1"
74087408
name="iteration-value"
@@ -7417,8 +7417,8 @@ exports[`EstimateCost - Item > render with priceText 1`] = `
74177417
class="emotion-58 emotion-59 emotion-60"
74187418
>
74197419
<div
7420-
aria-controls="«r18»"
7421-
aria-describedby="«r18»"
7420+
aria-controls="«r1b»"
7421+
aria-describedby="«r1b»"
74227422
class="emotion-61 emotion-62"
74237423
data-container-full-width="true"
74247424
tabindex="-1"
@@ -7427,8 +7427,8 @@ exports[`EstimateCost - Item > render with priceText 1`] = `
74277427
class="emotion-63 emotion-1"
74287428
>
74297429
<div
7430+
aria-controls="«r1b»"
74307431
aria-expanded="false"
7431-
aria-haspopup="listbox"
74327432
class="emotion-65 emotion-66"
74337433
data-disabled="false"
74347434
data-dropdownvisible="false"
@@ -9497,7 +9497,7 @@ exports[`EstimateCost - Item > render with tabulation 1`] = `
94979497
class="emotion-56 emotion-57"
94989498
data-size="medium"
94999499
data-testid="unit-input"
9500-
id="«re»"
9500+
id="«rf»"
95019501
max="9007199254740991"
95029502
min="1"
95039503
name="iteration-value"
@@ -9512,8 +9512,8 @@ exports[`EstimateCost - Item > render with tabulation 1`] = `
95129512
class="emotion-58 emotion-59 emotion-60"
95139513
>
95149514
<div
9515-
aria-controls="«rg»"
9516-
aria-describedby="«rg»"
9515+
aria-controls="«rh»"
9516+
aria-describedby="«rh»"
95179517
class="emotion-61 emotion-62"
95189518
data-container-full-width="true"
95199519
tabindex="-1"
@@ -9522,8 +9522,8 @@ exports[`EstimateCost - Item > render with tabulation 1`] = `
95229522
class="emotion-63 emotion-1"
95239523
>
95249524
<div
9525+
aria-controls="«rh»"
95259526
aria-expanded="false"
9526-
aria-haspopup="listbox"
95279527
class="emotion-65 emotion-66"
95289528
data-disabled="false"
95299529
data-dropdownvisible="false"
@@ -11524,8 +11524,8 @@ exports[`EstimateCost - Item > render with tooltipInfo 1`] = `
1152411524
class="emotion-16 emotion-17"
1152511525
>
1152611526
<div
11527-
aria-controls="«r1h»"
11528-
aria-describedby="«r1h»"
11527+
aria-controls="«r1l»"
11528+
aria-describedby="«r1l»"
1152911529
class="emotion-18 emotion-19"
1153011530
tabindex="0"
1153111531
>
@@ -11646,7 +11646,7 @@ exports[`EstimateCost - Item > render with tooltipInfo 1`] = `
1164611646
class="emotion-62 emotion-63"
1164711647
data-size="medium"
1164811648
data-testid="unit-input"
11649-
id="«r1j»"
11649+
id="«r1n»"
1165011650
max="9007199254740991"
1165111651
min="1"
1165211652
name="iteration-value"
@@ -11661,8 +11661,8 @@ exports[`EstimateCost - Item > render with tooltipInfo 1`] = `
1166111661
class="emotion-64 emotion-65 emotion-66"
1166211662
>
1166311663
<div
11664-
aria-controls="«r1l»"
11665-
aria-describedby="«r1l»"
11664+
aria-controls="«r1p»"
11665+
aria-describedby="«r1p»"
1166611666
class="emotion-18 emotion-19"
1166711667
data-container-full-width="true"
1166811668
tabindex="-1"
@@ -11671,8 +11671,8 @@ exports[`EstimateCost - Item > render with tooltipInfo 1`] = `
1167111671
class="emotion-69 emotion-1"
1167211672
>
1167311673
<div
11674+
aria-controls="«r1p»"
1167411675
aria-expanded="false"
11675-
aria-haspopup="listbox"
1167611676
class="emotion-71 emotion-72"
1167711677
data-disabled="false"
1167811678
data-dropdownvisible="false"
@@ -11740,8 +11740,8 @@ exports[`EstimateCost - Item > render with tooltipInfo 1`] = `
1174011740
class="emotion-16 emotion-17"
1174111741
>
1174211742
<div
11743-
aria-controls="«r1q»"
11744-
aria-describedby="«r1q»"
11743+
aria-controls="«r1v»"
11744+
aria-describedby="«r1v»"
1174511745
class="emotion-18 emotion-19"
1174611746
tabindex="0"
1174711747
>

packages/plus/src/components/EstimateCost/__tests__/__snapshots__/Region.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ exports[`EstimateCost - Region > render region component 1`] = `
10901090
class="emotion-65 emotion-1"
10911091
>
10921092
<div
1093+
aria-controls="«r5»"
10931094
aria-expanded="false"
1094-
aria-haspopup="listbox"
10951095
class="emotion-67 emotion-68"
10961096
data-disabled="false"
10971097
data-dropdownvisible="false"

0 commit comments

Comments
 (0)