Skip to content

Commit bcdba6f

Browse files
committed
Ignore no-unnecessary-condition where I'm confident the condition is warranted
1 parent 7960cb8 commit bcdba6f

File tree

12 files changed

+42
-15
lines changed

12 files changed

+42
-15
lines changed

src/components/changeset/changeset.arg.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ export const ChangesetArg = (
3838
ValidateChangesetEditablePipe,
3939
)(target, methodName, argIndex);
4040

41-
// method metadata is set after parameter metadata, so wait until next tick
42-
// to determine if method is query or mutation to set default description.
41+
// method metadata is set after parameter metadata, so wait until the next tick
42+
// to determine if method is query or mutation to set the default description.
4343
process.nextTick(() => {
4444
type = Reflect.getMetadata(TypeKey, (target as any)[methodName!]);
45+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- double-checking at runtime
4546
if (!type) {
4647
throw new ServerException(
4748
'Something went wrong trying to determine operation type',

src/components/file/file.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ export class FileService {
134134
}
135135
throw new ServerException('Failed to retrieve file contents', e);
136136
}
137+
// I think this is a safety check for our S3 mocks
138+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
137139
if (!data) {
138140
throw new NotFoundException('Could not find file contents');
139141
}

src/components/file/media/detect-existing-media.migration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class DetectExistingMediaMigration extends BaseMigration {
8181
}
8282
yield* currentPage;
8383
page++;
84-
// eslint-disable-next-line no-constant-condition
84+
// eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
8585
} while (true);
8686
}
8787

src/components/file/media/media-detector.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ export class MediaDetector {
3636
return {
3737
__typename: 'Image',
3838
dimensions: {
39+
// Guarding against library lies
40+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
3941
width: size.width ?? 0,
4042
height: size.height ?? 0,
43+
/* eslint-enable @typescript-eslint/no-unnecessary-condition */
4144
},
4245
};
4346
}

src/components/location/location.gel.repository.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ export class LocationGelRepository
5757
const locations = e.select(node)[
5858
rel as keyof typeof node
5959
] as typeof e.Location;
60+
// Types may be misleading, confirm at runtime.
61+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
6062
if (!locations) {
6163
throw new ServerException(`${label} does not have a "${rel}" link`);
6264
}
6365
if (locations.__element__.__name__ !== 'default::Location') {
6466
throw new ServerException(`${label}.${rel} is not a link to Locations`);
6567
}
68+
/* eslint-enable @typescript-eslint/no-unnecessary-condition */
6669
const all = e.select(locations, (obj) => ({
6770
...this.applyFilter(obj, input),
6871
...this.applyOrderBy(obj, input),

src/components/periodic-report/handlers/sync-progress-report-to-engagement.handler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ export class SyncProgressReportToEngagementDateRange
101101
engagementRange(event.previous),
102102
];
103103
Settings.throwOnInvalid = true;
104+
// I turned off throw on invalid above for this, so it is necessary despite the type inconsistency
105+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
104106
if (prev && !prev.isValid) {
105107
this.logger.error('Found invalid date range for event', {
106108
eventType: event.constructor.name,
@@ -109,6 +111,7 @@ export class SyncProgressReportToEngagementDateRange
109111
});
110112
throw new Error('Invalid engagement date range');
111113
}
114+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
112115
if (updated && !updated.isValid) {
113116
this.logger.error('Found invalid date range for event', {
114117
eventType: event.constructor.name,

src/components/product/product.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ export class ProductService {
8181
}
8282

8383
const otherInput: CreateOtherProduct | undefined =
84+
// Double-checking not undefined seems safer here since a union type
85+
// could have this field declared as undefined.
86+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
8487
'title' in input && input.title !== undefined ? input : undefined;
8588
const derivativeInput: CreateDerivativeScriptureProduct | undefined =
89+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
8690
'produces' in input && input.produces !== undefined ? input : undefined;
8791
const scriptureInput: CreateDirectScriptureProduct | undefined =
8892
!otherInput && !derivativeInput ? input : undefined;

src/components/progress-report/migrations/reextract-all-progress-reports.migration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ async function* createPaginator<T>(
9393
}
9494
yield* currentPage;
9595
page++;
96-
// eslint-disable-next-line no-constant-condition
96+
// eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
9797
} while (true);
9898
}

src/components/progress-summary/progress-summary.extractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const findFiscalYearRow = (sheet: ProgressSheet, fiscalYear: number) => {
5858

5959
const findLatestCumulative = (currentYear: Row<ProgressSheet>) => {
6060
const { sheet } = currentYear;
61-
// eslint-disable-next-line no-constant-condition
61+
// eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
6262
while (true) {
6363
const summary = summaryFrom(currentYear, ...sheet.columnsForCumulative);
6464
if (summary.planned > 0 || summary.actual > 0) {

src/core/database/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const createBetterError = (e: Error) => {
112112
if (!isNeo4jError(e)) {
113113
return e;
114114
}
115+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
115116
e.message ??= ''; // I've seen the message be null
116117

117118
const better = cast(e);

0 commit comments

Comments
 (0)