Skip to content
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

chore(null): address straightforward null check errors for src/common/components #5946

Merged
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
2 changes: 1 addition & 1 deletion src/background/actions/action-payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface ChangeInstanceSelectionPayload extends AssessmentActionInstance
}

export interface UpdateSelectedDetailsViewPayload extends BaseActionPayload {
detailsViewType: VisualizationType;
detailsViewType: VisualizationType | null;
pivotType: DetailsViewPivotType;
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/components/cards/instance-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const InstanceDetails = NamedFC<InstanceDetailsProps>('InstanceDetails',
cardSelectionMessageCreator.toggleCardSelection(result.ruleId, result.uid, event);
};

const hiddenButton = React.useRef(null);
const hiddenButton = React.useRef<HTMLButtonElement>(null);
const cardHighlightingProperties = isHighlightSupported
? {
onClick: (_: React.SyntheticEvent): void => {
Expand Down Expand Up @@ -124,7 +124,7 @@ const renderCardRowsForPropertyBag = (
props: InstanceDetailsProps,
) => {
let propertyIndex = 0;
const cardRows = [];
const cardRows: JSX.Element[] = [];
forOwn(propertyBag, (propertyData, propertyName) => {
const propertyConfig = props.deps.getPropertyConfigById(propertyName);
if (!isEmpty(propertyConfig)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const NeedsReviewInstancesSection = NamedFC<CommonInstancesSectionProps>(
deps={deps}
title="Instances to review"
results={cardsViewData.cards.unknown}
containerClassName={null}
outcomeType="review"
badgeCount={count}
userConfigurationStoreData={userConfigurationStoreData}
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/cards/result-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ResultSectionDeps = ResultSectionContentDeps;

export type ResultSectionProps = Omit<ResultSectionContentProps, 'headingLevel'> &
Omit<ResultSectionTitleProps, 'titleSize'> & {
containerClassName: string;
containerClassName?: string;
deps: ResultSectionDeps;
sectionHeadingLevel: HeadingLevel;
};
Expand Down
4 changes: 0 additions & 4 deletions src/common/components/cards/rules-with-instances.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { FixInstructionProcessor } from 'common/components/fix-instruction-processor';
import { CardSelectionMessageCreator } from 'common/message-creators/card-selection-message-creator';
import { NamedFC } from 'common/react/named-fc';
import * as React from 'react';
Expand All @@ -27,7 +26,6 @@ export type RulesWithInstancesDeps = RuleContentDeps &

export type RulesWithInstancesProps = {
deps: RulesWithInstancesDeps;
fixInstructionProcessor: FixInstructionProcessor;
rules: CardRuleResult[];
outcomeType: InstanceOutcomeType;
userConfigurationStoreData: UserConfigurationStoreData;
Expand All @@ -44,7 +42,6 @@ export const RulesWithInstances = NamedFC<RulesWithInstancesProps>(
({
rules,
outcomeType,
fixInstructionProcessor,
deps,
userConfigurationStoreData,
targetAppInfo,
Expand Down Expand Up @@ -73,7 +70,6 @@ export const RulesWithInstances = NamedFC<RulesWithInstancesProps>(
key={`${rule.id}-rule-group`}
deps={deps}
rule={rule}
fixInstructionProcessor={fixInstructionProcessor}
userConfigurationStoreData={userConfigurationStoreData}
targetAppInfo={targetAppInfo}
cardSelectionMessageCreator={cardSelectionMessageCreator}
Expand Down
2 changes: 1 addition & 1 deletion src/common/extension-telemetry-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export type ExportFastPassResultsTelemetryData = {
} & ExportResultsTelemetryData;

export type DetailsViewOpenTelemetryData = {
selectedTest: string;
selectedTest: string | null;
} & BaseTelemetryData;

export type DetailsViewOpenedTelemetryData = {
Expand Down
4 changes: 2 additions & 2 deletions src/common/telemetry-data-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ export class TelemetryDataFactory {

public forOpenDetailsView(
event: SupportedMouseEvent,
visualizationType: VisualizationType,
visualizationType: VisualizationType | null,
source: TelemetryEventSource,
): DetailsViewOpenTelemetryData {
return {
...this.withTriggeredByAndSource(event, source),
selectedTest: VisualizationType[visualizationType],
selectedTest: visualizationType == null ? null : VisualizationType[visualizationType],
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/popup/actions/popup-action-message-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class PopupActionMessageCreator {

public openDetailsView(
event: SupportedMouseEvent,
viewType: VisualizationType,
viewType: VisualizationType | null,
source: TelemetryEventSource,
pivotType: DetailsViewPivotType,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exports[`NeedsReviewInstancesSection renders null results 1`] = `null`;
exports[`NeedsReviewInstancesSection renders with alerting off 1`] = `
<ResultSection
badgeCount={0}
containerClassName={null}
deps={Object {}}
outcomeCounter={[Function]}
outcomeType="review"
Expand All @@ -27,7 +26,6 @@ exports[`NeedsReviewInstancesSection renders with alerting off 1`] = `
exports[`NeedsReviewInstancesSection renders with alerting on 1`] = `
<ResultSection
badgeCount={0}
containerClassName={null}
deps={Object {}}
outcomeCounter={[Function]}
outcomeType="review"
Expand All @@ -47,7 +45,6 @@ exports[`NeedsReviewInstancesSection renders with alerting on 1`] = `
exports[`NeedsReviewInstancesSection renders with unknowns 1`] = `
<ResultSection
badgeCount={2}
containerClassName={null}
deps={Object {}}
outcomeCounter={[Function]}
outcomeType="review"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ exports[`RulesWithInstances renders 1`] = `
deps={
Object {
"collapsibleControl": [Function],
"fixInstructionProcessor": [typemoq mock object],
}
}
fixInstructionProcessor={[typemoq mock object]}
rule={
Object {
"description": "sample-description",
Expand Down Expand Up @@ -69,6 +69,7 @@ exports[`RulesWithInstances renders 1`] = `
deps={
Object {
"collapsibleControl": [Function],
"fixInstructionProcessor": [typemoq mock object],
}
}
header={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ describe('RulesWithInstances', () => {
collapsibleControl: (props: CollapsibleComponentCardsProps) => (
<CollapsibleControlStub {...props} />
),
fixInstructionProcessor: fixInstructionProcessorMock.object,
} as RulesWithInstancesDeps;
const outcomeCounterStub = () => 5;

const wrapped = shallow(
<RulesWithInstances
deps={depsStub}
fixInstructionProcessor={fixInstructionProcessorMock.object}
outcomeType={'pass'}
rules={rules}
userConfigurationStoreData={null}
Expand Down