Skip to content

chore(eslint): re-enable no-unused-vars for catch blocks; re-enable no-redundant-type-constituents and clean up redundant COMPASS-9459 #7023

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
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
7 changes: 0 additions & 7 deletions configs/eslint-config-compass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ const extraTsRules = {
// clean those out and re-enable the rules
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none', // should be `'all'`
},
],
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/unbound-method': 'warn',
'@typescript-eslint/no-duplicate-type-constituents': 'warn',
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion configs/webpack-config-compass/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function entriesToHtml(
fs.statSync(maybeTemplatePath);
template = maybeTemplatePath;
break;
} catch (e) {
} catch {
// ignore and use default template, electron renderer entry will need
// at least some kind of html page provided one way or the other
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas-service/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class CompassAuthService {
throwIfAborted(signal);
try {
return (await this.introspect({ signal })).active;
} catch (err) {
} catch {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/atlas-service/src/store/atlas-signin-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const restoreSignInState = (): AtlasSignInThunkAction<Promise<void>> => {
} else {
dispatch({ type: AtlasSignInActions.RestoringFailed });
}
} catch (err) {
} catch {
// For the initial state check if failed to check auth for any reason we
// will just allow user to sign in again, ignoring the error
dispatch({ type: AtlasSignInActions.RestoringFailed });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const countDocuments = (): PipelineBuilderThunkAction<Promise<void>> => {
type: ActionTypes.CountFinished,
count: Number(count),
});
} catch (e) {
} catch {
dispatch({
type: ActionTypes.CountFailed,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-aggregations/src/modules/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const fetchExplainForPipeline = (): PipelineBuilderThunkAction<
const explainPlan = new ExplainPlan(rawExplainPlan as Stage);
dispatch({ type: FETCH_EXPLAIN_PLAN_SUCCESS, explainPlan });
ExplainFetchAbortControllerMap.delete(id);
} catch (err) {
} catch {
// We are only fetching this to get information about index usage for
// insight badge, if this fails for any reason: server, cancel, error
// getting pipeline from state, or parsing explain plan. Whatever it is,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class PipelineBuilder {
if (!Array.isArray(this.pipeline)) {
throw new Error('Pipeline should be an array');
}
} catch (e) {
} catch {
this.pipeline = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function isValidStageNode(node?: t.ObjectExpression): boolean {
// before validating it again
parseShellBSON(generate(node));
return true;
} catch (err) {
} catch {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,13 @@ const formatWizardValue = (value?: string): string => {
let reIndented = value;
try {
reIndented = JSON.stringify(JSON.parse(value), null, 2);
} catch (e) {
} catch {
// not valid json
}

try {
return prettify(reIndented);
} catch (e) {
} catch {
// not valid js (ie. the generated stage has placeholders for the user to fill etc ..)
return reIndented;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const fetchIndexes = (): PipelineBuilderThunkAction<Promise<void>> => {
type: ActionTypes.FetchIndexesFinished,
indexes,
});
} catch (e) {
} catch {
dispatch({
type: ActionTypes.FetchIndexesFailed,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CompassGuideCueStorage implements GuideCueStorage {
get data(): GuideCueData {
try {
return JSON.parse(this.storage.getItem(this.key) ?? '[]');
} catch (e) {
} catch {
return [];
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Icon from '@leafygreen-ui/icon';

type IndexDirection = number | unknown;
type IndexDirection = unknown;

const IndexIcon = ({
className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('CompassConnections store', function () {
// Connect method should not reject, all the logic is encapsulated,
// there is no reason to expose the error outside the store
await connectPromise;
} catch (err) {
} catch {
expect.fail('Expected connect() method to not throw');
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function stringifyBSON(value: any) {
return EJSON.stringify(value);
}

export function unBSON(value: any | any[]): any | any[] {
export function unBSON(value: any): any {
const shape = getValueShape(value);
if (shape === 'array') {
return value.map(unBSON);
} else if (shape === 'object') {
const mapped: Record<string, any | any[]> = {};
const mapped: Record<string, any> = {};
for (const [k, v] of Object.entries(value)) {
mapped[k] = unBSON(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export type ArrayItemBranch = UnifiedBranch & {

export type Branch = {
path: ObjectPath;
value: any | any[];
value: any;
};

export type BranchesWithChanges = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class CellEditor
_pasteEdit(value: string) {
try {
this.editor().paste(value);
} catch (e) {
} catch {
this.editor().edit(value);
} finally {
this._pasting = false;
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-crud/src/stores/crud-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('store', function () {

try {
await dataService.dropCollection('compass-crud.test');
} catch (err) {
} catch {
// noop
}

Expand Down Expand Up @@ -357,7 +357,7 @@ describe('store', function () {
writeText: mockCopyToClipboard,
},
});
} catch (e) {
} catch {
// Electron has the global navigator as a getter.
sinon.replaceGetter(global as any, 'navigator', () => ({
clipboard: {
Expand Down Expand Up @@ -1836,7 +1836,7 @@ describe('store', function () {

try {
await dataService.dropCollection('compass-crud.timeseries');
} catch (err) {
} catch {
// noop
}

Expand Down
6 changes: 3 additions & 3 deletions packages/compass-crud/src/stores/crud-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ class CrudStoreImpl
let update;
try {
update = parseShellBSON(this.state.bulkUpdate.updateText);
} catch (err) {
} catch {
// If this couldn't parse then the update button should have been
// disabled. So if we get here it is a race condition and ignoring is
// probably OK - the button will soon appear disabled to the user anyway.
Expand Down Expand Up @@ -1978,7 +1978,7 @@ class CrudStoreImpl
let update;
try {
update = parseShellBSON(this.state.bulkUpdate.updateText);
} catch (err) {
} catch {
// If this couldn't parse then the update button should have been
// disabled. So if we get here it is a race condition and ignoring is
// probably OK - the button will soon appear disabled to the user anyway.
Expand Down Expand Up @@ -2193,7 +2193,7 @@ export async function findAndModifyWithFLEFallback(
{ promoteValues: false }
);
return [undefined, docs[0]] as ErrorOrResult;
} catch (e) {
} catch {
/* fallthrough */
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-crud/src/utils/cancellable-queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ describe('cancellable-queries', function () {

try {
await dataService.dropCollection('cancel.numbers');
} catch (err) {
} catch {
// noop
}
await dataService.insertMany('cancel.numbers', docs, {});

try {
await dataService.dropCollection('cancel.empty');
} catch (err) {
} catch {
// noop
}
await dataService.createCollection('cancel.empty', {});
Expand All @@ -60,7 +60,7 @@ describe('cancellable-queries', function () {
if (dataService) {
try {
await dataService.disconnect();
} catch (err) {
} catch {
// ignore
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DataModelStorageElectron implements DataModelStorage {
try {
const res = await this.userData.readAll();
return res.data;
} catch (err) {
} catch {
return [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-data-modeling/src/store/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export function renameDiagram(
}
dispatch({ type: DiagramActionTypes.RENAME_DIAGRAM, id, name: newName });
void dataModelStorage.save({ ...diagram, name: newName });
} catch (err) {
} catch {
// TODO log
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function existsEventually(
typeof timeout !== 'undefined' ? { timeout } : undefined
);
return true;
} catch (err) {
} catch {
// return false if not
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function screenshot(
const fullPath = path.join(LOG_SCREENSHOTS_PATH, filename);
try {
await withTimeout(10000, browser.saveScreenshot(fullPath));
} catch (err: any) {
} catch {
// For some reason browser.saveScreenshot() sometimes times out on mac with
// `WARN webdriver: Request timed out! Consider increasing the
// "connectionRetryTimeout" option.`. The default is 120 seconds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function shellEval(
if (parse === true) {
try {
result = JSON.parse(result);
} catch (err) {
} catch {
// just leave it unparsed for now if there's a parse error because
// that's really helpful when debugging
console.error('Could not parse result:', result);
Expand Down
6 changes: 3 additions & 3 deletions packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Compass {
let value;
try {
value = await arg.jsonValue();
} catch (err) {
} catch {
// there are still some edge cases we can't easily convert into text
console.error('could not convert', arg);
value = '¯\\_(ツ)_/¯';
Expand Down Expand Up @@ -989,7 +989,7 @@ export async function buildCompass(
try {
await getCompassBuildMetadata();
return;
} catch (e) {
} catch {
/* ignore */
}

Expand Down Expand Up @@ -1137,7 +1137,7 @@ export async function cleanup(compass?: Compass): Promise<void> {
try {
// make sure the process can exit
await compass.browser.deleteSession({ shutdownDriver: true });
} catch (_) {
} catch {
debug('browser already closed');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function mochaGlobalSetup(this: Mocha.Runner) {
try {
debug('Clearing out past logs');
fs.rmdirSync(LOG_PATH, { recursive: true });
} catch (e) {
} catch {
debug('.log dir already removed');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ describe('CSFLE / QE', function () {
// present and smaller than the default one to allow for tests to
// proceed correctly
await footer.waitForDisplayed({ reverse: true, timeout: 10000 });
} catch (err) {
} catch {
if (
mode === 'unindexed' &&
(await footer.getText()) ===
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-e2e-tests/tests/search-indexes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('Search Indexes', function () {
// Try to delete a namespace if it exists
try {
await dbInstance.dropCollection(collectionName);
} catch (e) {
} catch {
// noop
}

Expand All @@ -210,7 +210,7 @@ describe('Search Indexes', function () {
{
try {
await dbInstance.dropCollection(collectionName);
} catch (e) {
} catch {
console.log(`Failed to drop collection: ${DB_NAME}.${collectionName}`);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type ExplainPlanModalState = {
isModalOpen: boolean;
status: 'initial' | 'loading' | 'ready' | 'error';
explainPlan: SerializedExplainPlan | null;
rawExplainPlan: unknown | null;
rawExplainPlan: unknown;
explainPlanFetchId: number;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function stageCountForTelemetry(inputExpression: InputExpression) {
return {
num_stages: countAggregationStagesInString(inputExpression.aggregation),
};
} catch (ignore) {
} catch {
// Things like [{ $match: { x: NumberInt(10) } }] do not evaluate in any kind of context
return { num_stages: -1 };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-export-to-language/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function getCurrentlyConnectedUri(

try {
connectionStringUrl = dataService.getConnectionString().clone();
} catch (e) {
} catch {
return '<uri>';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/compass-generative-ai/src/atlas-ai-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class AtlasAiService {
let data;
try {
data = JSON.parse(text);
} catch (e) {
} catch {
this.logger.log.info(
this.logger.mongoLogId(1_001_000_310),
'AtlasAIService',
Expand Down
Loading