Skip to content

ref: Use strict equality everywhere #13590

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 3 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ConfigStore from 'app/stores/configStore';
import ServiceIncidentActions from 'app/actions/serviceIncidentActions';

function getIncidentsFromIncidentResponse(incidents) {
if (incidents === null || incidents.length == 0) {
if (incidents === null || incidents.length === 0) {
return [[], 'none'];
}

Expand Down
4 changes: 2 additions & 2 deletions src/sentry/static/sentry/app/components/actorAvatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class ActorAvatar extends React.Component {
render() {
const {actor, ...props} = this.props;

if (actor.type == 'user') {
if (actor.type === 'user') {
const user = actor.id ? MemberListStore.getById(actor.id) : actor;
return <Avatar user={user} hasTooltip {...props} />;
}

if (actor.type == 'team') {
if (actor.type === 'team') {
const team = TeamStore.getById(actor.id);
return <Avatar team={team} hasTooltip {...props} />;
}
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/static/sentry/app/components/alertLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const StyledLink = styled(Link)`
background-color: ${p => p.theme.alert[p.priority].backgroundLight};
color: ${p => p.theme.gray4};
border: 1px dashed ${p => p.theme.alert[p.priority].border};
padding: ${p => (p.size == 'small' ? `${space(1)} ${space(1.5)}` : space(2))};
padding: ${p => (p.size === 'small' ? `${space(1)} ${space(1.5)}` : space(2))};
margin-bottom: ${space(3)};
border-radius: 0.25em;
transition: 0.2s border-color;
Expand All @@ -53,5 +53,5 @@ const AlertLinkText = styled('div')`
`;

const StyledInlineSvg = styled(InlineSvg)`
margin-right: ${p => (p.spacingSize == 'small' ? space(1) : space(1.5))};
margin-right: ${p => (p.spacingSize === 'small' ? space(1) : space(1.5))};
`;
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/alertMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class AlertMessage extends React.PureComponent {
const {alert, system} = this.props;
let icon;

if (alert.type == 'success') {
if (alert.type === 'success') {
icon = 'icon-circle-check';
} else {
icon = 'icon-circle-exclamation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Icon = styled('div')`
display: block;
}

color: ${p => (p.type == 'success' ? p.theme.green : p.theme.red)};
color: ${p => (p.type === 'success' ? p.theme.green : p.theme.red)};
`;

const Message = styled('div')`
Expand Down Expand Up @@ -88,9 +88,9 @@ function ToastIndicator({indicator, onDismiss, className, ...props}) {
}
};

if (type == 'success') {
if (type === 'success') {
icon = <InlineSvg src="icon-circle-check" size="24px" />;
} else if (type == 'error') {
} else if (type === 'error') {
icon = <InlineSvg src="icon-circle-close" size="24px" />;
}
return (
Expand All @@ -99,7 +99,7 @@ function ToastIndicator({indicator, onDismiss, className, ...props}) {
className={cx(className, 'ref-toast', `ref-${type}`)}
{...props}
>
{type == 'loading' ? (
{type === 'loading' ? (
<StyledLoadingIndicator mini />
) : (
<Icon type={type}>{icon}</Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const GuideAnchor = createReactClass({
if (
data.currentGuide &&
data.currentStep > 0 &&
data.currentGuide.steps[data.currentStep - 1].target == this.props.target &&
data.currentGuide.steps[data.currentStep - 1].target === this.props.target &&
// TODO(adhiraj): It would be more correct to let invisible anchors become active,
// and use CSS to make them invisible.
this.props.type !== 'invisible'
Expand Down Expand Up @@ -103,7 +103,7 @@ const recedeAnchor = keyframes`

const GuideAnchorContainer = styled('div')`
${p =>
p.type == 'text' &&
p.type === 'text' &&
`
display: inline-block;
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PluginComponentBase extends React.Component {
}

onSave(callback, ...args) {
if (this.state.state == FormState.SAVING) {
if (this.state.state === FormState.SAVING) {
return;
}
callback = callbackWithArgs(callback, ...args);
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/static/sentry/app/components/contextData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {isUrl} from 'app/utils';
function looksLikeObjectRepr(value) {
const a = value[0];
const z = value[value.length - 1];
if (a == '<' && z == '>') {
if (a === '<' && z === '>') {
return true;
} else if (a == '[' && z == ']') {
} else if (a === '[' && z === ']') {
return true;
} else if (a == '(' && z == ')') {
} else if (a === '(' && z === ')') {
return true;
} else if (z == ')' && value.match(/^[\w\d._-]+\(/)) {
} else if (z === ')' && value.match(/^[\w\d._-]+\(/)) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ const AutoCompleteItem = styled('div')`

font-size: 0.9em;
background-color: ${p =>
p.index == p.highlightedIndex ? p.theme.offWhite : 'transparent'};
p.index === p.highlightedIndex ? p.theme.offWhite : 'transparent'};
padding: ${p => getItemPaddingForSize(p.size)};
cursor: pointer;
border-bottom: 1px solid ${p => p.theme.borderLight};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EventTags extends React.Component {
<em className="icon-open" />
</a>
)}
{tag.key == 'release' && (
{tag.key === 'release' && (
<VersionHoverCard
containerClassName="pill-icon"
version={tag.value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const Frame = createReactClass({
// we don't want to render out zero line numbers which are used to
// indicate lack of source information for native setups. We could
// TODO(mitsuhiko): only do this for events from native platforms?
if (defined(data.lineNo) && data.lineNo != 0) {
if (defined(data.lineNo) && data.lineNo !== 0) {
title.push(
<span className="in-at in-at-line" key="no">
{' '}
Expand Down Expand Up @@ -370,8 +370,8 @@ const Frame = createReactClass({
isInlineFrame() {
return (
this.props.prevFrame &&
this.getPlatform() == (this.props.prevFrame.platform || this.props.platform) &&
this.props.data.instructionAddr == this.props.prevFrame.instructionAddr
this.getPlatform() === (this.props.prevFrame.platform || this.props.platform) &&
this.props.data.instructionAddr === this.props.prevFrame.instructionAddr
);
},

Expand All @@ -382,7 +382,7 @@ const Frame = createReactClass({
if (this.props.data.trust === 'scan' || this.props.data.trust === 'cfi-scan') {
return t('Found by stack scanning');
}
if (this.getPlatform() == 'cocoa') {
if (this.getPlatform() === 'cocoa') {
const func = this.props.data.function || '<unknown>';
if (func.match(/^@objc\s/)) {
return t('Objective-C -> Swift shim frame');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RawExceptionContent extends React.Component {
getAppleCrashReportEndpoint() {
const {type, organization, projectId, eventId} = this.props;

const minified = type == 'minified';
const minified = type === 'minified';
return `/projects/${
organization.slug
}/${projectId}/events/${eventId}/apple-crash-report?minified=${minified}`;
Expand Down Expand Up @@ -96,7 +96,7 @@ class RawExceptionContent extends React.Component {
content = <LoadingIndicator />;
} else if (this.state.error) {
content = <LoadingError onRetry={this.fetchData} />;
} else if (!this.state.loading && this.state.crashReport != '') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible we (unintentionally) relied on loose equality here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is ok since it's initialized as empty string in constructor and again in the fetch function

} else if (!this.state.loading && this.state.crashReport !== '') {
content = <ClippedBox clipHeight={250}>{this.state.crashReport}</ClippedBox>;
downloadButton = (
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function stringifyQueryList(query) {

const queryObj = {};
for (const kv of query) {
if (kv !== null && kv.length == 2) {
if (kv !== null && kv.length === 2) {
const [k, v] = kv;
if (v !== null) {
queryObj[k] = v;
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/forms/apiForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class ApiForm extends Form {
onSubmit = e => {
e.preventDefault();

if (this.state.state == FormState.SAVING) {
if (this.state.state === FormState.SAVING) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/forms/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Form extends React.Component {
const hasChanges = requireChanges
? Object.keys(data).length && !_.isEqual(data, initialData)
: true;
const isError = this.state.state == FormState.ERROR;
const isError = this.state.state === FormState.ERROR;
const nonFieldErrors = this.state.errors && this.state.errors.non_field_errors;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ExternalIssueList extends AsyncComponent {
};

onSentryAppComponentsChange = sentryAppComponents => {
const components = sentryAppComponents.filter(c => c.type == 'issue-link');
const components = sentryAppComponents.filter(c => c.type === 'issue-link');
this.setState({components});
};

Expand Down Expand Up @@ -117,7 +117,7 @@ class ExternalIssueList extends AsyncComponent {
const {externalIssues, sentryAppInstallations, components} = this.state;
const {group} = this.props;

if (components.length == 0) {
if (components.length === 0) {
return null;
}

Expand All @@ -127,7 +127,7 @@ class ExternalIssueList extends AsyncComponent {
i => i.app.uuid === sentryApp.uuid
);

const issue = (externalIssues || []).find(i => i.serviceType == sentryApp.slug);
const issue = (externalIssues || []).find(i => i.serviceType === sentryApp.slug);

return (
<ErrorBoundary key={sentryApp.slug} mini>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ const PluginActions = createReactClass({
<Modal.Title>{`${plugin.name || plugin.title} Issue`}</Modal.Title>
</Modal.Header>
<NavTabs underlined={true}>
<li className={actionType == 'create' ? 'active' : ''}>
<li className={actionType === 'create' ? 'active' : ''}>
<a onClick={() => this.handleClick('create')}>{t('Create')}</a>
</li>
<li className={actionType == 'link' ? 'active' : ''}>
<li className={actionType === 'link' ? 'active' : ''}>
<a onClick={() => this.handleClick('link')}>{t('Link')}</a>
</li>
</NavTabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SentryAppExternalIssueForm extends React.Component {

getFieldDefault(field) {
const {group} = this.props;
if (field.type == 'textarea') {
if (field.type === 'textarea') {
field.maxRows = 10;
field.autosize = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ export default withApi(withOrganization(SuggestedOwners));
*/
function findMatchedRules(rules, owner) {
const matchOwner = (actorType, key) =>
(actorType == 'user' && key === owner.email) ||
(actorType == 'team' && key == owner.name);
(actorType === 'user' && key === owner.email) ||
(actorType === 'team' && key === owner.name);

const actorHasOwner = ([actorType, key]) =>
actorType === owner.type && matchOwner(actorType, key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TodoList extends React.Component {
const org = this.props.organization;
const tasks = TASKS.map(task => {
for (const serverTask of org.onboardingTasks) {
if (serverTask.task == task.task) {
if (serverTask.task === task.task) {
Object.assign(task, serverTask);
break;
}
Expand All @@ -165,7 +165,7 @@ class TodoList extends React.Component {
data: {task: skippedTask, status: 'skipped'},
success: () => {
const newState = this.state.tasks.map(task => {
if (task.task == skippedTask) {
if (task.task === skippedTask) {
task.status = 'skipped';
}
return task;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ class Broadcasts extends React.Component {
data-test-id="sidebar-broadcasts"
orientation={orientation}
collapsed={collapsed}
active={currentPanel == 'broadcasts'}
active={currentPanel === 'broadcasts'}
badge={unseenPosts.length}
icon={<InlineSvg src="icon-broadcast" size="22px" />}
label={t("What's new")}
onClick={this.handleShowPanel}
id="broadcasts"
/>

{showPanel && currentPanel == 'broadcasts' && (
{showPanel && currentPanel === 'broadcasts' && (
<SidebarPanel
data-test-id="sidebar-broadcasts-panel"
orientation={orientation}
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Sidebar extends React.Component {
};

hashChangeHandler = () => {
if (window.location.hash == '#welcome') {
if (window.location.hash === '#welcome') {
this.togglePanel('todos');
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OnboardingStatus extends React.Component {
const {currentPanel, org} = this.props;
if (
currentPanel !== prevProps.currentPanel &&
(currentPanel || prevProps.currentPanel == 'todos')
(currentPanel || prevProps.currentPanel === 'todos')
) {
this.recordAnalytics(currentPanel, parseInt(org.id, 10));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class StackedBarChart extends React.Component {

getMinHeight(index, pointLength) {
const {minHeights} = this.props;
return minHeights && (minHeights[index] || minHeights[index] == 0)
return minHeights && (minHeights[index] || minHeights[index] === 0)
? this.props.minHeights[index]
: 1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/static/sentry/app/components/switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Switch extends React.Component {
}
}

const getSize = p => (p.size == 'sm' ? 16 : 24);
const getToggleSize = p => getSize(p) - (p.size == 'sm' ? 6 : 10);
const getToggleTop = p => (p.size == 'sm' ? 2 : 4);
const getSize = p => (p.size === 'sm' ? 16 : 24);
const getToggleSize = p => getSize(p) - (p.size === 'sm' ? 6 : 10);
const getToggleTop = p => (p.size === 'sm' ? 2 : 4);
const getTranslateX = p => (p.isActive ? getToggleTop(p) + getSize(p) : getToggleTop(p));

const SwitchContainer = styled('div')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class TagDistributionMeter extends React.Component {
last={index === segments.length - 1}
isOther={!!value.isOther}
>
<Description first={index == 0}>
<Description first={index === 0}>
<Percentage>{pctLabel}%</Percentage>
<Label>{value.name}</Label>
</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const fields = {
saveMessage: t('Changing grouping config will apply to future events only.'),
selectionInfoFunction: args => {
const {groupingConfigs, value} = args;
const selection = groupingConfigs.find(({id}) => id == value);
const selection = groupingConfigs.find(({id}) => id === value);
const changelog = (selection && selection.changelog) || '';
if (!changelog) {
return null;
Expand Down Expand Up @@ -150,7 +150,7 @@ export const fields = {
saveMessage: t('Changing grouping enhancements will apply to future events only.'),
selectionInfoFunction: args => {
const {groupingEnhancementBases, value} = args;
const selection = groupingEnhancementBases.find(({id}) => id == value);
const selection = groupingEnhancementBases.find(({id}) => id === value);
const changelog = (selection && selection.changelog) || '';
if (!changelog) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/static/sentry/app/data/forms/sentryApplication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ const forms = [
autosize: true,
help: 'Schema for your UI components',
getValue: val => {
return val == '' ? {} : JSON.parse(val);
return val === '' ? {} : JSON.parse(val);
},
setValue: val => {
const schema = JSON.stringify(val, null, 2);
if (schema == '{}') {
if (schema === '{}') {
return '';
}
return schema;
Expand Down
Loading