Skip to content

Commit

Permalink
chore: eslint --fix across packages/*/src (#1430)
Browse files Browse the repository at this point in the history
I ran `npx prettier packages/*/src --write` to run Prettier on all src
files across packages.

I also ran `npm run lint:test` to confirm there are no more failing
tests.

resolves #1429
  • Loading branch information
bmingles authored Jul 31, 2023
1 parent d131b05 commit 0326d74
Show file tree
Hide file tree
Showing 156 changed files with 965 additions and 1,172 deletions.
4 changes: 2 additions & 2 deletions packages/app-utils/src/components/AppBootstrap.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function expectMockChild() {

function renderComponent(client: CoreClient) {
const api = TestUtils.createMockProxy<DhType>({
CoreClient: (jest
CoreClient: jest
.fn()
.mockImplementation(() => client) as unknown) as CoreClient,
.mockImplementation(() => client) as unknown as CoreClient,
});
return render(
<ApiContext.Provider value={api}>
Expand Down
17 changes: 9 additions & 8 deletions packages/app-utils/src/plugins/PluginUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ export function getAuthPluginComponent(
const authHandlers = getAuthHandlers(authConfigValues);
// Filter out all the plugins that are auth plugins, and then map them to [pluginName, AuthPlugin] pairs
// Uses some pretty disgusting casting, because TypeScript wants to treat it as an (string | AuthPlugin)[] array instead
const authPlugins = ([
...pluginMap.entries(),
].filter(([, plugin]: [string, { AuthPlugin?: AuthPlugin }]) =>
isAuthPlugin(plugin.AuthPlugin)
) as [string, { AuthPlugin: AuthPlugin }][]).map(([name, plugin]) => [
name,
plugin.AuthPlugin,
]) as [string, AuthPlugin][];
const authPlugins = (
[...pluginMap.entries()].filter(
([, plugin]: [string, { AuthPlugin?: AuthPlugin }]) =>
isAuthPlugin(plugin.AuthPlugin)
) as [string, { AuthPlugin: AuthPlugin }][]
).map(([name, plugin]) => [name, plugin.AuthPlugin]) as [
string,
AuthPlugin,
][];

// Add all the core plugins in priority
authPlugins.push(...(corePlugins ?? []));
Expand Down
8 changes: 5 additions & 3 deletions packages/auth-plugins/src/AuthPluginParent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ describe('availability tests', () => {
});

it('is available when window parent is set', () => {
const parentSpy = jest.spyOn(window, 'parent', 'get').mockReturnValue(
TestUtils.createMockProxy<Window>({ postMessage: jest.fn() })
);
const parentSpy = jest
.spyOn(window, 'parent', 'get')
.mockReturnValue(
TestUtils.createMockProxy<Window>({ postMessage: jest.fn() })
);
window.history.pushState(
{},
'Test Title',
Expand Down
5 changes: 2 additions & 3 deletions packages/auth-plugins/src/UserContexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export type UserPermissionsOverride = Partial<UserPermissions>;

export const UserOverrideContext = createContext<UserOverride>({});

export const UserPermissionsOverrideContext = createContext<UserPermissionsOverride>(
{}
);
export const UserPermissionsOverrideContext =
createContext<UserPermissionsOverride>({});

export const UserContext = createContext<User | null>(null);
9 changes: 4 additions & 5 deletions packages/chart/src/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export class Chart extends Component<ChartProps, ChartState> {

handleRestyle([changes, seriesIndexes]: readonly [
Record<string, unknown>,
number[]
number[],
]): void {
log.debug('handleRestyle', changes, seriesIndexes);
if (Object.keys(changes).includes('visible')) {
Expand Down Expand Up @@ -522,9 +522,8 @@ export class Chart extends Component<ChartProps, ChartState> {

updateFormatterSettings(settings: FormatterSettings): void {
const columnFormats = FormatterUtils.getColumnFormats(settings);
const dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(
settings
);
const dateTimeFormatterOptions =
FormatterUtils.getDateTimeFormatterOptions(settings);
const { decimalFormatOptions = {}, integerFormatOptions = {} } = settings;

if (
Expand Down Expand Up @@ -565,7 +564,7 @@ export class Chart extends Component<ChartProps, ChartState> {
// Call relayout to resize avoiding the debouncing plotly does
// https://github.com/plotly/plotly.js/issues/2769#issuecomment-402099552
PlotlyProp.relayout(
((this.plot.current as unknown) as { el: HTMLElement }).el,
(this.plot.current as unknown as { el: HTMLElement }).el,
{
autosize: true,
}
Expand Down
36 changes: 18 additions & 18 deletions packages/chart/src/ChartUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ describe('handles subplots and columns/rows correctly', () => {
chartTestUtils.makeChart({ axes, row: 1 }),
];
const figure = chartTestUtils.makeFigure({ charts, rows: 2 });
expect(
chartUtils.getChartBounds(figure, charts[0], width, height)
).toEqual({ bottom: 0.5 + halfYMargin, top: 1, left: 0, right: 1 });
expect(
chartUtils.getChartBounds(figure, charts[1], width, height)
).toEqual({ bottom: 0, top: 0.5 - halfYMargin, left: 0, right: 1 });
expect(chartUtils.getChartBounds(figure, charts[0], width, height)).toEqual(
{ bottom: 0.5 + halfYMargin, top: 1, left: 0, right: 1 }
);
expect(chartUtils.getChartBounds(figure, charts[1], width, height)).toEqual(
{ bottom: 0, top: 0.5 - halfYMargin, left: 0, right: 1 }
);
});

it('handles column location correctly', () => {
Expand All @@ -346,12 +346,12 @@ describe('handles subplots and columns/rows correctly', () => {
chartTestUtils.makeChart({ axes, column: 1 }),
];
const figure = chartTestUtils.makeFigure({ charts, cols: 2 });
expect(
chartUtils.getChartBounds(figure, charts[0], width, height)
).toEqual({ bottom: 0, top: 1, left: 0, right: 0.5 - halfXMargin });
expect(
chartUtils.getChartBounds(figure, charts[1], width, height)
).toEqual({ bottom: 0, top: 1, left: 0.5 + halfXMargin, right: 1 });
expect(chartUtils.getChartBounds(figure, charts[0], width, height)).toEqual(
{ bottom: 0, top: 1, left: 0, right: 0.5 - halfXMargin }
);
expect(chartUtils.getChartBounds(figure, charts[1], width, height)).toEqual(
{ bottom: 0, top: 1, left: 0.5 + halfXMargin, right: 1 }
);
});

it('handles colspan', () => {
Expand All @@ -378,9 +378,9 @@ describe('handles subplots and columns/rows correctly', () => {
right: 1,
}
);
expect(
chartUtils.getChartBounds(figure, charts[2], width, height)
).toEqual({ bottom: 0, top: 0.5 - halfYMargin, left: 0, right: 1 });
expect(chartUtils.getChartBounds(figure, charts[2], width, height)).toEqual(
{ bottom: 0, top: 0.5 - halfYMargin, left: 0, right: 1 }
);
});

it('handles rowspan', () => {
Expand All @@ -407,9 +407,9 @@ describe('handles subplots and columns/rows correctly', () => {
right: 0.5 - halfXMargin,
}
);
expect(
chartUtils.getChartBounds(figure, charts[2], width, height)
).toEqual({ bottom: 0, top: 1, left: 0.5 + halfXMargin, right: 1 });
expect(chartUtils.getChartBounds(figure, charts[2], width, height)).toEqual(
{ bottom: 0, top: 1, left: 0.5 + halfXMargin, right: 1 }
);
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/chart/src/ChartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,8 @@ class ChartUtils {
holidays,
timeZone: calendarTimeZone,
} = businessCalendar;
const typeFormatter = formatter?.getColumnTypeFormatter(
BUSINESS_COLUMN_TYPE
);
const typeFormatter =
formatter?.getColumnTypeFormatter(BUSINESS_COLUMN_TYPE);
let formatterTimeZone;
if (isDateTimeColumnFormatter(typeFormatter)) {
formatterTimeZone = typeFormatter.dhTimeZone;
Expand Down Expand Up @@ -638,7 +637,8 @@ class ChartUtils {
);
}

(axisFormat as RangebreakAxisFormat).rangebreaks = rangebreaks;
(axisFormat as RangebreakAxisFormat).rangebreaks =
rangebreaks;
}

if (axisFormats.size === chart.axes.length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/main/AppInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface AppInitProps {
workspace: Workspace;
workspaceStorage: WorkspaceStorage;

setActiveTool: (type: typeof ToolType[keyof typeof ToolType]) => void;
setActiveTool: (type: (typeof ToolType)[keyof typeof ToolType]) => void;
setApi: (api: DhType) => void;
setCommandHistoryStorage: (storage: PouchCommandHistoryStorage) => void;
setDashboardData: (
Expand Down
12 changes: 9 additions & 3 deletions packages/code-studio/src/main/AppMainContainer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,25 @@ $nav-space: 4px; // give a gap around some buttons for focus area that are in na
}

.grid-cursor-linker {
cursor: url('../assets/svg/cursor-linker.svg') 8 8, crosshair;
cursor:
url('../assets/svg/cursor-linker.svg') 8 8,
crosshair;
}

.grid-cursor-linker-not-allowed {
cursor: url('../assets/svg/cursor-linker-not-allowed.svg') 8 8, not-allowed;
cursor:
url('../assets/svg/cursor-linker-not-allowed.svg') 8 8,
not-allowed;
}

.linker-overlay path.link-select {
cursor: pointer;
}

.linker-overlay.danger-delete path.link-select {
cursor: url('../assets/svg/cursor-unlinker.svg') 8 8, pointer;
cursor:
url('../assets/svg/cursor-unlinker.svg') 8 8,
pointer;
}

.app-main-top-nav-menus {
Expand Down
4 changes: 2 additions & 2 deletions packages/code-studio/src/main/AppMainContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function renderAppMainContainer({
serverConfigValues={serverConfigValues}
dashboardOpenedPanelMaps={dashboardOpenedPanelMaps}
connection={connection}
session={(session as unknown) as IdeSession}
session={session as unknown as IdeSession}
sessionConfig={sessionConfig}
match={match}
plugins={plugins}
Expand Down Expand Up @@ -133,7 +133,7 @@ it('listens for widgets properly', async () => {
const user = userEvent.setup();
const TABLE_A = { name: 'a', type: 'Table' };
const TABLE_B = { name: 'b', type: 'Table' };
let callback: (obj: VariableChanges) => void = (null as unknown) as (
let callback: (obj: VariableChanges) => void = null as unknown as (
obj: VariableChanges
) => void;

Expand Down
50 changes: 20 additions & 30 deletions packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,8 @@ export class AppMainContainer extends Component<
const { updateDashboardData, updateWorkspaceData } = this.props;
const fileText = await file.text();
const exportedLayout = JSON.parse(fileText);
const {
filterSets,
layoutConfig,
links,
} = UserLayoutUtils.normalizeLayout(exportedLayout);
const { filterSets, layoutConfig, links } =
UserLayoutUtils.normalizeLayout(exportedLayout);

updateWorkspaceData({ layoutConfig });
updateDashboardData(DEFAULT_DASHBOARD_ID, {
Expand All @@ -592,14 +589,11 @@ export class AppMainContainer extends Component<
*/
async resetLayout(): Promise<void> {
const { layoutStorage, session } = this.props;
const {
filterSets,
layoutConfig,
links,
} = await UserLayoutUtils.getDefaultLayout(
layoutStorage,
session !== undefined
);
const { filterSets, layoutConfig, links } =
await UserLayoutUtils.getDefaultLayout(
layoutStorage,
session !== undefined
);

const { updateDashboardData, updateWorkspaceData } = this.props;
updateWorkspaceData({ layoutConfig });
Expand Down Expand Up @@ -648,9 +642,11 @@ export class AppMainContainer extends Component<
pluginModule != null &&
(pluginModule as { TablePlugin: ReactElement }).TablePlugin != null
) {
return (pluginModule as {
TablePlugin: TablePlugin;
}).TablePlugin;
return (
pluginModule as {
TablePlugin: TablePlugin;
}
).TablePlugin;
}

const errorMessage = `Unable to find table plugin ${pluginName}.`;
Expand Down Expand Up @@ -778,23 +774,17 @@ export class AppMainContainer extends Component<
}

getDashboardPlugins = memoize((plugins: DeephavenPluginModuleMap) =>
([...plugins.entries()].filter(
([, plugin]: [string, { DashboardPlugin?: typeof React.Component }]) =>
plugin.DashboardPlugin != null
) as [
string,
{ DashboardPlugin: typeof React.Component }
][]).map(([name, { DashboardPlugin }]) => <DashboardPlugin key={name} />)
(
[...plugins.entries()].filter(
([, plugin]: [string, { DashboardPlugin?: typeof React.Component }]) =>
plugin.DashboardPlugin != null
) as [string, { DashboardPlugin: typeof React.Component }][]
).map(([name, { DashboardPlugin }]) => <DashboardPlugin key={name} />)
);

render(): ReactElement {
const {
activeTool,
plugins,
user,
workspace,
serverConfigValues,
} = this.props;
const { activeTool, plugins, user, workspace, serverConfigValues } =
this.props;
const { data: workspaceData } = workspace;
const { layoutConfig } = workspaceData;
const { permissions } = user;
Expand Down
4 changes: 2 additions & 2 deletions packages/code-studio/src/main/UserLayoutUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ const layoutConfig: ItemConfigType[] = [
type: 'TestComponentType',
},
];
const layoutV3 = ({
const layoutV3 = {
links,
filterSets,
layoutConfig,
another: 'another test property',
version: 3,
} as unknown) as ExportedLayout;
} as unknown as ExportedLayout;
const layoutV2: ExportedLayoutV2 = {
links,
filterSets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,11 @@ export class ColumnSpecificSectionContent extends PureComponent<
);
}

getRuleError(
rule: FormatterItem
): { hasColumnNameError: boolean; hasFormatError: boolean; message: string } {
getRuleError(rule: FormatterItem): {
hasColumnNameError: boolean;
hasFormatError: boolean;
message: string;
} {
const { dh } = this.props;
const error = {
hasColumnNameError: false,
Expand Down
31 changes: 14 additions & 17 deletions packages/code-studio/src/settings/FormattingSectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,22 @@ export class FormattingSectionContent extends PureComponent<
FormattingSectionContent.inputDebounceTime
);

this.handleDefaultDateTimeFormatChange = this.handleDefaultDateTimeFormatChange.bind(
this
);
this.handleDefaultDecimalFormatChange = this.handleDefaultDecimalFormatChange.bind(
this
);
this.handleDefaultIntegerFormatChange = this.handleDefaultIntegerFormatChange.bind(
this
);
this.handleDefaultDateTimeFormatChange =
this.handleDefaultDateTimeFormatChange.bind(this);
this.handleDefaultDecimalFormatChange =
this.handleDefaultDecimalFormatChange.bind(this);
this.handleDefaultIntegerFormatChange =
this.handleDefaultIntegerFormatChange.bind(this);
this.handleShowTimeZoneChange = this.handleShowTimeZoneChange.bind(this);
this.handleShowTSeparatorChange = this.handleShowTSeparatorChange.bind(
this
);
this.handleShowTSeparatorChange =
this.handleShowTSeparatorChange.bind(this);
this.handleTimeZoneChange = this.handleTimeZoneChange.bind(this);
this.handleResetDateTimeFormat = this.handleResetDateTimeFormat.bind(this);
this.handleResetDecimalFormat = this.handleResetDecimalFormat.bind(this);
this.handleResetIntegerFormat = this.handleResetIntegerFormat.bind(this);
this.handleResetTimeZone = this.handleResetTimeZone.bind(this);
this.handleTruncateNumbersWithPoundChange = this.handleTruncateNumbersWithPoundChange.bind(
this
);
this.handleTruncateNumbersWithPoundChange =
this.handleTruncateNumbersWithPoundChange.bind(this);

const {
formatter,
Expand Down Expand Up @@ -414,10 +409,12 @@ export class FormattingSectionContent extends PureComponent<
} = this.state;

const {
defaultFormatString: defaultDecimalFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,
defaultFormatString:
defaultDecimalFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,
} = defaultDecimalFormatOptions ?? {};
const {
defaultFormatString: defaultIntegerFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,
defaultFormatString:
defaultIntegerFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,
} = defaultIntegerFormatOptions ?? {};

const isTimeZoneDefault = timeZone === defaults.timeZone;
Expand Down
Loading

0 comments on commit 0326d74

Please sign in to comment.