Skip to content
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

Reformat files and update lint config #297

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
68c6b91
Reformat devserver with Prettier
RichDom2185 Mar 26, 2024
98b3571
Reformat scripts with Prettier
RichDom2185 Mar 26, 2024
246ad13
Reformat tabs with Prettier
RichDom2185 Mar 26, 2024
d57c4c3
Reformat bundles with Prettier
RichDom2185 Mar 26, 2024
ed00f2c
Reformat config files with Prettier
RichDom2185 Mar 26, 2024
b33035b
Merge branch 'master' of https://github.com/source-academy/modules in…
RichDom2185 Apr 8, 2024
e58323d
Report unused disable directives
RichDom2185 Apr 8, 2024
f0adf32
Revert some Prettier devserver changes
RichDom2185 Apr 8, 2024
0a1c106
Revert some changes
RichDom2185 Apr 11, 2024
790b2cb
Revert some changes
RichDom2185 Apr 11, 2024
74a8d9b
Update .gitignore
RichDom2185 Apr 11, 2024
b24ad87
Revert some changes in scripts
RichDom2185 Apr 11, 2024
77eaa1a
Reformat ModalDiv
RichDom2185 Apr 11, 2024
c440062
Revert some changes in tabs
RichDom2185 Apr 11, 2024
3184411
Revert some changes in tabs
RichDom2185 Apr 11, 2024
b19b3f3
Reformat some files manually
RichDom2185 Apr 11, 2024
e049d79
Revert some changes in bundles
RichDom2185 Apr 11, 2024
1af7840
Reformat sound.test.ts
RichDom2185 Apr 11, 2024
a2caec5
Revert some changes in bundles
RichDom2185 Apr 11, 2024
63ed6ac
Downgrade unused disable directives severity
RichDom2185 Apr 11, 2024
393d095
Revert some changes in bundles
RichDom2185 Apr 11, 2024
690e0c4
Revert some changes in bundles
RichDom2185 Apr 13, 2024
2708100
Fix arrow parens lint
RichDom2185 Apr 13, 2024
7be4131
Enforce member delimiter style
RichDom2185 Apr 13, 2024
ff56592
Make arrow-parens global
RichDom2185 Apr 13, 2024
409eb9b
Use React.FC typing
RichDom2185 Apr 13, 2024
089ce65
Reformat MarkSweep
RichDom2185 Apr 13, 2024
f319466
Standardize operator-linebreak to before
RichDom2185 Apr 13, 2024
91aad7a
Reformat devserver
RichDom2185 Apr 13, 2024
a75a77f
Reformat utils
RichDom2185 Apr 13, 2024
0facb84
Reformat MultiUserController
RichDom2185 Apr 13, 2024
15e7926
Reformat CopyGc
RichDom2185 Apr 13, 2024
b71a002
Reformat canvas_holder
RichDom2185 Apr 13, 2024
c29cfcc
Update tab template
RichDom2185 Apr 13, 2024
9085574
Lint scripts
RichDom2185 Apr 13, 2024
f9c1b5c
Merge branch 'master' into reformat-files-1
RichDom2185 Apr 13, 2024
9755239
Bump actions-gh-pages to v4
RichDom2185 Apr 13, 2024
d3918d6
Reformat buildAll test
RichDom2185 Apr 13, 2024
5011783
Reformat Unity Academy tab
RichDom2185 Apr 13, 2024
7c084cb
Add empty line to EOFs
RichDom2185 Apr 13, 2024
f1d8961
Update submodule to use relative path
RichDom2185 Apr 13, 2024
9ebf333
Merge branch 'master' into reformat-files-1
RichDom2185 Apr 25, 2024
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ scripts/bin.js
.Trashes
ehthumbs.db
Thumbs.db

# IDE #
#######
.idea/
2 changes: 1 addition & 1 deletion devserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This server relies on [`Vite`](https://vitejs.dev) to create a server that automatically reloads when it detects file system changes. This allows Source Academy developers to make changes to their tabs without having to use the frontend, and have it render code changes live.

The server is designed to be run using `yarn devserver` from the repository's root directory, hence `vite.config.ts` is not located within this folder.
The server is designed to be run using `yarn devserver` from the repository's root directory, hence `vite.config.ts` is not located within this folder.
2 changes: 1 addition & 1 deletion devserver/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
82 changes: 37 additions & 45 deletions devserver/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,41 @@ const Playground: React.FC<{}> = () => {
}
};

const getAutoComplete = useCallback((row: number, col: number, callback: any) => {
getNames(editorValue, row, col, codeContext)
.then(([editorNames, displaySuggestions]) => {
if (!displaySuggestions) {
callback();
return;
}

const editorSuggestions = editorNames.map((editorName: any) => ({
...editorName,
caption: editorName.name,
value: editorName.name,
score: editorName.score ? editorName.score + 1000 : 1000,
name: undefined
}));

const builtins: Record<string, any> = SourceDocumentation.builtins[Chapter.SOURCE_4];
const builtinSuggestions = Object.entries(builtins)
.map(([builtin, thing]) => ({
...thing,
caption: builtin,
value: builtin,
score: 100,
name: builtin,
docHTML: thing.description
const getAutoComplete = useCallback(
(row: number, col: number, callback: any) => {
getNames(editorValue, row, col, codeContext).then(
([editorNames, displaySuggestions]) => {
if (!displaySuggestions) {
callback();
return;
}

const editorSuggestions = editorNames.map((editorName: any) => ({
...editorName,
caption: editorName.name,
value: editorName.name,
score: editorName.score ? editorName.score + 1000 : 1000,
name: undefined
}));

callback(null, [
...builtinSuggestions,
...editorSuggestions
]);
});
}, [editorValue, codeContext]);
const builtins: Record<string, any> = SourceDocumentation.builtins[Chapter.SOURCE_4];
const builtinSuggestions = Object.entries(builtins).map(
([builtin, thing]) => ({
...thing,
caption: builtin,
value: builtin,
score: 100,
name: builtin,
docHTML: thing.description
})
);

callback(null, [...builtinSuggestions, ...editorSuggestions]);
});
}, [editorValue, codeContext]);

const loadTabs = () => getDynamicTabs(codeContext)
.then((tabs) => {
.then(tabs => {
setDynamicTabs(tabs);

const newIds = tabs.map(({ id }) => id);
Expand All @@ -104,7 +103,7 @@ const Playground: React.FC<{}> = () => {
}
setAlerts(newIds);
})
.catch((error) => {
.catch(error => {
showToast(errorToast);
console.log(error);
});
Expand All @@ -115,7 +114,7 @@ const Playground: React.FC<{}> = () => {
codeContext.moduleContexts = mockModuleContext.moduleContexts = {};

runInContext(editorValue, codeContext)
.then((result) => {
.then(result => {
if (codeContext.errors.length > 0) {
showToast(errorToast);
} else {
Expand Down Expand Up @@ -160,13 +159,8 @@ const Playground: React.FC<{}> = () => {
controlBarProps: {
editorButtons: [
<ControlBarRunButton handleEditorEval={evalCode} key="eval" />,
<ControlBarClearButton onClick={resetEditor}
key="clear"
/>,
<ControlBarRefreshButton
onClick={onRefresh}
key="refresh"
/>
<ControlBarClearButton onClick={resetEditor} key="clear" />,
<ControlBarRefreshButton onClick={onRefresh} key="refresh" />
]
},
replProps: {
Expand All @@ -184,16 +178,14 @@ const Playground: React.FC<{}> = () => {
selectedTabId,
onChange: useCallback((newId: string) => {
setSelectedTab(newId);
setAlerts(alerts.filter((id) => id !== newId));
setAlerts(alerts.filter(id => id !== newId));
}, [alerts]),
alerts
}
};

return (
<HotKeys
className={classNames('Playground', Classes.DARK)}
>
<HotKeys className={classNames('Playground', Classes.DARK)}>
<OverlayToaster ref={toaster} />
<Workspace {...workspaceProps} />
</HotKeys>
Expand Down
10 changes: 5 additions & 5 deletions devserver/src/components/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { useDimensions } from './utils/Hooks';

type DispatchProps = {
handleEditorEval: () => void;
handleEditorValueChange: (newValue: string) => void
handlePromptAutocomplete: (row: number, col: number, callback: any) => void
handleEditorValueChange: (newValue: string) => void;
handlePromptAutocomplete: (row: number, col: number, callback: any) => void;
};

type StateProps = {
Expand All @@ -21,17 +21,17 @@ type StateProps = {
replProps: ReplProps;
sideContentHeight?: number;
sideContentIsResizeable?: boolean;
editorValue: string
editorValue: string;

sideContentProps: SideContentProps
sideContentProps: SideContentProps;
};

const rightResizeOnly: Enable = { right: true };
const bottomResizeOnly: Enable = { bottom: true };

export type WorkspaceProps = DispatchProps & StateProps;

const Workspace: React.FC<WorkspaceProps> = (props) => {
const Workspace: React.FC<WorkspaceProps> = props => {
const contentContainerDiv = React.useRef<HTMLDivElement | null>(null);
const editorDividerDiv = React.useRef<HTMLDivElement | null>(null);
const leftParentResizable = React.useRef<Resizable | null>(null);
Expand Down
6 changes: 4 additions & 2 deletions devserver/src/components/controlBar/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ export type ControlBarProps = {
editingWorkspaceButtons?: Array<JSX.Element | null>;
};

const ControlBar: React.FC<ControlBarProps> = (props) => {
const ControlBar: React.FC<ControlBarProps> = props => {
const editorControl = (
<div className={classNames('ControlBar_editor', Classes.BUTTON_GROUP)}>
{props.editorButtons}
</div>
);

const flowControl = props.flowButtons && (
<div className={classNames('ControlBar_flow', Classes.BUTTON_GROUP)}>{props.flowButtons}</div>
<div className={classNames('ControlBar_flow', Classes.BUTTON_GROUP)}>
{props.flowButtons}
</div>
);

const editingWorkspaceControl = (
Expand Down
18 changes: 10 additions & 8 deletions devserver/src/components/controlBar/ControlBarClearButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { IconNames } from '@blueprintjs/icons';
import ControlButton from '../ControlButton';

type Props = {
onClick: () => void
onClick: () => void;
};

export const ControlBarClearButton = (props: Props) => <Tooltip content="Clear the editor and context">
<ControlButton
label="Clear"
icon={IconNames.Trash}
onClick={props.onClick}
/>
</Tooltip>;
export const ControlBarClearButton = (props: Props) => (
<Tooltip content="Clear the editor and context">
<ControlButton
label="Clear"
icon={IconNames.Trash}
onClick={props.onClick}
/>
</Tooltip>
);
18 changes: 10 additions & 8 deletions devserver/src/components/controlBar/ControlBarRefreshButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { IconNames } from '@blueprintjs/icons';
import ControlButton from '../ControlButton';

type Props = {
onClick: () => void
onClick: () => void;
};

export const ControlBarRefreshButton = (props: Props) => <Tooltip content="Manually refresh the side content">
<ControlButton
onClick={props.onClick}
icon={IconNames.Refresh}
label="Refresh"
/>
</Tooltip>;
export const ControlBarRefreshButton = (props: Props) => (
<Tooltip content="Manually refresh the side content">
<ControlButton
onClick={props.onClick}
icon={IconNames.Refresh}
label="Refresh"
/>
</Tooltip>
);
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type StateProps = {

type ControlButtonRunButtonProps = DispatchProps & StateProps;

export const ControlBarRunButton: React.FC<ControlButtonRunButtonProps> = (props) => {
export const ControlBarRunButton: React.FC<ControlButtonRunButtonProps> = props => {
const tooltipContent = 'Evaluate the program';
return (
<Tooltip content={tooltipContent} placement={Position.TOP}>
Expand Down
11 changes: 5 additions & 6 deletions devserver/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type DispatchProps = {

export type EditorStateProps = {
newCursorPosition?: Position;
editorValue: string
handleEditorValueChange: (newCode: string) => void
editorValue: string;
handleEditorValueChange: (newCode: string) => void;
};

export type EditorProps = DispatchProps & EditorStateProps;
Expand Down Expand Up @@ -91,10 +91,9 @@ const Editor: React.FC<EditorProps> = (props: EditorProps) => {
// The () => ref.current() are designed to use the latest instance only.

// Start autocompletion
acequire('ace/ext/language_tools')
.setCompleters([
makeCompleter((...args) => handlePromptAutocompleteRef.current(...args))
]);
acequire('ace/ext/language_tools').setCompleters([
makeCompleter((...args) => handlePromptAutocompleteRef.current(...args))
]);
}, [editor]);

React.useLayoutEffect(() => {
Expand Down
8 changes: 6 additions & 2 deletions devserver/src/components/repl/Repl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const Output: React.FC<OutputProps> = (props: OutputProps) => {
case 'running':
return (
<Card>
<Pre className="log-output">{props.output.consoleLogs.join('\n')}</Pre>
<Pre className="log-output">
{props.output.consoleLogs.join('\n')}
</Pre>
</Card>
);
case 'result':
Expand All @@ -32,7 +34,9 @@ const Output: React.FC<OutputProps> = (props: OutputProps) => {
}
return (
<Card>
<Pre className="log-output">{props.output.consoleLogs.join('\n')}</Pre>
<Pre className="log-output">
{props.output.consoleLogs.join('\n')}
</Pre>
<Pre className="result-output">{props.output.value}</Pre>
</Card>
);
Expand Down
10 changes: 5 additions & 5 deletions devserver/src/components/sideContent/SideContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export type SideContentProps = {
renderActiveTabPanelOnly?: boolean;
editorWidth?: string;
sideContentHeight?: number;
dynamicTabs: SideContentTab[]
dynamicTabs: SideContentTab[];

selectedTabId: string
alerts: string[]
onChange?: (newId: string, oldId: string) => void
selectedTabId: string;
alerts: string[];
onChange?: (newId: string, oldId: string) => void;
};

const renderTab = (
Expand Down Expand Up @@ -89,7 +89,7 @@ const SideContent: React.FC<SideContentProps> = ({
if (onChange) onChange(newId, oldId);
}}
>
{dynamicTabs.map((tab) => renderTab(tab, alerts.includes(tab.id), editorWidth, sideContentHeight))}
{dynamicTabs.map(tab => renderTab(tab, alerts.includes(tab.id), editorWidth, sideContentHeight))}
</Tabs>
</div>
</Card>
Expand Down
37 changes: 22 additions & 15 deletions devserver/src/components/sideContent/TestTab.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { IconNames } from '@blueprintjs/icons';
import type { SideContentTab } from './types';

const TestTab = () => <div style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginBottom: '5px'
}}>
<h2>Source Academy Tab Development Server</h2>
<p style={{
}}>
Run some code that imports modules in the editor on the left. You should see the corresponding module tab spawn.<br />
Whenever you make changes to the tab, the server should automatically reload and show the changes that you've made <br />
If that does not happen, you can click the refresh button to manually reload tabs
</p>
</div>;
const TestTab = () => (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginBottom: '5px'
}}
>
<h2>Source Academy Tab Development Server</h2>
<p>
Run some code that imports modules in the editor on the left. You should
see the corresponding module tab spawn.
<br />
Whenever you make changes to the tab, the server should automatically
reload and show the changes that you've made <br />
If that does not happen, you can click the refresh button to manually
reload tabs
</p>
</div>
);

const testTabContent: SideContentTab = {
id: 'test',
label: 'Welcome to the tab development server!',
iconName: IconNames.LabTest,
body: <TestTab/ >
body: <TestTab />
};

export default testTabContent;
Loading
Loading