Skip to content

Commit 0546cc8

Browse files
committed
lint
1 parent 5eeedf6 commit 0546cc8

File tree

9 files changed

+92
-44
lines changed

9 files changed

+92
-44
lines changed

src/test/setup-themeColorReader.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,27 @@
66
import Module from 'module';
77

88
const noopChannel = {
9-
trace: () => { /* no-op */ },
10-
debug: () => { /* no-op */ },
11-
info: () => { /* no-op */ },
12-
warn: () => { /* no-op */ },
13-
error: () => { /* no-op */ },
14-
appendLine: () => { /* no-op */ },
15-
dispose: () => { /* no-op */ },
9+
trace: () => {
10+
/* no-op */
11+
},
12+
debug: () => {
13+
/* no-op */
14+
},
15+
info: () => {
16+
/* no-op */
17+
},
18+
warn: () => {
19+
/* no-op */
20+
},
21+
error: () => {
22+
/* no-op */
23+
},
24+
appendLine: () => {
25+
/* no-op */
26+
},
27+
dispose: () => {
28+
/* no-op */
29+
},
1630
};
1731

1832
const vscodeMock = {
@@ -55,4 +69,3 @@ const fakeModule = new Module('vscode');
5569
fakeModule.exports = vscodeMock;
5670
(fakeModule as any).loaded = true;
5771
require.cache['vscode'] = fakeModule;
58-

src/test/suite/utils/themeColorReader.test.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ suite('themeColorReader', function () {
3838
test('should match parent scope to child pattern', function () {
3939
// Theme scope "string" should match pattern "string.quoted"
4040
const theme: ThemeJson = {
41-
tokenColors: [
42-
{ scope: 'string', settings: { foreground: '#CE9178' } },
43-
],
41+
tokenColors: [{ scope: 'string', settings: { foreground: '#CE9178' } }],
4442
};
4543
const result = extractTokenOverrides(theme);
4644
expect(result.string).to.equal('#CE9178');
@@ -116,11 +114,20 @@ suite('themeColorReader', function () {
116114
test('should extract all supported token color types', function () {
117115
const theme: ThemeJson = {
118116
tokenColors: [
119-
{ scope: 'support.type.property-name', settings: { foreground: '#9CDCFE' } },
117+
{
118+
scope: 'support.type.property-name',
119+
settings: { foreground: '#9CDCFE' },
120+
},
120121
{ scope: 'string', settings: { foreground: '#CE9178' } },
121122
{ scope: 'constant.numeric', settings: { foreground: '#B5CEA8' } },
122-
{ scope: 'constant.language.boolean', settings: { foreground: '#569CD6' } },
123-
{ scope: 'constant.language.null', settings: { foreground: '#569CD6' } },
123+
{
124+
scope: 'constant.language.boolean',
125+
settings: { foreground: '#569CD6' },
126+
},
127+
{
128+
scope: 'constant.language.null',
129+
settings: { foreground: '#569CD6' },
130+
},
124131
{ scope: 'entity.name.type', settings: { foreground: '#4EC9B0' } },
125132
{ scope: 'comment', settings: { foreground: '#6A9955' } },
126133
{ scope: 'punctuation', settings: { foreground: '#D4D4D4' } },
@@ -203,9 +210,7 @@ suite('themeColorReader', function () {
203210
});
204211
writeThemeFile(tempDir, 'parent.json', {
205212
include: './grandparent.json',
206-
tokenColors: [
207-
{ scope: 'string', settings: { foreground: '#444444' } },
208-
],
213+
tokenColors: [{ scope: 'string', settings: { foreground: '#444444' } }],
209214
});
210215
const childPath = writeThemeFile(tempDir, 'child.json', {
211216
include: './parent.json',
@@ -214,9 +219,9 @@ suite('themeColorReader', function () {
214219
],
215220
});
216221
const result = parseThemeFile(childPath, {});
217-
expect(result.comment).to.equal('#555555'); // child
218-
expect(result.string).to.equal('#444444'); // parent
219-
expect(result.number).to.equal('#333333'); // grandparent
222+
expect(result.comment).to.equal('#555555'); // child
223+
expect(result.string).to.equal('#444444'); // parent
224+
expect(result.number).to.equal('#333333'); // grandparent
220225
});
221226

222227
test('should handle circular includes without crashing', function () {
@@ -228,9 +233,7 @@ suite('themeColorReader', function () {
228233
});
229234
writeThemeFile(tempDir, 'b.json', {
230235
include: './a.json',
231-
tokenColors: [
232-
{ scope: 'string', settings: { foreground: '#BBBBBB' } },
233-
],
236+
tokenColors: [{ scope: 'string', settings: { foreground: '#BBBBBB' } }],
234237
});
235238
const aPath = path.join(tempDir, 'a.json');
236239
// Should not throw or hang
@@ -268,7 +271,10 @@ suite('themeColorReader', function () {
268271
writeThemeFile(tempDir, `${i}.json`, {
269272
...(include ? { include } : {}),
270273
tokenColors: [
271-
{ scope: 'comment', settings: { foreground: `#${String(i).padStart(6, '0')}` } },
274+
{
275+
scope: 'comment',
276+
settings: { foreground: `#${String(i).padStart(6, '0')}` },
277+
},
272278
],
273279
});
274280
}
@@ -306,4 +312,3 @@ suite('themeColorReader', function () {
306312
});
307313
});
308314
});
309-

src/test/suite/views/data-browsing-app/documentQuerySlice.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ describe('documentQuerySlice', function () {
106106
comment: '#888888',
107107
punctuation: '#ffffff',
108108
};
109-
const result = reducer(initialState, themeColorsReceived({ themeColors, themeKind: 'vs-dark' }));
109+
const result = reducer(
110+
initialState,
111+
themeColorsReceived({ themeColors, themeKind: 'vs-dark' }),
112+
);
110113
expect(result.themeColors).to.deep.equal(themeColors);
111114
expect(result.themeKind).to.equal('vs-dark');
112115
});
@@ -125,7 +128,10 @@ describe('documentQuerySlice', function () {
125128
punctuation: '#ffffff',
126129
},
127130
};
128-
const result = reducer(stateWithColors, themeColorsReceived({ themeColors: null, themeKind: 'vs' }));
131+
const result = reducer(
132+
stateWithColors,
133+
themeColorsReceived({ themeColors: null, themeKind: 'vs' }),
134+
);
129135
expect(result.themeColors).to.be.null;
130136
expect(result.themeKind).to.equal('vs');
131137
});

src/test/suite/views/data-browsing-app/monaco-viewer.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ describe('MonacoViewer test suite', function () {
201201
punctuation: '#D4D4D4',
202202
};
203203

204-
render(<MonacoViewer document={document} themeColors={themeColors} themeKind="vs-dark" />);
204+
render(
205+
<MonacoViewer
206+
document={document}
207+
themeColors={themeColors}
208+
themeKind="vs-dark"
209+
/>,
210+
);
205211

206212
const container = screen.getByTestId('monaco-viewer-container');
207213
expect(container).to.exist;

src/utils/themeColorReader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export function getThemeTokenColors(): TokenColors {
177177
const themeName = vscode.workspace
178178
.getConfiguration('workbench')
179179
.get<string>('colorTheme');
180-
const colors: TokenColors = {}
180+
const colors: TokenColors = {};
181181

182182
if (!themeName) {
183183
log.error('Failed to read theme name from workbench settings');

src/views/data-browsing-app/monaco-viewer.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import Editor, { useMonaco, loader } from '@monaco-editor/react';
99
import type * as Monaco from 'monaco-editor';
1010
import type { editor } from 'monaco-editor';
1111
import { css, spacing } from '@mongodb-js/compass-components';
12-
import type { TokenColors, MonacoBaseTheme } from './extension-app-message-constants';
12+
import type {
13+
TokenColors,
14+
MonacoBaseTheme,
15+
} from './extension-app-message-constants';
1316
import { toJSString } from 'mongodb-query-parser';
1417
import { EJSON } from 'bson';
1518

@@ -149,8 +152,8 @@ const MonacoViewer: React.FC<MonacoViewerProps> = ({
149152
}, [themeColors]);
150153

151154
useEffect(() => {
152-
console.log(colors)
153-
console.log(themeKind)
155+
console.log(colors);
156+
console.log(themeKind);
154157
if (monaco) {
155158
monaco.editor.defineTheme('currentVSCodeTheme', {
156159
base: themeKind,
@@ -200,7 +203,12 @@ const MonacoViewer: React.FC<MonacoViewerProps> = ({
200203
}, [documentString, calculateHeight]);
201204

202205
const handleEditorMount = useCallback(
203-
(editorInstance: editor.IStandaloneCodeEditor, monacoInstance: Parameters<NonNullable<React.ComponentProps<typeof Editor>['onMount']>>[1]) => {
206+
(
207+
editorInstance: editor.IStandaloneCodeEditor,
208+
monacoInstance: Parameters<
209+
NonNullable<React.ComponentProps<typeof Editor>['onMount']>
210+
>[1],
211+
) => {
204212
editorRef.current = editorInstance;
205213
setEditorHeight(calculateHeight());
206214

@@ -221,7 +229,8 @@ const MonacoViewer: React.FC<MonacoViewerProps> = ({
221229
run: (ed) => {
222230
const selection = ed.getSelection();
223231
if (selection && !selection.isEmpty()) {
224-
const selectedText = ed.getModel()?.getValueInRange(selection) ?? '';
232+
const selectedText =
233+
ed.getModel()?.getValueInRange(selection) ?? '';
225234
void navigator.clipboard.writeText(selectedText);
226235
}
227236
},

src/views/data-browsing-app/store/documentQuerySlice.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import {
55
sendGetTotalCount,
66
sendCancelRequest,
77
} from '../vscode-api';
8-
import type { TokenColors, MonacoBaseTheme } from '../extension-app-message-constants';
8+
import type {
9+
TokenColors,
10+
MonacoBaseTheme,
11+
} from '../extension-app-message-constants';
912

1013
export interface PreviewDocument {
1114
[key: string]: unknown;
@@ -163,7 +166,10 @@ const documentQuerySlice = createSlice({
163166
},
164167
themeColorsReceived: (
165168
state,
166-
action: PayloadAction<{ themeColors: TokenColors | null; themeKind: MonacoBaseTheme }>,
169+
action: PayloadAction<{
170+
themeColors: TokenColors | null;
171+
themeKind: MonacoBaseTheme;
172+
}>,
167173
) => {
168174
state.themeColors = action.payload.themeColors;
169175
state.themeKind = action.payload.themeKind;

src/views/data-browsing-app/store/messageHandler.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export const handleExtensionMessage = (
1919
case PreviewMessageType.loadPage:
2020
dispatch(
2121
documentsReceived(
22-
message.documents
23-
? (message.documents as PreviewDocument[])
24-
: [],
22+
message.documents ? (message.documents as PreviewDocument[]) : [],
2523
),
2624
);
2725
break;
@@ -42,10 +40,12 @@ export const handleExtensionMessage = (
4240
break;
4341
}
4442
case PreviewMessageType.updateThemeColors:
45-
dispatch(themeColorsReceived({
46-
themeColors: message.themeColors,
47-
themeKind: message.themeKind,
48-
}));
43+
dispatch(
44+
themeColorsReceived({
45+
themeColors: message.themeColors,
46+
themeKind: message.themeKind,
47+
}),
48+
);
4949
break;
5050
}
5151
};

src/views/dataBrowsingController.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { createWebviewPanel, getWebviewHtml } from '../utils/webviewHelpers';
99
import type { MessageFromWebviewToExtension } from './data-browsing-app/extension-app-message-constants';
1010
import { CollectionType } from '../explorer/documentUtils';
1111
import formatError from '../utils/formatError';
12-
import { getThemeTokenColors, getMonacoBaseTheme } from '../utils/themeColorReader';
12+
import {
13+
getThemeTokenColors,
14+
getMonacoBaseTheme,
15+
} from '../utils/themeColorReader';
1316

1417
const log = createLogger('data browsing controller');
1518

0 commit comments

Comments
 (0)