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 2 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
Jump to file
Failed to load files.
Loading
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'],
},
},
};
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
5 changes: 3 additions & 2 deletions src/sentry/static/sentry/app/components/panels/panelBody.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Flex} from 'grid-emotion';
import {css, cx} from 'react-emotion';
import {css} from 'react-emotion';
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';

import space from 'app/styles/space';
import textStyles from 'app/styles/text';
Expand All @@ -18,7 +19,7 @@ const PanelBody = ({className, disablePadding, flex, direction, ...props}) => {

return (
<Comp
className={cx(padding, textClassName, className)}
className={classNames(padding, textClassName, className)}
{...props}
direction={flexDirection}
/>
Expand Down
5 changes: 5 additions & 0 deletions src/sentry/static/sentry/app/styled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// TODO(ts): Figure out why eslint chokes on this import
import styled, {CreateStyled} from '@original-emotion/styled'; // eslint-disable-line import/named
import theme from './utils/theme';

export default styled as CreateStyled<typeof theme>;
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"declaration": false,
"declarationMap": false,
"downlevelIteration": true,
"inlineSources": true,
"inlineSources": false,
"importHelpers": true,
"lib": ["esnext", "dom"],
"module": "esnext",
Expand All @@ -30,7 +30,9 @@
"baseUrl": ".",
"outDir": "src/sentry/static/sentry/dist",
"paths": {
"app/*": ["src/sentry/static/sentry/app/*"]
"app/*": ["src/sentry/static/sentry/app/*"],
"@emotion/styled": ["src/sentry/static/sentry/app/styled.tsx"],
"@original-emotion/*": ["node_modules/@emotion/*"]
},
"plugins": [{"name": "typescript-styled-plugin"}]
},
Expand Down
7 changes: 7 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ let appConfig = {
resolve: {
alias: {
app: path.join(staticPrefix, 'app'),
'@emotion/styled': path.join(staticPrefix, 'app', 'styled'),
'@original-emotion/styled': path.join(
__dirname,
'node_modules',
'@emotion',
'styled'
),

// Aliasing this for getsentry's build, otherwise `less/select2` will not be able
// to be resolved
Expand Down
Loading