Skip to content

Commit 94a63d9

Browse files
authored
feat(emotion): Upgrade emotion to v10 (#15106)
* ref(ui): Refactor `cx` from emotion to `classnames` We generally use the `classnames` library to handle merging/dynamic `className`. No reason to use two different libraries. * upgrade emotion, add styled wrapper for typings (and related paths), add eslint rules for emotion, update babel plugin * Refactor usage of emotion `css` being treated as a class name string * change innerRef --> ref * refactor grid-emotion props and update to `reflexbox` * eslint for emotion-setup * refactor injectGlobal --> Global for emotion upgrade * Add <CacheProvider>, this is needed to turn speedy off for percy * refactor <HeaderItem> - fix missing props to styled components, remove innerRef and forwardRef * Change <Tooltip> logic for when to apply a wrapper, emotion causes the previously expected types to be different * random TS fixes for styled components * fix <RadioGroup> animation needing `css` * forwardRef for Switch * define a `theme.space` for rebass/grid * fix DOM attribute warnings with "loading" prop * fix settings breadcrumb - Box in `reflexbox` has different CSS than grid-emotion * change <ProviderRow> to remove `Flex` around CircleIndicator as it was squishing it on small widths * css fixes for percy * fix featureDisabled logic for custom alerts because emotion * refactor emotion9 --> emotion10 (imports) * update snapshots and fix tests
1 parent 348f90a commit 94a63d9

File tree

564 files changed

+7244
-6556
lines changed

Some content is hidden

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

564 files changed

+7244
-6556
lines changed

.eslintrc.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
plugins: ['@typescript-eslint'],
3+
plugins: ['@typescript-eslint', 'emotion'],
44
extends: ['sentry-app/strict'],
55
globals: {
66
require: false,
@@ -11,7 +11,12 @@ module.exports = {
1111
tick: true,
1212
jest: true,
1313
},
14-
rules: {},
14+
rules: {
15+
'emotion/jsx-import': 'off',
16+
'emotion/no-vanilla': 'error',
17+
'emotion/import-from-emotion': 'error',
18+
'emotion/styled-import': 'error',
19+
},
1520
overrides: [
1621
{
1722
files: ['*.ts', '*.tsx'],

.eslintrc.relax.js

+7
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ const strict = require('./.eslintrc.js');
33
module.exports = {
44
...strict,
55
extends: ['sentry-app'],
6+
7+
rules: {
8+
'emotion/jsx-import': 'off',
9+
'emotion/no-vanilla': 'warn',
10+
'emotion/import-from-emotion': 'error',
11+
'emotion/styled-import': 'error',
12+
},
613
};

babel.config.js

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
/*eslint-env node*/
22
module.exports = {
3-
presets: ['@babel/react', '@babel/env', '@babel/preset-typescript'],
3+
presets: [
4+
'@babel/react',
5+
'@babel/env',
6+
'@babel/preset-typescript',
7+
[
8+
'@emotion/babel-preset-css-prop',
9+
{
10+
autoLabel: true,
11+
sourceMap: false,
12+
labelFormat: '[local]',
13+
},
14+
],
15+
],
416
plugins: [
5-
'emotion',
617
'react-hot-loader/babel',
718
'@babel/plugin-syntax-dynamic-import',
819
'@babel/plugin-proposal-object-rest-spread',
@@ -34,13 +45,19 @@ module.exports = {
3445
],
3546
},
3647
development: {
37-
plugins: [
38-
['emotion', {sourceMap: true, autoLabel: true}],
39-
'@babel/plugin-transform-react-jsx-source',
48+
presets: [
49+
[
50+
'@emotion/babel-preset-css-prop',
51+
{
52+
autoLabel: true,
53+
sourceMap: false,
54+
},
55+
],
4056
],
57+
plugins: ['@babel/plugin-transform-react-jsx-source'],
4158
},
4259
test: {
43-
plugins: [['emotion', {autoLabel: true}], 'dynamic-import-node'],
60+
plugins: ['dynamic-import-node'],
4461
},
4562
},
4663
};

docs-ui/components/button.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33
import {storiesOf} from '@storybook/react';
44
import {withInfo} from '@storybook/addon-info';
55
import {action} from '@storybook/addon-actions';

docs-ui/components/checkboxFancy.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import {storiesOf} from '@storybook/react';
33
import {withInfo} from '@storybook/addon-info';
44
import {number, boolean} from '@storybook/addon-knobs';
5-
import styled from 'react-emotion';
5+
import styled from '@emotion/styled';
66

77
import CheckboxFancy from 'app/components/checkboxFancy';
88

docs-ui/components/colors.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {storiesOf} from '@storybook/react';
33
import {withInfo} from '@storybook/addon-info';
4-
import styled from 'react-emotion';
4+
import styled from '@emotion/styled';
55

66
import theme from 'app/utils/theme';
77

docs-ui/components/emptyMessage.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'react-emotion';
1+
import styled from '@emotion/styled';
22
import React from 'react';
33

44
import {Panel, PanelHeader} from 'app/components/panels';

docs-ui/components/gridEditable.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {storiesOf} from '@storybook/react';
33
import {withInfo} from '@storybook/addon-info';
4-
import styled from 'react-emotion';
4+
import styled from '@emotion/styled';
55

66
import Button from 'app/components/button';
77
import GlobalModal from 'app/components/globalModal';

docs-ui/components/icons.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {storiesOf} from '@storybook/react';
33
import {withInfo} from '@storybook/addon-info';
4-
import styled from 'react-emotion';
4+
import styled from '@emotion/styled';
55

66
import InlineSvg from 'app/components/inlineSvg';
77

docs-ui/components/idBadge.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {storiesOf} from '@storybook/react';
33
import {withInfo} from '@storybook/addon-info';
4-
import styled from 'react-emotion';
4+
import styled from '@emotion/styled';
55

66
import IdBadge from 'app/components/idBadge';
77

docs-ui/components/issueSyncListElement.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33
import {storiesOf} from '@storybook/react';
44
import {withInfo} from '@storybook/addon-info';
55

docs-ui/components/platformIcon.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33
import {storiesOf} from '@storybook/react';
44
import {withInfo} from '@storybook/addon-info';
55

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"@babel/preset-react": "^7.7.0",
1818
"@babel/preset-typescript": "^7.7.2",
1919
"@babel/runtime": "~7.7.2",
20+
"@emotion/babel-preset-css-prop": "^10.0.27",
21+
"@emotion/core": "^10.0.27",
22+
"@emotion/styled": "^10.0.27",
2023
"@sentry/apm": "5.10.1",
2124
"@sentry/browser": "5.10.1",
2225
"@sentry/integrations": "5.10.1",
@@ -43,7 +46,6 @@
4346
"babel-core": "^7.0.0-bridge.0",
4447
"babel-loader": "^8.0.0",
4548
"babel-plugin-add-react-displayname": "^0.0.5",
46-
"babel-plugin-emotion": "9.2.11",
4749
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
4850
"bootstrap": "3.4.0",
4951
"classnames": "2.2.0",
@@ -60,13 +62,12 @@
6062
"dompurify": "^2.0.7",
6163
"echarts": "4.2.1",
6264
"echarts-for-react": "2.0.14",
63-
"emotion": "9.2.12",
64-
"emotion-theming": "9.2.9",
65+
"emotion": "10.0.27",
66+
"emotion-theming": "10.0.27",
6567
"file-loader": "^3.0.1",
6668
"focus-visible": "^5.0.2",
6769
"fuse.js": "^3.4.6",
6870
"gettext-parser": "1.3.1",
69-
"grid-emotion": "^2.1.0",
7071
"intersection-observer": "^0.7.0",
7172
"ios-device-list": "^1.1.30",
7273
"jed": "^1.1.0",
@@ -95,7 +96,6 @@
9596
"react-date-range": "^1.0.0-beta",
9697
"react-document-title": "2.0.3",
9798
"react-dom": "16.7.0",
98-
"react-emotion": "9.2.12",
9999
"react-hot-loader": "4.12.16",
100100
"react-keydown": "^1.9.7",
101101
"react-lazyload": "^2.3.0",
@@ -107,6 +107,7 @@
107107
"react-select": "^1.2.1",
108108
"react-sparklines": "1.7.0",
109109
"react-virtualized": "^9.20.1",
110+
"reflexbox": "^4.0.6",
110111
"reflux": "0.4.1",
111112
"regenerator-runtime": "^0.13.3",
112113
"scroll-to-element": "^2.0.0",
@@ -145,6 +146,7 @@
145146
"enzyme-to-json": "3.4.3",
146147
"eslint": "5.11.1",
147148
"eslint-config-sentry-app": "1.27.0",
149+
"eslint-plugin-emotion": "^10.0.14",
148150
"jest": "24.9.0",
149151
"jest-canvas-mock": "^2.2.0",
150152
"jest-junit": "^9.0.0",

src/sentry/static/sentry/app/actionCreators/indicator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33

44
import {DEFAULT_TOAST_DURATION} from 'app/constants';
55
import {t, tct} from 'app/locale';

src/sentry/static/sentry/app/actionCreators/modal.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {css} from 'react-emotion';
2+
import {css} from '@emotion/core';
33
import {ModalHeader, ModalBody, ModalFooter} from 'react-bootstrap';
44

55
import ModalActions from 'app/actions/modalActions';
@@ -14,6 +14,7 @@ export type ModalRenderProps = {
1414

1515
export type ModalOptions = {
1616
onClose?: () => void;
17+
modalCss?: ReturnType<typeof css>;
1718
modalClassName?: string;
1819
dialogClassName?: string;
1920
type?: string;
@@ -73,7 +74,7 @@ export function openDiffModal(options: ModalOptions) {
7374
.then(mod => mod.default)
7475
.then(Modal => {
7576
// This is the only way to style the different Modal children
76-
const diffModalCss = css`
77+
const modalCss = css`
7778
.modal-dialog {
7879
display: flex;
7980
margin: 0;
@@ -95,7 +96,7 @@ export function openDiffModal(options: ModalOptions) {
9596
`;
9697

9798
openModal(deps => <Modal {...deps} {...options} />, {
98-
modalClassName: diffModalCss,
99+
modalCss,
99100
});
100101
});
101102
}
@@ -200,7 +201,7 @@ export function openDebugFileSourceModal(options: ModalOptions = {}) {
200201

201202
export async function openInviteMembersModal(options = {}) {
202203
const mod = await import(/* webpackChunkName: "InviteMembersModal" */ 'app/components/modals/inviteMembersModal');
203-
const {default: Modal, modalClassName} = mod;
204+
const {default: Modal, modalCss} = mod;
204205

205-
openModal(deps => <Modal {...deps} {...options} />, {modalClassName});
206+
openModal(deps => <Modal {...deps} {...options} />, {modalCss});
206207
}

src/sentry/static/sentry/app/components/acl/featureDisabled.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33

44
import {selectText} from 'app/utils/selectText';
55
import {t, tct} from 'app/locale';
@@ -32,7 +32,7 @@ type Props = {
3232
* Attaches additional styles to the FeatureDisabled component to make it
3333
* look consistent within the Alert.
3434
*/
35-
alert?: boolean | React.ReactElement;
35+
alert?: boolean | React.ElementType;
3636
/**
3737
* Do not show the help toggle. The description will always be rendered.
3838
*/
@@ -118,7 +118,7 @@ class FeatureDisabled extends React.Component<Props, State> {
118118
return this.renderFeatureDisabled();
119119
}
120120

121-
const AlertComponent = typeof alert === 'function' ? alert : Alert;
121+
const AlertComponent = typeof alert === 'boolean' ? Alert : alert;
122122

123123
return (
124124
<AlertComponent type="warning" icon="icon-lock">

src/sentry/static/sentry/app/components/actions/actionLink.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33
import classNames from 'classnames';
44
import PropTypes from 'prop-types';
55

src/sentry/static/sentry/app/components/activity/author.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'react-emotion';
1+
import styled from '@emotion/styled';
22

33
const ActivityAuthor = styled('span')`
44
font-weight: 600;

src/sentry/static/sentry/app/components/activity/item/avatar.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import styled from 'react-emotion';
3+
import styled from '@emotion/styled';
44

55
import UserAvatar from 'app/components/avatar/userAvatar';
66
import InlineSvg from 'app/components/inlineSvg';

src/sentry/static/sentry/app/components/activity/item/bubble.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import PropTypes from 'prop-types';
2-
import styled from 'react-emotion';
2+
import styled from '@emotion/styled';
33

44
/**
55
* This creates a bordered box that has a left pointing arrow

src/sentry/static/sentry/app/components/activity/item/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import styled from 'react-emotion';
3+
import styled from '@emotion/styled';
44

55
import DateTime from 'app/components/dateTime';
66
import TimeSince from 'app/components/timeSince';

src/sentry/static/sentry/app/components/activity/note/editorTools.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'react-emotion';
1+
import styled from '@emotion/styled';
22

33
const EditorTools = styled('span')`
44
display: none;

src/sentry/static/sentry/app/components/activity/note/header.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import styled from 'react-emotion';
3+
import styled from '@emotion/styled';
44

55
import {t} from 'app/locale';
66
import ActivityAuthor from 'app/components/activity/author';

src/sentry/static/sentry/app/components/activity/note/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import styled from 'react-emotion';
3+
import styled from '@emotion/styled';
44

55
import ActivityItem from 'app/components/activity/item';
66
import SentryTypes from 'app/sentryTypes';

src/sentry/static/sentry/app/components/activity/note/input.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {MentionsInput, Mention} from 'react-mentions';
22
import PropTypes from 'prop-types';
33
import React from 'react';
4-
import styled from 'react-emotion';
4+
import styled from '@emotion/styled';
55

66
import {t} from 'app/locale';
77
import Button from 'app/components/button';

src/sentry/static/sentry/app/components/alert.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {css} from 'emotion';
1+
import {css} from '@emotion/core';
22
import PropTypes from 'prop-types';
33
import React from 'react';
44
import classNames from 'classnames';
55
import color from 'color';
6-
import styled from 'react-emotion';
6+
import styled from '@emotion/styled';
77

88
import InlineSvg from 'app/components/inlineSvg';
99
import TextBlock from 'app/views/settings/components/text/textBlock';

src/sentry/static/sentry/app/components/alertLink.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'react-emotion';
1+
import styled from '@emotion/styled';
22
import React from 'react';
33
import {LocationDescriptor} from 'history';
44

src/sentry/static/sentry/app/components/alertMessage.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import styled from 'react-emotion';
3+
import styled from '@emotion/styled';
44

55
import Alert from 'app/components/alert';
66
import AlertActions from 'app/actions/alertActions';

src/sentry/static/sentry/app/components/alerts/toastIndicator.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import classNames from 'classnames';
44
import posed from 'react-pose';
5-
import styled from 'react-emotion';
5+
import styled from '@emotion/styled';
66

77
import {t} from 'app/locale';
88
import InlineSvg from 'app/components/inlineSvg';

src/sentry/static/sentry/app/components/assigneeSelector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import Reflux from 'reflux';
44
import createReactClass from 'create-react-class';
5-
import styled from 'react-emotion';
5+
import styled from '@emotion/styled';
66

77
import SentryTypes from 'app/sentryTypes';
88
import {User} from 'app/types';

0 commit comments

Comments
 (0)