Skip to content

Commit 7e2f7f1

Browse files
authored
Merge pull request #781 from mjbvz/tsmf-tsx
Make sure tsx files have same formatting as ts files
2 parents 7ec56dd + 7560f94 commit 7e2f7f1

File tree

7 files changed

+93
-110
lines changed

7 files changed

+93
-110
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[*.ts]
1+
[*.{ts,tsx,js,jsx,json}]
22
indent_style = tab
33
tab_width = 4
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare module '*.css' {
2-
const classes: { [className: string]: string };
3-
export = classes;
4-
}
1+
declare module '*.css' {
2+
const classes: { [className: string]: string };
3+
export = classes;
4+
}

notebook-renderer-react-sample/src/client/index.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import './style.css';
44

5-
import { IssuesList } from './render';
65
import errorOverlay from 'vscode-notebook-error-overlay';
76
import type { ActivationFunction } from 'vscode-notebook-renderer';
7+
import { IssuesList } from './render';
88

99
// ----------------------------------------------------------------------------
1010
// This is the entrypoint to the notebook renderer's webview client-side code.
@@ -14,33 +14,33 @@ import type { ActivationFunction } from 'vscode-notebook-renderer';
1414
// ----------------------------------------------------------------------------
1515

1616
export const activate: ActivationFunction = context => {
17-
return {
18-
renderOutputItem(outputItem, element) {
19-
let shadow = element.shadowRoot;
20-
if (!shadow) {
21-
shadow = element.attachShadow({ mode: 'open' });
22-
const root = document.createElement('div');
23-
root.id = 'root';
24-
shadow.append(root);
25-
}
17+
return {
18+
renderOutputItem(outputItem, element) {
19+
let shadow = element.shadowRoot;
20+
if (!shadow) {
21+
shadow = element.attachShadow({ mode: 'open' });
22+
const root = document.createElement('div');
23+
root.id = 'root';
24+
shadow.append(root);
25+
}
2626

27-
const root = shadow.querySelector<HTMLElement>('#root');
28-
if (!root) {
29-
throw new Error('Could not find root element');
30-
}
27+
const root = shadow.querySelector<HTMLElement>('#root');
28+
if (!root) {
29+
throw new Error('Could not find root element');
30+
}
3131

32-
errorOverlay.wrap(root, () => {
33-
root.innerHTML = '';
34-
const node = document.createElement('div');
35-
root.appendChild(node);
32+
errorOverlay.wrap(root, () => {
33+
root.innerHTML = '';
34+
const node = document.createElement('div');
35+
root.appendChild(node);
3636

37-
ReactDOM.render(<IssuesList info={{ container: node, mime: outputItem.mime, value: outputItem.json(), context }} />, root);
38-
});
39-
},
40-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
41-
disposeOutputItem(_outputId) {
42-
// Do any teardown here. outputId is the cell output being deleted, or
43-
// undefined if we're clearing all outputs.
44-
}
45-
};
37+
ReactDOM.render(<IssuesList info={{ container: node, mime: outputItem.mime, value: outputItem.json(), context }} />, root);
38+
});
39+
},
40+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
41+
disposeOutputItem(_outputId) {
42+
// Do any teardown here. outputId is the cell output being deleted, or
43+
// undefined if we're clearing all outputs.
44+
}
45+
};
4646
};
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
/* eslint-disable @typescript-eslint/naming-convention */
2-
import React from "react";
3-
import type { RendererContext } from 'vscode-notebook-renderer';
4-
5-
interface IRenderInfo {
6-
container: HTMLElement;
7-
mime: string;
8-
value: GitHubIssuesValue[];
9-
context: RendererContext<unknown>;
10-
}
11-
12-
interface GitHubIssuesValue {
13-
title: string;
14-
url: string;
15-
body: string;
16-
}
17-
18-
export const IssuesList: React.FC<{info: IRenderInfo}> = ({info}) => {
19-
const issues = info.value.map(item => {
20-
return <tr>
21-
<td><a href={item.url}>{item.title}</a></td>
22-
<td>{item.body}</td>
23-
</tr>;
24-
});
25-
26-
return <div>
27-
<table>
28-
<tr>
29-
<th>Issue</th>
30-
<th>Description</th>
31-
</tr>
32-
{issues}
33-
</table>
34-
</div>;
35-
};
36-
37-
if (module.hot) {
38-
module.hot.addDisposeHandler(() => {
39-
// In development, this will be called before the renderer is reloaded. You
40-
// can use this to clean up or stash any state.
41-
});
42-
}
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
import React from "react";
3+
import type { RendererContext } from 'vscode-notebook-renderer';
4+
5+
interface IRenderInfo {
6+
container: HTMLElement;
7+
mime: string;
8+
value: GitHubIssuesValue[];
9+
context: RendererContext<unknown>;
10+
}
11+
12+
interface GitHubIssuesValue {
13+
title: string;
14+
url: string;
15+
body: string;
16+
}
17+
18+
export const IssuesList: React.FC<{ info: IRenderInfo }> = ({ info }) => {
19+
const issues = info.value.map(item => {
20+
return <tr>
21+
<td><a href={item.url}>{item.title}</a></td>
22+
<td>{item.body}</td>
23+
</tr>;
24+
});
25+
26+
return <div>
27+
<table>
28+
<tr>
29+
<th>Issue</th>
30+
<th>Description</th>
31+
</tr>
32+
{issues}
33+
</table>
34+
</div>;
35+
};
36+
37+
if (module.hot) {
38+
module.hot.addDisposeHandler(() => {
39+
// In development, this will be called before the renderer is reloaded. You
40+
// can use this to clean up or stash any state.
41+
});
42+
}

notebook-renderer-react-sample/src/client/tsconfig.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

notebook-renderer-react-sample/src/tsconfig-base.json

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
{
2-
"files": [],
3-
"references": [
4-
{
5-
"path": "./src/client"
6-
}
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "ES2020",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"strict": true,
8+
"jsx": "react",
9+
// noEmit prevents the default tsc from building this--we use webpack instead
10+
"noEmit": true,
11+
"rootDir": ".",
12+
"types": [
13+
"webpack-env",
14+
"vscode-notebook-renderer"
15+
],
16+
"allowSyntheticDefaultImports": true
17+
},
18+
"include": [
19+
"src/**/*"
720
]
8-
}
21+
}

0 commit comments

Comments
 (0)