Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 12f9168

Browse files
authored
build: use @scaleway/tsconfig (#589)
* build: use @scaleway/tsconfig * fix: correct errors
1 parent 4318688 commit 12f9168

File tree

7 files changed

+35
-26
lines changed

7 files changed

+35
-26
lines changed

.storybook/preview.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SCWUITheme, normalize, theme } from '@scaleway/ui'
22

33
import { css, ThemeProvider, Global, Theme } from '@emotion/react'
4+
import { Story } from '@storybook/react'
45

56
const STORY_SORT = {
67
order: [
@@ -46,17 +47,24 @@ const ENV_PARAMETERS = {
4647
},
4748
}
4849
export const parameters =
49-
ENV_PARAMETERS[process.env.STORYBOOK_ENVIRONMENT] || ENV_PARAMETERS.production
50+
(process.env?.['STORYBOOK_ENVIRONMENT'] as keyof typeof ENV_PARAMETERS) ||
51+
ENV_PARAMETERS.production
5052

51-
const adjustedTheme = ancestorTheme =>
53+
const adjustedTheme = (ancestorTheme: Theme) =>
5254
({
5355
...ancestorTheme,
5456
...Object.keys(theme).reduce(
5557
(acc, themeItem) => ({
5658
...acc,
5759
[themeItem]: {
58-
...(acc[themeItem] ?? {}),
59-
...theme[themeItem],
60+
...((acc[themeItem as keyof typeof theme] as Record<
61+
string,
62+
unknown
63+
>) ?? {}),
64+
...(theme[themeItem as keyof typeof theme] as Record<
65+
string,
66+
unknown
67+
>),
6068
},
6169
}),
6270
ancestorTheme,
@@ -68,10 +76,10 @@ export const globalStyles = (_: Theme) => css`
6876
`
6977

7078
export const decorators = [
71-
Story => (
79+
(StoryComponent: Story) => (
7280
<ThemeProvider theme={adjustedTheme}>
7381
<Global styles={[globalStyles]} />
74-
<Story />
82+
<StoryComponent />
7583
</ThemeProvider>
7684
),
7785
]

.storybook/scaleway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { create } from '@storybook/theming/create'
1+
import { create } from '@storybook/theming'
22
import brandImage from './assets/scaleway-text.png'
33

44
export default create({

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"@rollup/plugin-url": "8.0.1",
141141
"@scaleway/eslint-config-react": "3.11.2",
142142
"@scaleway/jest-helpers": "2.0.24",
143+
"@scaleway/tsconfig": "^1.1.0",
143144
"@semantic-release/changelog": "6.0.2",
144145
"@semantic-release/commit-analyzer": "9.0.2",
145146
"@semantic-release/git": "10.0.1",

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/DateField/__tests__/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('DateField', () => {
3737
})
3838
const option = node.getAllByRole('option')[0]
3939
await act(() => {
40-
option.click()
40+
option?.click()
4141
})
4242
expect(onChange).toBeCalledTimes(1)
4343
// Blur not working on react-datepicker:

src/mocks/mockErrors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export const mockErrors: FormErrors = {
1111
`This field should have a length greater than ${minLength}`,
1212
REGEX: ({ regex }) => {
1313
if (
14-
(Array.isArray(regex[0]) ? regex[0][0].source : regex[0].source) ===
15-
emailRegex.source
14+
(Array.isArray(regex[0])
15+
? regex?.[0]?.[0]?.source
16+
: regex?.[0]?.source) === emailRegex.source
1617
) {
1718
return 'Invalid email'
1819
}

tsconfig.json

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
{
2+
"extends": "@scaleway/tsconfig",
23
"compilerOptions": {
3-
"target": "es2020",
4-
"module": "esnext",
5-
"strict": true,
6-
"allowSyntheticDefaultImports": true,
7-
"allowJs": true,
8-
"esModuleInterop": true,
4+
"target": "esnext",
5+
// For storybook compatibility we use commonjs
6+
"module": "commonjs",
7+
"jsxImportSource": "@emotion/react",
8+
99
"noEmit": true,
10-
"moduleResolution": "node",
1110
"skipLibCheck": true,
12-
"jsx": "preserve"
1311
},
1412
"include": [
15-
"./storybook/**/*.ts",
16-
"./storybook/**/*.tsx",
1713
"**/*.ts",
1814
"**/*.tsx",
19-
"emotion.d.ts",
15+
".storybook/**/*.ts",
16+
".storybook/**/*.tsx"
2017
],
21-
"exclude": [
22-
"node_modules",
23-
"coverage",
24-
"dist"
25-
]
18+
"exclude": ["node_modules", "coverage", "dist"]
2619
}

0 commit comments

Comments
 (0)