Skip to content

Commit

Permalink
Switch to the new JSX transform (#991)
Browse files Browse the repository at this point in the history
* Remove jsxRuntime pragmas

* Migrate to the  jsx automatic runtime - part 1

* Migrate to the jsx automatic runtime - part 2

* Fix TS errors by opting into the new jsx runtime in the root tsconfig

* Fix Storybook List bug

* Fix React not defined errors with shorthand fragments

This can be fixed by either keeping the React import or importing Fragment and using it directly. This commit applies the second option in Circuit components

* Use babel-jest instead of ts-jest

* Update snapshots

* Add types for @emotion/core/jsx-runtime

The types were added in Emotion 11, we can remove this when we upgrade. Until then, we're typing the module globally to silence TS and hopefully fix the build errors
  • Loading branch information
Robin Métral authored Jun 22, 2021
1 parent 7879a99 commit 4c63423
Show file tree
Hide file tree
Showing 350 changed files with 973 additions and 1,656 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ module.exports = require('@sumup/foundry/eslint')(
{
files: ['packages/circuit-ui/**/*'],
rules: {
// The custom JSX pragma is required to make Emotion's css prop
// work with TypeScript.
'emotion/jsx-import': 'error',
// The automatic JSX runtime handles the React import. We will update the defaults in Foundry v5.
'react/react-in-jsx-scope': 'off',
},
},
{
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/BorderRadius.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/BorderWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/IconSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
5 changes: 2 additions & 3 deletions .storybook/components/Icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
* limitations under the License.
*/

import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useState } from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { ThemeProvider } from 'emotion-theming';
import { keys, entries, includes, isEmpty, groupBy, sortBy } from 'lodash/fp';
import { entries, includes, isEmpty, groupBy, sortBy } from 'lodash/fp';
import { light } from '@sumup/design-tokens';
import * as iconComponents from '@sumup/icons';
import { icons } from '@sumup/icons/manifest.json';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { ThemeProvider } from 'emotion-theming';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { ThemeProvider } from 'emotion-theming';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Link.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import LinkTo from '@storybook/addon-links/react';
import { css } from '@emotion/core';

Expand Down
1 change: 0 additions & 1 deletion .storybook/components/MediaQueriesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import { withTheme, ThemeProvider } from 'emotion-theming';
import { light } from '@sumup/design-tokens';

Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import { Canvas } from '@storybook/addon-docs/blocks';
import { ThemeProvider } from 'emotion-theming';
import { light } from '@sumup/design-tokens';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

/* eslint-disable react/prop-types, react/display-name */

import React from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider } from 'emotion-theming';
import { css } from '@emotion/core';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import { Story as StorybookStory } from '@storybook/addon-docs/blocks';

import Preview from './Preview';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Swatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
1 change: 0 additions & 1 deletion .storybook/components/Teaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { ThemeProvider } from 'emotion-theming';
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Type.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import React, { Fragment, createElement } from 'react';
import { Fragment, createElement } from 'react';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
Expand Down
3 changes: 1 addition & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { addDecorator, addParameters } from '@storybook/react';
import { addParameters } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withPerformance } from 'storybook-addon-performance';
import { ThemeProvider } from 'emotion-theming';
Expand Down
4 changes: 2 additions & 2 deletions .storybook/util/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const components = {
size: TEXT_SIZE,
css: italicStyles,
}),
ul: withThemeProvider(List, { size: TEXT_SIZE }),
ol: withThemeProvider(List, { size: TEXT_SIZE, variant: 'ordered' }),
ul: withThemeProvider(List),
ol: withThemeProvider(List, { variant: 'ordered' }),
a: withThemeProvider(Link, { size: TEXT_SIZE }),
};
11 changes: 1 addition & 10 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,16 @@
*/

module.exports = {
preset: 'ts-jest',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
// HACK: See https://github.com/storybookjs/storybook/pull/9292
moduleNameMapper: {
'react-syntax-highlighter/dist/esm/(.*)':
'react-syntax-highlighter/dist/cjs/$1',
},
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
'^.+\\.(md|mdx)$': '<rootDir>/jest.mdxTransformer.js',
},
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
testURL: 'http://localhost',
globals: {
'ts-jest': {
tsconfig: {
jsx: 'react',
},
},
},
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"react-dom": "^17.0.1",
"storybook-addon-performance": "^0.15.1",
"svgo": "^2.0.3",
"ts-jest": "^26.4.4",
"typescript": "^4.0.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Heading, SubHeading, Text, Input } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Heading, SubHeading, Text, Input } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Badge } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Badge } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Body, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Body, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Button } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Button } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Button, LoadingButton, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Button, LoadingButton, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { ListView, SvgButton as SpecialButton } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { CardList, IconButton as SpecialButton } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import {
Heading,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import {
Headline,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Heading, CardList } from '@sumup/circuit-ui';

const BaseHeading = () => <Heading size={Heading.KILO} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { Heading, CardList } from '@sumup/circuit-ui';

const BaseHeading = () => <Heading size={'kilo'} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { LoadingButton } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { LoadingButton } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { InlineMessage } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { InlineMessage } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, Fragment } from 'react';
import { useRef, Fragment } from 'react';
import styled from '@emotion/styled';
import { Input, TextArea } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, Fragment } from 'react';
import { useRef, Fragment } from 'react';
import styled from '@emotion/styled';
import { Input, TextArea } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import { useRef } from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { Input, TextArea } from '@sumup/circuit-ui';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import { useRef } from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { Input, TextArea } from '@sumup/circuit-ui';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { List, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { List, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { RadioButton, Switch, Toggle } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { RadioButton, Switch, Toggle } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Selector } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Selector } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { Col } from '@sumup/circuit-ui';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { Col } from '@sumup/circuit-ui';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ThemeProvider } from 'emotion-theming';
import { theme } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ThemeProvider } from 'emotion-theming';
import { light } from '@sumup/design-tokens';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ThemeProvider } from 'emotion-theming';
import { theme, Text } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { ThemeProvider } from 'emotion-theming';
import { Text } from '@sumup/circuit-ui';
import { light } from '@sumup/design-tokens';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Toggle } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import { Toggle } from '@sumup/circuit-ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import {
Heading,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled';
import {
Heading,
Expand Down
Loading

0 comments on commit 4c63423

Please sign in to comment.