Skip to content

Commit 3f4fbbf

Browse files
authored
chore(eslint): re-enable no-unused-vars for catch blocks; re-enable no-redundant-type-constituents and clean up redundant COMPASS-9459 (#7023)
chore(eslint): re-enable no-unused-vars for catch statements; re-enable no-redundant-type-constituents and clean up redundant
1 parent 22c56de commit 3f4fbbf

File tree

74 files changed

+99
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+99
-105
lines changed

configs/eslint-config-compass/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ const extraTsRules = {
2525
// clean those out and re-enable the rules
2626
'@typescript-eslint/no-explicit-any': 'warn',
2727
'@typescript-eslint/no-base-to-string': 'warn',
28-
'@typescript-eslint/no-unused-vars': [
29-
'error',
30-
{
31-
caughtErrors: 'none', // should be `'all'`
32-
},
33-
],
34-
'@typescript-eslint/no-redundant-type-constituents': 'warn',
3528
'@typescript-eslint/unbound-method': 'warn',
3629
'@typescript-eslint/no-duplicate-type-constituents': 'warn',
3730
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',

configs/webpack-config-compass/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function entriesToHtml(
3838
fs.statSync(maybeTemplatePath);
3939
template = maybeTemplatePath;
4040
break;
41-
} catch (e) {
41+
} catch {
4242
// ignore and use default template, electron renderer entry will need
4343
// at least some kind of html page provided one way or the other
4444
}

packages/atlas-service/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class CompassAuthService {
244244
throwIfAborted(signal);
245245
try {
246246
return (await this.introspect({ signal })).active;
247-
} catch (err) {
247+
} catch {
248248
return false;
249249
}
250250
}

packages/atlas-service/src/store/atlas-signin-reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export const restoreSignInState = (): AtlasSignInThunkAction<Promise<void>> => {
278278
} else {
279279
dispatch({ type: AtlasSignInActions.RestoringFailed });
280280
}
281-
} catch (err) {
281+
} catch {
282282
// For the initial state check if failed to check auth for any reason we
283283
// will just allow user to sign in again, ignoring the error
284284
dispatch({ type: AtlasSignInActions.RestoringFailed });

packages/compass-aggregations/src/modules/count-documents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const countDocuments = (): PipelineBuilderThunkAction<Promise<void>> => {
132132
type: ActionTypes.CountFinished,
133133
count: Number(count),
134134
});
135-
} catch (e) {
135+
} catch {
136136
dispatch({
137137
type: ActionTypes.CountFailed,
138138
});

packages/compass-aggregations/src/modules/insights.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const fetchExplainForPipeline = (): PipelineBuilderThunkAction<
9797
const explainPlan = new ExplainPlan(rawExplainPlan as Stage);
9898
dispatch({ type: FETCH_EXPLAIN_PLAN_SUCCESS, explainPlan });
9999
ExplainFetchAbortControllerMap.delete(id);
100-
} catch (err) {
100+
} catch {
101101
// We are only fetching this to get information about index usage for
102102
// insight badge, if this fails for any reason: server, cancel, error
103103
// getting pipeline from state, or parsing explain plan. Whatever it is,

packages/compass-aggregations/src/modules/pipeline-builder/pipeline-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class PipelineBuilder {
9696
if (!Array.isArray(this.pipeline)) {
9797
throw new Error('Pipeline should be an array');
9898
}
99-
} catch (e) {
99+
} catch {
100100
this.pipeline = null;
101101
}
102102
}

packages/compass-aggregations/src/modules/pipeline-builder/pipeline-parser/stage-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function isValidStageNode(node?: t.ObjectExpression): boolean {
2626
// before validating it again
2727
parseShellBSON(generate(node));
2828
return true;
29-
} catch (err) {
29+
} catch {
3030
return false;
3131
}
3232
}

packages/compass-aggregations/src/modules/pipeline-builder/stage-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,13 @@ const formatWizardValue = (value?: string): string => {
886886
let reIndented = value;
887887
try {
888888
reIndented = JSON.stringify(JSON.parse(value), null, 2);
889-
} catch (e) {
889+
} catch {
890890
// not valid json
891891
}
892892

893893
try {
894894
return prettify(reIndented);
895-
} catch (e) {
895+
} catch {
896896
// not valid js (ie. the generated stage has placeholders for the user to fill etc ..)
897897
return reIndented;
898898
}

packages/compass-aggregations/src/modules/search-indexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const fetchIndexes = (): PipelineBuilderThunkAction<Promise<void>> => {
109109
type: ActionTypes.FetchIndexesFinished,
110110
indexes,
111111
});
112-
} catch (e) {
112+
} catch {
113113
dispatch({
114114
type: ActionTypes.FetchIndexesFailed,
115115
});

packages/compass-components/src/components/guide-cue/guide-cue-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class CompassGuideCueStorage implements GuideCueStorage {
1919
get data(): GuideCueData {
2020
try {
2121
return JSON.parse(this.storage.getItem(this.key) ?? '[]');
22-
} catch (e) {
22+
} catch {
2323
return [];
2424
}
2525
}

packages/compass-components/src/components/index-icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import Icon from '@leafygreen-ui/icon';
33

4-
type IndexDirection = number | unknown;
4+
type IndexDirection = unknown;
55

66
const IndexIcon = ({
77
className,

packages/compass-connections/src/stores/connections-store-redux.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('CompassConnections store', function () {
145145
// Connect method should not reject, all the logic is encapsulated,
146146
// there is no reason to expose the error outside the store
147147
await connectPromise;
148-
} catch (err) {
148+
} catch {
149149
expect.fail('Expected connect() method to not throw');
150150
}
151151
});

packages/compass-crud/src/components/change-view/bson-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export function stringifyBSON(value: any) {
1616
return EJSON.stringify(value);
1717
}
1818

19-
export function unBSON(value: any | any[]): any | any[] {
19+
export function unBSON(value: any): any {
2020
const shape = getValueShape(value);
2121
if (shape === 'array') {
2222
return value.map(unBSON);
2323
} else if (shape === 'object') {
24-
const mapped: Record<string, any | any[]> = {};
24+
const mapped: Record<string, any> = {};
2525
for (const [k, v] of Object.entries(value)) {
2626
mapped[k] = unBSON(v);
2727
}

packages/compass-crud/src/components/change-view/unified-document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export type ArrayItemBranch = UnifiedBranch & {
9797

9898
export type Branch = {
9999
path: ObjectPath;
100-
value: any | any[];
100+
value: any;
101101
};
102102

103103
export type BranchesWithChanges = {

packages/compass-crud/src/components/table-view/cell-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class CellEditor
347347
_pasteEdit(value: string) {
348348
try {
349349
this.editor().paste(value);
350-
} catch (e) {
350+
} catch {
351351
this.editor().edit(value);
352352
} finally {
353353
this._pasting = false;

packages/compass-crud/src/stores/crud-store.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe('store', function () {
211211

212212
try {
213213
await dataService.dropCollection('compass-crud.test');
214-
} catch (err) {
214+
} catch {
215215
// noop
216216
}
217217

@@ -357,7 +357,7 @@ describe('store', function () {
357357
writeText: mockCopyToClipboard,
358358
},
359359
});
360-
} catch (e) {
360+
} catch {
361361
// Electron has the global navigator as a getter.
362362
sinon.replaceGetter(global as any, 'navigator', () => ({
363363
clipboard: {
@@ -1836,7 +1836,7 @@ describe('store', function () {
18361836

18371837
try {
18381838
await dataService.dropCollection('compass-crud.timeseries');
1839-
} catch (err) {
1839+
} catch {
18401840
// noop
18411841
}
18421842

packages/compass-crud/src/stores/crud-store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ class CrudStoreImpl
12161216
let update;
12171217
try {
12181218
update = parseShellBSON(this.state.bulkUpdate.updateText);
1219-
} catch (err) {
1219+
} catch {
12201220
// If this couldn't parse then the update button should have been
12211221
// disabled. So if we get here it is a race condition and ignoring is
12221222
// probably OK - the button will soon appear disabled to the user anyway.
@@ -1978,7 +1978,7 @@ class CrudStoreImpl
19781978
let update;
19791979
try {
19801980
update = parseShellBSON(this.state.bulkUpdate.updateText);
1981-
} catch (err) {
1981+
} catch {
19821982
// If this couldn't parse then the update button should have been
19831983
// disabled. So if we get here it is a race condition and ignoring is
19841984
// probably OK - the button will soon appear disabled to the user anyway.
@@ -2193,7 +2193,7 @@ export async function findAndModifyWithFLEFallback(
21932193
{ promoteValues: false }
21942194
);
21952195
return [undefined, docs[0]] as ErrorOrResult;
2196-
} catch (e) {
2196+
} catch {
21972197
/* fallthrough */
21982198
}
21992199
}

packages/compass-crud/src/utils/cancellable-queries.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ describe('cancellable-queries', function () {
3333

3434
try {
3535
await dataService.dropCollection('cancel.numbers');
36-
} catch (err) {
36+
} catch {
3737
// noop
3838
}
3939
await dataService.insertMany('cancel.numbers', docs, {});
4040

4141
try {
4242
await dataService.dropCollection('cancel.empty');
43-
} catch (err) {
43+
} catch {
4444
// noop
4545
}
4646
await dataService.createCollection('cancel.empty', {});
@@ -60,7 +60,7 @@ describe('cancellable-queries', function () {
6060
if (dataService) {
6161
try {
6262
await dataService.disconnect();
63-
} catch (err) {
63+
} catch {
6464
// ignore
6565
}
6666
}

packages/compass-data-modeling/src/services/data-model-storage-electron.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DataModelStorageElectron implements DataModelStorage {
2525
try {
2626
const res = await this.userData.readAll();
2727
return res.data;
28-
} catch (err) {
28+
} catch {
2929
return [];
3030
}
3131
}

packages/compass-data-modeling/src/store/diagram.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function renameDiagram(
274274
}
275275
dispatch({ type: DiagramActionTypes.RENAME_DIAGRAM, id, name: newName });
276276
void dataModelStorage.save({ ...diagram, name: newName });
277-
} catch (err) {
277+
} catch {
278278
// TODO log
279279
}
280280
};

packages/compass-e2e-tests/helpers/commands/exists-eventually.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function existsEventually(
1212
typeof timeout !== 'undefined' ? { timeout } : undefined
1313
);
1414
return true;
15-
} catch (err) {
15+
} catch {
1616
// return false if not
1717
return false;
1818
}

packages/compass-e2e-tests/helpers/commands/screenshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function screenshot(
2929
const fullPath = path.join(LOG_SCREENSHOTS_PATH, filename);
3030
try {
3131
await withTimeout(10000, browser.saveScreenshot(fullPath));
32-
} catch (err: any) {
32+
} catch {
3333
// For some reason browser.saveScreenshot() sometimes times out on mac with
3434
// `WARN webdriver: Request timed out! Consider increasing the
3535
// "connectionRetryTimeout" option.`. The default is 120 seconds.

packages/compass-e2e-tests/helpers/commands/shell-eval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function shellEval(
5959
if (parse === true) {
6060
try {
6161
result = JSON.parse(result);
62-
} catch (err) {
62+
} catch {
6363
// just leave it unparsed for now if there's a parse error because
6464
// that's really helpful when debugging
6565
console.error('Could not parse result:', result);

packages/compass-e2e-tests/helpers/compass.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export class Compass {
200200
let value;
201201
try {
202202
value = await arg.jsonValue();
203-
} catch (err) {
203+
} catch {
204204
// there are still some edge cases we can't easily convert into text
205205
console.error('could not convert', arg);
206206
value = '¯\\_(ツ)_/¯';
@@ -989,7 +989,7 @@ export async function buildCompass(
989989
try {
990990
await getCompassBuildMetadata();
991991
return;
992-
} catch (e) {
992+
} catch {
993993
/* ignore */
994994
}
995995

@@ -1137,7 +1137,7 @@ export async function cleanup(compass?: Compass): Promise<void> {
11371137
try {
11381138
// make sure the process can exit
11391139
await compass.browser.deleteSession({ shutdownDriver: true });
1140-
} catch (_) {
1140+
} catch {
11411141
debug('browser already closed');
11421142
}
11431143
}

packages/compass-e2e-tests/helpers/test-runner-global-fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export async function mochaGlobalSetup(this: Mocha.Runner) {
131131
try {
132132
debug('Clearing out past logs');
133133
fs.rmdirSync(LOG_PATH, { recursive: true });
134-
} catch (e) {
134+
} catch {
135135
debug('.log dir already removed');
136136
}
137137

packages/compass-e2e-tests/tests/in-use-encryption.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ describe('CSFLE / QE', function () {
575575
// present and smaller than the default one to allow for tests to
576576
// proceed correctly
577577
await footer.waitForDisplayed({ reverse: true, timeout: 10000 });
578-
} catch (err) {
578+
} catch {
579579
if (
580580
mode === 'unindexed' &&
581581
(await footer.getText()) ===

packages/compass-e2e-tests/tests/search-indexes.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('Search Indexes', function () {
185185
// Try to delete a namespace if it exists
186186
try {
187187
await dbInstance.dropCollection(collectionName);
188-
} catch (e) {
188+
} catch {
189189
// noop
190190
}
191191

@@ -210,7 +210,7 @@ describe('Search Indexes', function () {
210210
{
211211
try {
212212
await dbInstance.dropCollection(collectionName);
213-
} catch (e) {
213+
} catch {
214214
console.log(`Failed to drop collection: ${DB_NAME}.${collectionName}`);
215215
}
216216
}

packages/compass-explain-plan/src/stores/explain-plan-modal-store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type ExplainPlanModalState = {
4949
isModalOpen: boolean;
5050
status: 'initial' | 'loading' | 'ready' | 'error';
5151
explainPlan: SerializedExplainPlan | null;
52-
rawExplainPlan: unknown | null;
52+
rawExplainPlan: unknown;
5353
explainPlanFetchId: number;
5454
};
5555

packages/compass-export-to-language/src/components/modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function stageCountForTelemetry(inputExpression: InputExpression) {
8989
return {
9090
num_stages: countAggregationStagesInString(inputExpression.aggregation),
9191
};
92-
} catch (ignore) {
92+
} catch {
9393
// Things like [{ $match: { x: NumberInt(10) } }] do not evaluate in any kind of context
9494
return { num_stages: -1 };
9595
}

packages/compass-export-to-language/src/stores/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function getCurrentlyConnectedUri(
7474

7575
try {
7676
connectionStringUrl = dataService.getConnectionString().clone();
77-
} catch (e) {
77+
} catch {
7878
return '<uri>';
7979
}
8080

packages/compass-generative-ai/src/atlas-ai-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class AtlasAiService {
342342
let data;
343343
try {
344344
data = JSON.parse(text);
345-
} catch (e) {
345+
} catch {
346346
this.logger.log.info(
347347
this.logger.mongoLogId(1_001_000_310),
348348
'AtlasAIService',

0 commit comments

Comments
 (0)