Skip to content

feat(emotion): Upgrade emotion to v10 #15106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f6bcc85
ref(ui): Refactor `cx` from emotion to `classnames`
billyvg Jan 3, 2020
87269e3
upgrade emotion, add styled wrapper for typings (and related paths), …
billyvg Jan 5, 2020
e47d1ca
Refactor usage of emotion `css` being treated as a class name string
billyvg Jan 5, 2020
e136ae5
change innerRef --> ref
billyvg Jan 5, 2020
3087993
eslint for emotion-setup
billyvg Jan 5, 2020
f37a3c4
refactor injectGlobal --> Global for emotion upgrade
billyvg Jan 5, 2020
457b836
Add <CacheProvider>, this is needed to turn speedy off for percy
billyvg Jan 5, 2020
51c9455
refactor <HeaderItem> - fix missing props to styled components, remov…
billyvg Jan 5, 2020
ad42316
Change <Tooltip> logic for when to apply a wrapper, emotion causes th…
billyvg Jan 5, 2020
3e0a699
random TS fixes for styled components
billyvg Jan 5, 2020
666e39e
fix <RadioGroup> animation needing `css`
billyvg Jan 5, 2020
134727d
forwardRef for Switch
billyvg Jan 5, 2020
2315cbe
define a `theme.space` for rebass/grid
billyvg Jan 6, 2020
3cbc1be
fix DOM attribute warnings with "loading" prop
billyvg Jan 6, 2020
2908aa0
change <ProviderRow> to remove `Flex` around CircleIndicator as it wa…
billyvg Jan 7, 2020
f2400ca
css fixes for percy
billyvg Jan 7, 2020
c5393cb
fix settings breadcrumb - Box in `reflexbox` has different CSS than g…
billyvg Jan 7, 2020
e14d510
fix featureDisabled logic for custom alerts because emotion
billyvg Jan 8, 2020
5cb4165
refactor grid-emotion props and update to `reflexbox`
billyvg Jan 5, 2020
6fcc93a
refactor emotion9 --> emotion10 (imports)
billyvg Jan 5, 2020
c539551
update snapshots and fix tests
billyvg Jan 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 7 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'emotion'],
extends: ['sentry-app/strict'],
globals: {
require: false,
Expand All @@ -11,7 +11,12 @@ module.exports = {
tick: true,
jest: true,
},
rules: {},
rules: {
'emotion/jsx-import': 'off',
'emotion/no-vanilla': 'error',
'emotion/import-from-emotion': 'error',
'emotion/styled-import': 'error',
},
overrides: [
{
files: ['*.ts', '*.tsx'],
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc.relax.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ const strict = require('./.eslintrc.js');
module.exports = {
...strict,
extends: ['sentry-app'],

rules: {
'emotion/jsx-import': 'off',
'emotion/no-vanilla': 'warn',
'emotion/import-from-emotion': 'error',
'emotion/styled-import': 'error',
},
};
29 changes: 23 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/*eslint-env node*/
module.exports = {
presets: ['@babel/react', '@babel/env', '@babel/preset-typescript'],
presets: [
'@babel/react',
'@babel/env',
'@babel/preset-typescript',
[
'@emotion/babel-preset-css-prop',
{
autoLabel: true,
sourceMap: false,
labelFormat: '[local]',
},
],
],
plugins: [
'emotion',
'react-hot-loader/babel',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
Expand Down Expand Up @@ -34,13 +45,19 @@ module.exports = {
],
},
development: {
plugins: [
['emotion', {sourceMap: true, autoLabel: true}],
'@babel/plugin-transform-react-jsx-source',
presets: [
[
'@emotion/babel-preset-css-prop',
{
autoLabel: true,
sourceMap: false,
},
],
],
plugins: ['@babel/plugin-transform-react-jsx-source'],
},
test: {
plugins: [['emotion', {autoLabel: true}], 'dynamic-import-node'],
plugins: ['dynamic-import-node'],
},
},
};
2 changes: 1 addition & 1 deletion docs-ui/components/button.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import {action} from '@storybook/addon-actions';
Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/checkboxFancy.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import {number, boolean} from '@storybook/addon-knobs';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import CheckboxFancy from 'app/components/checkboxFancy';

Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/colors.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import theme from 'app/utils/theme';

Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/emptyMessage.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';
import React from 'react';

import {Panel, PanelHeader} from 'app/components/panels';
Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/gridEditable.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import Button from 'app/components/button';
import GlobalModal from 'app/components/globalModal';
Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/icons.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import InlineSvg from 'app/components/inlineSvg';

Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/idBadge.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import IdBadge from 'app/components/idBadge';

Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/issueSyncListElement.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';

Expand Down
2 changes: 1 addition & 1 deletion docs-ui/components/platformIcon.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import {storiesOf} from '@storybook/react';
import {withInfo} from '@storybook/addon-info';

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"@babel/preset-react": "^7.7.0",
"@babel/preset-typescript": "^7.7.2",
"@babel/runtime": "~7.7.2",
"@emotion/babel-preset-css-prop": "^10.0.27",
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@sentry/apm": "5.10.1",
"@sentry/browser": "5.10.1",
"@sentry/integrations": "5.10.1",
Expand All @@ -43,7 +46,6 @@
"babel-core": "^7.0.0-bridge.0",
"babel-loader": "^8.0.0",
"babel-plugin-add-react-displayname": "^0.0.5",
"babel-plugin-emotion": "9.2.11",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"bootstrap": "3.4.0",
"classnames": "2.2.0",
Expand All @@ -60,13 +62,12 @@
"dompurify": "^2.0.7",
"echarts": "4.2.1",
"echarts-for-react": "2.0.14",
"emotion": "9.2.12",
"emotion-theming": "9.2.9",
"emotion": "10.0.27",
"emotion-theming": "10.0.27",
"file-loader": "^3.0.1",
"focus-visible": "^5.0.2",
"fuse.js": "^3.4.6",
"gettext-parser": "1.3.1",
"grid-emotion": "^2.1.0",
"intersection-observer": "^0.7.0",
"ios-device-list": "^1.1.30",
"jed": "^1.1.0",
Expand Down Expand Up @@ -95,7 +96,6 @@
"react-date-range": "^1.0.0-beta",
"react-document-title": "2.0.3",
"react-dom": "16.7.0",
"react-emotion": "9.2.12",
"react-hot-loader": "4.12.16",
"react-keydown": "^1.9.7",
"react-lazyload": "^2.3.0",
Expand All @@ -107,6 +107,7 @@
"react-select": "^1.2.1",
"react-sparklines": "1.7.0",
"react-virtualized": "^9.20.1",
"reflexbox": "^4.0.6",
"reflux": "0.4.1",
"regenerator-runtime": "^0.13.3",
"scroll-to-element": "^2.0.0",
Expand Down Expand Up @@ -145,6 +146,7 @@
"enzyme-to-json": "3.4.3",
"eslint": "5.11.1",
"eslint-config-sentry-app": "1.27.0",
"eslint-plugin-emotion": "^10.0.14",
"jest": "24.9.0",
"jest-canvas-mock": "^2.2.0",
"jest-junit": "^9.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/actionCreators/indicator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import {DEFAULT_TOAST_DURATION} from 'app/constants';
import {t, tct} from 'app/locale';
Expand Down
11 changes: 6 additions & 5 deletions src/sentry/static/sentry/app/actionCreators/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {css} from 'react-emotion';
import {css} from '@emotion/core';
import {ModalHeader, ModalBody, ModalFooter} from 'react-bootstrap';

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

export type ModalOptions = {
onClose?: () => void;
modalCss?: ReturnType<typeof css>;
modalClassName?: string;
dialogClassName?: string;
type?: string;
Expand Down Expand Up @@ -73,7 +74,7 @@ export function openDiffModal(options: ModalOptions) {
.then(mod => mod.default)
.then(Modal => {
// This is the only way to style the different Modal children
const diffModalCss = css`
const modalCss = css`
.modal-dialog {
display: flex;
margin: 0;
Expand All @@ -95,7 +96,7 @@ export function openDiffModal(options: ModalOptions) {
`;

openModal(deps => <Modal {...deps} {...options} />, {
modalClassName: diffModalCss,
modalCss,
});
});
}
Expand Down Expand Up @@ -200,7 +201,7 @@ export function openDebugFileSourceModal(options: ModalOptions = {}) {

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

openModal(deps => <Modal {...deps} {...options} />, {modalClassName});
openModal(deps => <Modal {...deps} {...options} />, {modalCss});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

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

const AlertComponent = typeof alert === 'function' ? alert : Alert;
const AlertComponent = typeof alert === 'boolean' ? Alert : alert;

return (
<AlertComponent type="warning" icon="icon-lock">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';
import classNames from 'classnames';
import PropTypes from 'prop-types';

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

const ActivityAuthor = styled('span')`
font-weight: 600;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import UserAvatar from 'app/components/avatar/userAvatar';
import InlineSvg from 'app/components/inlineSvg';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import styled from '@emotion/styled';

/**
* This creates a bordered box that has a left pointing arrow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import DateTime from 'app/components/dateTime';
import TimeSince from 'app/components/timeSince';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';

const EditorTools = styled('span')`
display: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import {t} from 'app/locale';
import ActivityAuthor from 'app/components/activity/author';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import ActivityItem from 'app/components/activity/item';
import SentryTypes from 'app/sentryTypes';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {MentionsInput, Mention} from 'react-mentions';
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import {t} from 'app/locale';
import Button from 'app/components/button';
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/static/sentry/app/components/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {css} from 'emotion';
import {css} from '@emotion/core';
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import color from 'color';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import InlineSvg from 'app/components/inlineSvg';
import TextBlock from 'app/views/settings/components/text/textBlock';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/alertLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled from 'react-emotion';
import styled from '@emotion/styled';
import React from 'react';
import {LocationDescriptor} from 'history';

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/alertMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import Alert from 'app/components/alert';
import AlertActions from 'app/actions/alertActions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import posed from 'react-pose';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import {t} from 'app/locale';
import InlineSvg from 'app/components/inlineSvg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import Reflux from 'reflux';
import createReactClass from 'create-react-class';
import styled from 'react-emotion';
import styled from '@emotion/styled';

import SentryTypes from 'app/sentryTypes';
import {User} from 'app/types';
Expand Down
Loading