Skip to content

Commit 71cf178

Browse files
committed
fix(eslint): update eslint to latest and resolve all new issues
1 parent 398d623 commit 71cf178

File tree

94 files changed

+892
-950
lines changed

Some content is hidden

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

94 files changed

+892
-950
lines changed

configs/eslint-config-compass/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
"@babel/eslint-parser": "^7.14.3",
1919
"@mongodb-js/eslint-config-devtools": "^0.9.9",
2020
"@mongodb-js/eslint-plugin-compass": "^1.2.17",
21-
"@typescript-eslint/eslint-plugin": "^8.43.0",
22-
"@typescript-eslint/parser": "^8.43.0",
21+
"@typescript-eslint/eslint-plugin": "^8.46.2",
22+
"@typescript-eslint/parser": "^8.46.2",
2323
"eslint": "^8.57.1",
2424
"eslint-config-prettier": "^8.3.0",
2525
"eslint-plugin-chai-friendly": "^1.1.0",
2626
"eslint-plugin-filename-rules": "^1.2.0",
2727
"eslint-plugin-jsx-a11y": "^6.10.2",
2828
"eslint-plugin-mocha": "^8.0.0",
2929
"eslint-plugin-react": "^7.37.5",
30-
"eslint-plugin-react-hooks": "^5.2.0"
30+
"eslint-plugin-react-hooks": "^7.0.1"
3131
},
3232
"scripts": {
3333
"prettier": "prettier-compass",

configs/testing-library-compass/src/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,12 @@ function createWrapper(
340340
const StoreGetter: React.FunctionComponent = ({ children }) => {
341341
const store = useStore();
342342
const actions = useConnectionActions();
343+
// We're breaking the rules of hooks on purpose here to expose the values
344+
// outside of the render
345+
/* eslint-disable react-hooks/immutability */
343346
wrapperState.connectionsStore.getState = store.getState.bind(store);
344347
wrapperState.connectionsStore.actions = actions;
348+
/* eslint-enable react-hooks/immutability */
345349
return <>{children}</>;
346350
};
347351
const logger = {
@@ -618,6 +622,9 @@ function createPluginWrapper<
618622
) {
619623
const ref: { current: PluginContext } = { current: {} as any };
620624
function ComponentWithProvider({ children, ...props }: any) {
625+
// We're breaking the rules of hooks on purpose here to expose the ref
626+
// outside of the render
627+
// eslint-disable-next-line react-hooks/immutability
621628
const plugin = (ref.current = Plugin.useActivate(
622629
initialPluginProps ?? ({} as any)
623630
));

package-lock.json

Lines changed: 203 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@
104104
"cheerio": "1.0.0-rc.10"
105105
},
106106
"@mongodb-js/eslint-config-devtools": {
107-
"@typescript-eslint/eslint-plugin": "^8.43.0",
108-
"@typescript-eslint/parser": "^8.43.0",
107+
"@typescript-eslint/eslint-plugin": "^8.46.2",
108+
"@typescript-eslint/parser": "^8.46.2",
109109
"eslint": "^8.57.1",
110110
"eslint-plugin-jsx-a11y": "^6.10.2",
111111
"eslint-plugin-react": "^7.37.5",
112-
"eslint-plugin-react-hooks": "^5.2.0"
112+
"eslint-plugin-react-hooks": "^7.0.1"
113113
},
114114
"@leafygreen-ui/emotion": "^4.0.9",
115115
"@leafygreen-ui/lib": "^15.3.0",

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-editor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
useDarkMode,
1010
cx,
1111
useRequiredURLSearchParams,
12+
useCurrentValueRef,
1213
} from '@mongodb-js/compass-components';
1314
import {
1415
createAggregationAutocompleter,
@@ -83,8 +84,7 @@ export const PipelineEditor: React.FunctionComponent<PipelineEditorProps> = ({
8384
const track = useTelemetry();
8485
const connectionInfoRef = useConnectionInfoRef();
8586
const editorInitialValueRef = useRef<string>(pipelineText);
86-
const editorCurrentValueRef = useRef<string>(pipelineText);
87-
editorCurrentValueRef.current = pipelineText;
87+
const editorCurrentValueRef = useCurrentValueRef<string>(pipelineText);
8888

8989
const { utmSource, utmMedium } = useRequiredURLSearchParams();
9090

@@ -112,7 +112,7 @@ export const PipelineEditor: React.FunctionComponent<PipelineEditorProps> = ({
112112
);
113113
editorInitialValueRef.current = editorCurrentValueRef.current;
114114
}
115-
}, [num_stages, track, connectionInfoRef]);
115+
}, [editorCurrentValueRef, track, num_stages, connectionInfoRef]);
116116

117117
const annotations: Annotation[] = useMemo(() => {
118118
return syntaxErrors

packages/compass-aggregations/src/components/stage-editor/stage-editor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Banner,
1515
useDarkMode,
1616
useRequiredURLSearchParams,
17+
useCurrentValueRef,
1718
} from '@mongodb-js/compass-components';
1819
import {
1920
changeStageValue,
@@ -99,8 +100,7 @@ export const StageEditor = ({
99100
const connectionInfoRef = useConnectionInfoRef();
100101
const darkMode = useDarkMode();
101102
const editorInitialValueRef = useRef<string | null>(stageValue);
102-
const editorCurrentValueRef = useRef<string | null>(stageValue);
103-
editorCurrentValueRef.current = stageValue;
103+
const editorCurrentValueRef = useCurrentValueRef<string | null>(stageValue);
104104

105105
const fields = useAutocompleteFields(namespace);
106106

@@ -150,6 +150,7 @@ export const StageEditor = ({
150150
editorInitialValueRef.current = editorCurrentValueRef.current;
151151
}
152152
}, [
153+
editorCurrentValueRef,
153154
track,
154155
num_stages,
155156
index,

packages/compass-aggregations/src/modules/pipeline-builder/pipeline-preview-manager.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('PipelinePreviewManager', function () {
3131

3232
const result = await Promise.allSettled([
3333
previewManager.getPreviewForStage(0, 'test.test', []),
34-
previewManager.cancelPreviewForStage(0),
34+
Promise.resolve(previewManager.cancelPreviewForStage(0)),
3535
]);
3636

3737
expect(result[0]).to.have.property('status', 'rejected');
@@ -108,7 +108,7 @@ describe('PipelinePreviewManager', function () {
108108
previewManager.getPreviewForStage(2, 'test.test', []),
109109
previewManager.getPreviewForStage(3, 'test.test', []),
110110
previewManager.getPreviewForStage(4, 'test.test', []),
111-
previewManager.clearQueue(1),
111+
Promise.resolve(previewManager.clearQueue(1)),
112112
]);
113113

114114
// Only pipeline for stage 0 was executed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { PipelineBuilderThunkAction } from '.';
33
import type { SearchIndex } from 'mongodb-data-service';
44
import { isAction } from '../utils/is-action';
55

6-
enum SearchIndexesStatuses {
6+
export enum SearchIndexesStatuses {
77
INITIAL = 'INITIAL',
88
LOADING = 'LOADING',
99
READY = 'READY',
@@ -39,7 +39,7 @@ export type SearchIndexesAction =
3939
type State = {
4040
isSearchIndexesSupported: boolean;
4141
indexes: SearchIndex[];
42-
status: SearchIndexesStatus;
42+
status: SearchIndexesStatuses;
4343
};
4444

4545
export const INITIAL_STATE: State = {

packages/compass-app-registry/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"reformat": "npm run eslint . -- --fix && npm run prettier -- --write ."
4949
},
5050
"dependencies": {
51+
"@mongodb-js/compass-components": "^1.56.0",
5152
"eventemitter3": "^4.0.0",
5253
"react": "^17.0.2",
5354
"react-redux": "^8.1.3",

packages/compass-app-registry/src/react-context.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import React, {
2-
createContext,
3-
useEffect,
4-
useRef,
5-
useContext,
6-
useState,
7-
} from 'react';
1+
import React, { createContext, useEffect, useContext, useState } from 'react';
2+
import { useInitialValue } from '@mongodb-js/compass-components';
83
import { globalAppRegistry, AppRegistry } from './app-registry';
94

105
/**
@@ -57,7 +52,7 @@ export function GlobalAppRegistryProvider({
5752
value?: AppRegistry;
5853
children?: React.ReactNode;
5954
}) {
60-
const appRegistry = useRef(value ?? globalAppRegistry).current;
55+
const appRegistry = useInitialValue(value ?? globalAppRegistry);
6156
return (
6257
<GlobalAppRegistryContext.Provider value={appRegistry}>
6358
{children}
@@ -73,11 +68,11 @@ export function AppRegistryProvider({
7368
children,
7469
...props
7570
}: AppRegistryProviderProps) {
76-
const initialPropsRef = useRef(props);
71+
const initialProps = useInitialValue(props);
7772
const {
7873
localAppRegistry: initialLocalAppRegistry,
7974
deactivateOnUnmount = true,
80-
} = initialPropsRef.current;
75+
} = initialProps;
8176

8277
const globalAppRegistry = useGlobalAppRegistry();
8378
const isTopLevelProvider = useIsTopLevelProvider();

0 commit comments

Comments
 (0)