Prettier 2.0 (#393)

This commit is contained in:
Steve Faulkner
2021-01-20 09:15:01 -06:00
committed by GitHub
parent c1937ca464
commit 4be53284b5
500 changed files with 41927 additions and 41838 deletions

View File

@@ -62,15 +62,15 @@ class NotebookReadOnlyRenderer extends React.Component<NotebookRendererProps> {
prompt: (props: { id: string; contentRef: string }) => this.renderPrompt(props.id, props.contentRef),
editor: {
monaco: (props: PassedEditorProps) =>
this.props.hideInputs ? <></> : <MonacoEditor readOnly={true} {...props} editorType={"monaco"} />
}
this.props.hideInputs ? <></> : <MonacoEditor readOnly={true} {...props} editorType={"monaco"} />,
},
}}
</CodeCell>
),
markdown: ({ id, contentRef }: { id: any; contentRef: ContentRef }) => (
<MarkdownCell id={id} contentRef={contentRef} cell_type="markdown">
{{
editor: {}
editor: {},
}}
</MarkdownCell>
),
@@ -79,11 +79,11 @@ class NotebookReadOnlyRenderer extends React.Component<NotebookRendererProps> {
{{
editor: {
monaco: (props: PassedEditorProps) =>
this.props.hideInputs ? <></> : <MonacoEditor {...props} readOnly={true} editorType={"monaco"} />
}
this.props.hideInputs ? <></> : <MonacoEditor {...props} readOnly={true} editorType={"monaco"} />,
},
}}
</RawCell>
)
),
}}
</Cells>
<AzureTheme />
@@ -99,10 +99,10 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo
return dispatch(
actions.addTransform({
mediaType: transform.MIMETYPE,
component: transform
component: transform,
})
);
}
},
};
};
return mapDispatchToProps;

View File

@@ -69,7 +69,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
super(props);
this.state = {
hoveredCellId: undefined
hoveredCellId: undefined,
};
}
@@ -103,14 +103,14 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
<CodeCell id={id} contentRef={contentRef} cell_type="code">
{{
editor: {
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />,
},
prompt: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) => (
<Prompt id={id} contentRef={contentRef} isHovered={false}>
{promptContent}
</Prompt>
),
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />,
}}
</CodeCell>
),
@@ -122,9 +122,9 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
<MarkdownCell id={id} contentRef={contentRef} cell_type="markdown">
{{
editor: {
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />,
},
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />,
}}
</MarkdownCell>
),
@@ -137,12 +137,12 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
<RawCell id={id} contentRef={contentRef} cell_type="raw">
{{
editor: {
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />
monaco: (props: PassedEditorProps) => <MonacoEditor {...props} editorType={"monaco"} />,
},
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />,
}}
</RawCell>
)
),
}}
</Cells>
</KeyboardShortcuts>
@@ -163,7 +163,7 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo
return dispatch(
actions.addTransform({
mediaType: transform.MIMETYPE,
component: transform
component: transform,
})
);
},
@@ -171,10 +171,10 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo
return dispatch(
cdbActions.UpdateNotebookParentDomElt({
contentRef,
parentElt
parentElt,
})
);
}
},
};
};
return mapDispatchToProps;

View File

@@ -46,7 +46,7 @@ export class PromptPure extends React.Component<Props> {
executionCount: this.props.executionCount,
runCell: this.props.executeCell,
stopCell: this.props.stopExecution,
isHovered: this.props.isHovered
isHovered: this.props.isHovered,
})}
</div>
);
@@ -74,7 +74,7 @@ const makeMapStateToProps = (state: CdbAppState, ownProps: ComponentProps): ((st
return {
status,
executionCount,
isHovered
isHovered,
};
};
return mapStateToProps;
@@ -89,11 +89,11 @@ const mapDispatchToProps = (
dispatch(
cdbActions.traceNotebookTelemetry({
action: Action.ExecuteCellPromptBtn,
actionModifier: ActionModifiers.Mark
actionModifier: ActionModifiers.Mark,
})
);
},
stopExecution: () => dispatch(actions.interruptKernel({}))
stopExecution: () => dispatch(actions.interruptKernel({})),
});
export default connect(makeMapStateToProps, mapDispatchToProps)(PromptPure);

View File

@@ -26,7 +26,7 @@ describe("StatusBar", () => {
{
lastSaved,
kernelSpecDisplayName: "javascript",
kernelStatus: "kernelStatus"
kernelStatus: "kernelStatus",
},
null,
null
@@ -45,7 +45,7 @@ describe("StatusBar", () => {
{
lastSaved: new Date(),
kernelSpecDisplayName: "python3",
kernelStatus: "kernelStatus"
kernelStatus: "kernelStatus",
},
null,
null

View File

@@ -90,7 +90,7 @@ const makeMapStateToProps = (initialState: AppState, initialProps: InitialProps)
return {
kernelStatus: NOT_CONNECTED,
kernelSpecDisplayName: "no kernel",
lastSaved: null
lastSaved: null,
};
}
@@ -118,7 +118,7 @@ const makeMapStateToProps = (initialState: AppState, initialProps: InitialProps)
return {
kernelSpecDisplayName,
kernelStatus,
lastSaved
lastSaved,
};
};

View File

@@ -7,7 +7,7 @@ import { IconButton } from "office-ui-fabric-react/lib/Button";
import {
DirectionalHint,
IContextualMenuItem,
ContextualMenuItemType
ContextualMenuItemType,
} from "office-ui-fabric-react/lib/ContextualMenu";
import { actions, AppState, DocumentRecordProps } from "@nteract/core";
import { CellToolbarContext } from "@nteract/stateful-components";
@@ -54,7 +54,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.executeCell();
this.props.traceNotebookTelemetry(Action.NotebooksExecuteCellFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Clear Outputs",
@@ -62,19 +62,19 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.clearOutputs();
this.props.traceNotebookTelemetry(Action.NotebooksClearOutputsFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Divider",
itemType: ContextualMenuItemType.Divider
}
itemType: ContextualMenuItemType.Divider,
},
]);
}
items = items.concat([
{
key: "Divider2",
itemType: ContextualMenuItemType.Divider
itemType: ContextualMenuItemType.Divider,
},
{
key: "Insert Code Cell Above",
@@ -82,7 +82,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.insertCodeCellAbove();
this.props.traceNotebookTelemetry(Action.NotebooksInsertCodeCellAboveFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Insert Code Cell Below",
@@ -90,7 +90,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.insertCodeCellBelow();
this.props.traceNotebookTelemetry(Action.NotebooksInsertCodeCellBelowFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Insert Text Cell Above",
@@ -98,7 +98,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.insertTextCellAbove();
this.props.traceNotebookTelemetry(Action.NotebooksInsertTextCellAboveFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Insert Text Cell Below",
@@ -106,12 +106,12 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.insertTextCellBelow();
this.props.traceNotebookTelemetry(Action.NotebooksInsertTextCellBelowFromMenu, ActionModifiers.Mark);
}
},
},
{
key: "Divider3",
itemType: ContextualMenuItemType.Divider
}
itemType: ContextualMenuItemType.Divider,
},
]);
const moveItems: IContextualMenuItem[] = [];
@@ -122,7 +122,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.moveCell(this.props.cellIdAbove, true);
this.props.traceNotebookTelemetry(Action.NotebooksMoveCellUpFromMenu, ActionModifiers.Mark);
}
},
});
}
@@ -133,14 +133,14 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.moveCell(this.props.cellIdBelow, false);
this.props.traceNotebookTelemetry(Action.NotebooksMoveCellDownFromMenu, ActionModifiers.Mark);
}
},
});
}
if (moveItems.length > 0) {
moveItems.push({
key: "Divider4",
itemType: ContextualMenuItemType.Divider
itemType: ContextualMenuItemType.Divider,
});
items = items.concat(moveItems);
}
@@ -151,7 +151,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
onClick: () => {
this.props.deleteCell();
this.props.traceNotebookTelemetry(Action.DeleteCellFromMenu, ActionModifiers.Mark);
}
},
});
const menuItemLabel = "More";
@@ -162,12 +162,12 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
ariaLabel={menuItemLabel}
menuIconProps={{
iconName: menuItemLabel,
styles: { root: { fontSize: "18px", fontWeight: "bold" } }
styles: { root: { fontSize: "18px", fontWeight: "bold" } },
}}
menuProps={{
isBeakVisible: false,
directionalHint: DirectionalHint.bottomRightEdge,
items
items,
}}
/>
);
@@ -188,7 +188,7 @@ const mapDispatchToProps = (
clearOutputs: () => dispatch(actions.clearOutputs({ id, contentRef })),
deleteCell: () => dispatch(actions.deleteCell({ id, contentRef })),
traceNotebookTelemetry: (action: Action, actionModifier?: string, data?: any) =>
dispatch(cdbActions.traceNotebookTelemetry({ action, actionModifier, data }))
dispatch(cdbActions.traceNotebookTelemetry({ action, actionModifier, data })),
});
const makeMapStateToProps = (state: AppState, ownProps: ComponentProps): ((state: AppState) => StateProps) => {
@@ -204,7 +204,7 @@ const makeMapStateToProps = (state: AppState, ownProps: ComponentProps): ((state
return {
cellType,
cellIdAbove,
cellIdBelow
cellIdBelow,
};
};
return mapStateToProps;

View File

@@ -193,12 +193,12 @@ const mapStateToProps = (state: AppState, ownProps: ComponentProps) => {
if (model && model.type === "notebook") {
const cellOrder = selectors.notebook.cellOrder(model);
const cellIndex = cellOrder.findIndex(cellId => cellId === id);
const cellIndex = cellOrder.findIndex((cellId) => cellId === id);
isFirstCell = cellIndex === 0;
}
return {
isFirstCell
isFirstCell,
};
};
@@ -208,7 +208,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
createCellAppend: (payload: { cellType: CellType; contentRef: ContentRef }) =>
dispatch(actions.createCellAppend(payload)),
createCellBelow: (payload: { cellType: CellType; id?: string; source: string; contentRef: ContentRef }) =>
dispatch(actions.createCellBelow(payload))
dispatch(actions.createCellBelow(payload)),
});
export default connect(mapStateToProps, mapDispatchToProps)(CellCreator);

View File

@@ -36,7 +36,7 @@ const makeMapStateToProps = (state: AppState, ownProps: ComponentProps): ((state
const cellIndex = cellOrder.indexOf(ownProps.id);
return {
cellIndex
cellIndex,
};
};
return mapStateToProps;

View File

@@ -34,7 +34,7 @@ const mapDispatchToProps = (
{ id, contentRef }: { id: string; contentRef: ContentRef }
): DispatchProps => ({
hover: () => dispatch(actions.setHoveredCell({ cellId: id })),
unHover: () => dispatch(actions.setHoveredCell({ cellId: undefined }))
unHover: () => dispatch(actions.setHoveredCell({ cellId: undefined })),
});
export default connect(undefined, mapDispatchToProps)(HoverableCell);

View File

@@ -9,7 +9,7 @@ import {
DragSourceMonitor,
DropTarget,
DropTargetConnector,
DropTargetMonitor
DropTargetMonitor,
} from "react-dnd";
import { connect } from "react-redux";
@@ -43,7 +43,7 @@ const cellDragPreviewImage = [
"s46mRlWqQiudxebVV3gAj7C9hXsmgZeztnfe/91YODEr3IoF/JY/sE2gbGaVLci3",
"hh0tRtWNvsm16JmNcOs6N9dW72LP7yOtWbEhjAUkZ+icoJ5HbE6+NSxMjKWe6cKb",
"GkUWgMwiFbXSlRpFkXelUlF4F70rVd7Bd4oZ/LL8xiDmtPV2Nwyf2zOlTfHERY7i",
"Haa1+w2+iFqx0aIgvgAAAABJRU5ErkJggg=="
"Haa1+w2+iFqx0aIgvgAAAABJRU5ErkJggg==",
].join("");
interface Props {
@@ -72,13 +72,13 @@ interface State {
const cellSource = {
beginDrag(props: Props) {
return {
id: props.id
id: props.id,
};
}
},
};
const DragHandle = styled.div.attrs({
role: "presentation"
role: "presentation",
})`
position: absolute;
z-index: 200;
@@ -93,12 +93,12 @@ interface DragAreaProps {
hoverUpperHalf: boolean;
}
const DragArea = styled.div.attrs<DragAreaProps>(props => ({
const DragArea = styled.div.attrs<DragAreaProps>((props) => ({
style: {
opacity: props.isDragging ? 0.25 : 1,
borderTop: props.isOver && props.hoverUpperHalf ? "3px lightgray solid" : "3px transparent solid",
borderBottom: props.isOver && !props.hoverUpperHalf ? "3px lightgray solid" : "3px transparent solid"
}
borderBottom: props.isOver && !props.hoverUpperHalf ? "3px lightgray solid" : "3px transparent solid",
},
}))`
padding: 10px;
margin-top: -15px;
@@ -128,7 +128,7 @@ export const cellTarget = {
id: monitor.getItem().id,
destinationId: props.id,
above: hoverUpperHalf,
contentRef: props.contentRef
contentRef: props.contentRef,
});
}
},
@@ -136,10 +136,10 @@ export const cellTarget = {
hover(props: Props, monitor: DropTargetMonitor, component: any): void {
if (monitor) {
component.setState({
hoverUpperHalf: isDragUpper(props, monitor, component.el)
hoverUpperHalf: isDragUpper(props, monitor, component.el),
});
}
}
},
};
function collectSource(
@@ -153,7 +153,7 @@ function collectSource(
return {
connectDragSource: connect.dragSource(),
isDragging: monitor.isDragging(),
connectDragPreview: connect.dragPreview()
connectDragPreview: connect.dragPreview(),
};
}
@@ -166,7 +166,7 @@ function collectTarget(
} {
return {
connectDropTarget: connect.dropTarget(),
isOver: monitor.isOver()
isOver: monitor.isOver(),
};
}
@@ -174,7 +174,7 @@ export class DraggableCellView extends React.Component<Props & DnDSourceProps &
el?: HTMLDivElement | null;
state = {
hoverUpperHalf: true
hoverUpperHalf: true,
};
componentDidMount(): void {
@@ -201,7 +201,7 @@ export class DraggableCellView extends React.Component<Props & DnDSourceProps &
isDragging={this.props.isDragging}
hoverUpperHalf={this.state.hoverUpperHalf}
isOver={this.props.isOver}
ref={el => {
ref={(el) => {
this.el = el;
}}
>
@@ -226,7 +226,7 @@ const target = DropTarget<Props, DnDTargetProps>("CELL", cellTarget, collectTarg
export const makeMapDispatchToProps = (initialDispatch: Dispatch) => {
const mapDispatchToProps = (dispatch: Dispatch) => ({
moveCell: (payload: actions.MoveCell["payload"]) => dispatch(actions.moveCell(payload)),
focusCell: (payload: actions.FocusCell["payload"]) => dispatch(actions.focusCell(payload))
focusCell: (payload: actions.FocusCell["payload"]) => dispatch(actions.focusCell(payload)),
});
return mapDispatchToProps;
};

View File

@@ -60,7 +60,7 @@ export class HijackScroll extends React.Component<Props> {
<div
onClick={this.props.selectCell}
role="presentation"
ref={el => {
ref={(el) => {
this.el = el;
}}
>
@@ -81,7 +81,7 @@ const makeMapStateToProps = (initialState: AppState, ownProps: ComponentProps) =
}
return {
focused
focused,
};
};
return mapStateToProps;
@@ -89,7 +89,7 @@ const makeMapStateToProps = (initialState: AppState, ownProps: ComponentProps) =
const makeMapDispatchToProps = (initialDispatch: Dispatch, ownProps: ComponentProps) => {
const mapDispatchToProps = (dispatch: Dispatch) => ({
selectCell: () => dispatch(actions.focusCell({ id: ownProps.id, contentRef: ownProps.contentRef }))
selectCell: () => dispatch(actions.focusCell({ id: ownProps.id, contentRef: ownProps.contentRef })),
});
return mapDispatchToProps;
};

View File

@@ -59,7 +59,7 @@ export class KeyboardShortcuts extends React.Component<Props> {
contentRef,
cellOrder,
focusedCell,
cellMap
cellMap,
} = this.props;
let ctrlKeyPressed = e.ctrlKey;
@@ -90,7 +90,7 @@ export class KeyboardShortcuts extends React.Component<Props> {
focusNextCell({
id: undefined,
createCellIfUndefined: true,
contentRef
contentRef,
});
/** Only focus the next editor if it is a code cell or a cell
@@ -125,7 +125,7 @@ export const makeMapStateToProps = (state: AppState, ownProps: ComponentProps) =
return {
cellOrder,
cellMap,
focusedCell
focusedCell,
};
};
return mapStateToProps;
@@ -136,7 +136,7 @@ export const mapDispatchToProps = (dispatch: Dispatch) => ({
focusNextCell: (payload: { id?: CellId; createCellIfUndefined: boolean; contentRef: ContentRef }) =>
dispatch(actions.focusNextCell(payload)),
focusNextCellEditor: (payload: { id?: CellId; contentRef: ContentRef }) =>
dispatch(actions.focusNextCellEditor(payload))
dispatch(actions.focusNextCellEditor(payload)),
});
export default connect(makeMapStateToProps, mapDispatchToProps)(KeyboardShortcuts);