Skip to content

Commit

Permalink
fix(eslint): Enable no-constant-binary-expression and fix violations (#…
Browse files Browse the repository at this point in the history
…83273)

https://eslint.org/docs/latest/rules/no-constant-binary-expression

Found and fixed some bugs. Also removed some unneeded `?? ''` fallbacks.
`??` is only useful when the left side could be `null` or `undefined`.
  • Loading branch information
ryan953 authored and andrewshie-sentry committed Jan 22, 2025
1 parent 867d69b commit 326444b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 43 deletions.
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,12 @@ export default typescript.config([
...eslint.configs.recommended.rules,
'no-cond-assign': ['error', 'always'],
'no-case-declarations': 'off', // TODO(ryan953): Fix violations and delete this line
'no-constant-binary-expression': 'off', // TODO(ryan953): Fix violations and delete this line
'no-dupe-class-members': 'off', // TODO(ryan953): Fix violations and delete this line
'no-import-assign': 'off', // TODO(ryan953): Fix violations and delete this line
'no-prototype-builtins': 'off', // TODO(ryan953): Fix violations and delete this line
'no-unsafe-optional-chaining': 'off', // TODO(ryan953): Fix violations and delete this line
'no-useless-catch': 'off', // TODO(ryan953): Fix violations and delete this line
'no-useless-escape': 'off', // TODO(ryan953): Fix violations and delete this line
'valid-typeof': 'off', // TODO(ryan953): Fix violations and delete this line
},
},
{
Expand Down
7 changes: 3 additions & 4 deletions static/app/components/charts/percentageAreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ export default class PercentageAreaChart extends Component<Props> {
const series = toArray(seriesParams);

// Filter series that have 0 counts
const date =
`${
series.length && moment(series[0].data[0]).format('MMM D, YYYY')
}<br />` || '';
const date = `${
series.length && moment(series[0].data[0]).format('MMM D, YYYY')
}<br />`;

return [
'<div class="tooltip-series">',
Expand Down
12 changes: 6 additions & 6 deletions static/app/utils/profiling/profile/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export function createContinuousProfileFrameIndex(

for (let i = 0; i < frames.length; i++) {
const frame = frames[i]!;
const frameKey = `${frame.filename ?? ''}:${frame.function ?? 'unknown'}:${
String(frame.lineno) ?? ''
}:${frame.instruction_addr ?? ''}`;
const frameKey = `${frame.filename ?? ''}:${frame.function ?? 'unknown'}:${String(
frame.lineno
)}:${frame.instruction_addr ?? ''}`;

const existing = insertionCache[frameKey];
if (existing) {
Expand Down Expand Up @@ -64,9 +64,9 @@ export function createSentrySampleProfileFrameIndex(

for (let i = 0; i < frames.length; i++) {
const frame = frames[i]!;
const frameKey = `${frame.filename ?? ''}:${frame.function ?? 'unknown'}:${
String(frame.lineno) ?? ''
}:${frame.instruction_addr ?? ''}`;
const frameKey = `${frame.filename ?? ''}:${frame.function ?? 'unknown'}:${String(
frame.lineno
)}:${frame.instruction_addr ?? ''}`;

const existing = insertionCache[frameKey];
if (existing) {
Expand Down
6 changes: 1 addition & 5 deletions static/app/views/performance/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,7 @@ export function getProject(
eventData: EventData,
projects: Project[]
): Project | undefined {
const projectSlug = (eventData?.project as string) || undefined;

if (typeof projectSlug === undefined) {
return undefined;
}
const projectSlug = eventData.project as string | undefined;

return projects.find(currentProject => currentProject.slug === projectSlug);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ export function MostRegressedProfileFunctions(props: MostRegressedProfileFunctio

const onChangeTrendType = useCallback(v => setTrendType(v.value), []);

const hasDifferentialFlamegraphPageFeature =
false && organization.features.includes('profiling-differential-flamegraph-page');
const hasDifferentialFlamegraphPageFeature = organization.features.includes(
'profiling-differential-flamegraph-page'
);

return (
<RegressedFunctionsContainer>
Expand Down
17 changes: 8 additions & 9 deletions static/app/views/settings/account/notifications/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,21 @@ export function getDocsLinkForEventType(
event: DataCategoryExact | string // TODO(isabella): get rid of strings after removing need for backward compatibility on gs
) {
switch (event) {
case DataCategoryExact.TRANSACTION || 'transaction':
case DataCategoryExact.TRANSACTION:
// For pre-AM3 plans prior to June 11th, 2024
return 'https://docs.sentry.io/pricing/quotas/legacy-manage-transaction-quota/';
case DataCategoryExact.SPAN ||
DataCategoryExact.SPAN_INDEXED ||
'span' ||
'span_indexed':
case DataCategoryExact.SPAN:
case DataCategoryExact.SPAN_INDEXED:
case 'span_indexed':
// For post-AM3 plans after June 11th, 2024
return 'https://docs.sentry.io/pricing/quotas/manage-transaction-quota/';
case DataCategoryExact.ATTACHMENT || 'attachment':
case DataCategoryExact.ATTACHMENT:
return 'https://docs.sentry.io/product/accounts/quotas/manage-attachments-quota/#2-rate-limiting';
case DataCategoryExact.REPLAY || 'replay':
case DataCategoryExact.REPLAY:
return 'https://docs.sentry.io/product/session-replay/';
case DataCategoryExact.MONITOR_SEAT || 'monitorSeat':
case DataCategoryExact.MONITOR_SEAT:
return 'https://docs.sentry.io/product/crons/';
case DataCategoryExact.PROFILE_DURATION || 'profileDuration':
case DataCategoryExact.PROFILE_DURATION:
return 'https://docs.sentry.io/product/explore/profiling/';
default:
return 'https://docs.sentry.io/product/accounts/quotas/manage-event-stream-guide/#common-workflows-for-managing-your-event-stream';
Expand Down
24 changes: 11 additions & 13 deletions static/app/views/traces/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,17 @@ function Content() {
const handleClearSearch = useCallback(
(searchIndex: number) => {
const newQueries = [...queries];
if (typeof newQueries[searchIndex] !== undefined) {
delete newQueries[searchIndex];
browserHistory.push({
...location,
query: {
...location.query,
cursor: undefined,
query: newQueries,
},
});
return true;
}
return false;
// TODO: do we need to return false when `newQueries[searchIndex] === undefined`?
delete newQueries[searchIndex];
browserHistory.push({
...location,
query: {
...location.query,
cursor: undefined,
query: newQueries,
},
});
return true;
},
[location, queries]
);
Expand Down
3 changes: 1 addition & 2 deletions static/app/views/traces/tracesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export function TracesChart() {
}
const data = series[i]!['count()'];
data.color = CHART_PALETTE[2][i];
data.seriesName =
`span ${i + 1}: ${queries[i] || t('All spans')}` || t('All spans');
data.seriesName = `span ${i + 1}: ${queries[i] || t('All spans')}`;
allData.push(data);
}

Expand Down

0 comments on commit 326444b

Please sign in to comment.