Skip to content

Commit f423a42

Browse files
committed
ref: Remove optional chaining
This is required for #13786
1 parent 634c2a7 commit f423a42

File tree

23 files changed

+72
-56
lines changed

23 files changed

+72
-56
lines changed

babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
'react-hot-loader/babel',
88
'@babel/plugin-syntax-dynamic-import',
99
'@babel/plugin-proposal-object-rest-spread',
10-
'@babel/plugin-proposal-optional-chaining',
1110
'@babel/plugin-transform-runtime',
1211
// NOTE: The order of the decorator and class-property plugins is important
1312
// here. Decorators must be processed first before class properties, see:

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"@babel/plugin-proposal-class-properties": "^7.0.0",
1212
"@babel/plugin-proposal-decorators": "^7.0.0",
1313
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
14-
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
1514
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
1615
"@babel/plugin-transform-runtime": "^7.0.0",
1716
"@babel/polyfill": "^7.0.0",

src/sentry/static/sentry/app/api.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isUndefined, isNil} from 'lodash';
1+
import {isUndefined, isNil, get} from 'lodash';
22
import $ from 'jquery';
33
import * as Sentry from '@sentry/browser';
44

@@ -72,15 +72,15 @@ export class Client {
7272
* If so, redirect user to new project slug
7373
*/
7474
hasProjectBeenRenamed(response) {
75-
const code = response?.responseJSON?.detail?.code;
75+
const code = get(response, 'responseJSON.detail.code');
7676

7777
// XXX(billy): This actually will never happen because we can't intercept the 302
7878
// jQuery ajax will follow the redirect by default...
7979
if (code !== PROJECT_MOVED) {
8080
return false;
8181
}
8282

83-
const slug = response?.responseJSON?.detail?.extra?.slug;
83+
const slug = get(response, 'responseJSON.detail.extra.slug');
8484

8585
redirectToProject(slug);
8686
return true;
@@ -120,7 +120,7 @@ export class Client {
120120
}
121121

122122
handleRequestError({id, path, requestOptions}, response, ...responseArgs) {
123-
const code = response?.responseJSON?.detail?.code;
123+
const code = get(response, 'responseJSON.detail.code');
124124
const isSudoRequired = code === SUDO_REQUIRED || code === SUPERUSER_REQUIRED;
125125

126126
if (isSudoRequired) {

src/sentry/static/sentry/app/components/charts/components/tooltip.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'echarts/lib/component/tooltip';
22

3+
import {get} from 'lodash';
34
import {getFormattedDate} from 'app/utils/dates';
45
import {truncationFormatter} from '../utils';
56

@@ -54,7 +55,9 @@ function getFormatter({filter, isGroupedByDate, truncate, formatAxisLabel, utc})
5455
const seriesParams = isAxisItem ? seriesParamsOrParam : [seriesParamsOrParam];
5556

5657
// If axis, timestamp comes from axis, otherwise for a single item it is defined in its data
57-
const timestamp = isAxisItem ? seriesParams[0].axisValue : seriesParams[0]?.data[0];
58+
const timestamp = isAxisItem
59+
? seriesParams[0].axisValue
60+
: get(seriesParams, '[0].data[0]');
5861

5962
const label =
6063
seriesParams.length && axisFormatterOrDefault(timestamp, isGroupedByDate, utc);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class CommitRow extends React.Component {
3737
<Message>{this.renderMessage(message)}</Message>
3838
<Meta>
3939
{tct('[author] committed [timeago]', {
40-
author: <strong>{author?.name || t('Unknown author')}</strong>,
40+
author: <strong>{(author && author.name) || t('Unknown author')}</strong>,
4141
timeago: <TimeSince date={dateCreated} />,
4242
})}
4343
</Meta>

src/sentry/static/sentry/app/components/forms/formField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class FormField extends React.PureComponent {
8989
if (defined(props.error)) {
9090
return props.error;
9191
}
92-
return form?.errors[props.name] || null;
92+
return (form && form.errors[props.name]) || null;
9393
}
9494

9595
getId() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PlatformPicker extends React.Component {
3535

3636
state = {
3737
category: PLATFORM_CATEGORIES[0].id,
38-
filter: this.props.noAutoFilter ? '' : this.props.platform?.split('-')[0],
38+
filter: this.props.noAutoFilter ? '' : (this.props.platform || '').split('-')[0],
3939
};
4040

4141
get platformList() {

src/sentry/static/sentry/app/utils/handleXhrErrorResponse.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export default function handleXhrErrorResponse(message) {
2222
}
2323

2424
// Ignore sudo-required errors
25-
if (responseJSON?.detail?.code === 'sudo-required') {
25+
if (responseJSON.detail && responseJSON.detail.code === 'sudo-required') {
2626
return;
2727
}
2828

29-
if (typeof responseJSON?.detail?.message === 'string') {
29+
if (responseJSON.detail && typeof responseJSON.detail.message === 'string') {
3030
Sentry.withScope(scope => {
3131
scope.setExtra('status', resp.status);
3232
scope.setExtra('detail', responseJSON.detail);

src/sentry/static/sentry/app/views/app.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Cookies from 'js-cookie';
77
import PropTypes from 'prop-types';
88
import React from 'react';
99
import keydown from 'react-keydown';
10-
import {isEqual} from 'lodash';
10+
import {get, isEqual} from 'lodash';
1111

1212
import {openCommandPalette} from 'app/actionCreators/modal';
1313
import {t} from 'app/locale';
@@ -117,8 +117,8 @@ class App extends React.Component {
117117
return;
118118
}
119119

120-
const code = jqXHR?.responseJSON?.detail?.code;
121-
const extra = jqXHR?.responseJSON?.detail?.extra;
120+
const code = get(jqXHR, 'responseJSON.detail.code');
121+
const extra = get(jqXHR, 'responseJSON.detail.extra');
122122

123123
// 401s can also mean sudo is required or it's a request that is allowed to fail
124124
// Ignore if these are the cases

src/sentry/static/sentry/app/views/onboarding/platform.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class OnboardingPlatform extends React.Component {
114114
render() {
115115
const {active, project, platform, scrollTargetId} = this.props;
116116

117-
const selectedPlatform = platform || project?.platform;
117+
const selectedPlatform = platform || (project && project.platform);
118118

119119
const continueDisabled =
120120
!selectedPlatform || this.state.progressing || (this.hasFirstProject && !active);

0 commit comments

Comments
 (0)