Skip to content

Commit

Permalink
Enable method-signature-style ESLint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
georgecwan committed Oct 18, 2023
1 parent 876a6ac commit 971ccba
Show file tree
Hide file tree
Showing 29 changed files with 329 additions and 319 deletions.
4 changes: 2 additions & 2 deletions @types/memoizee/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ declare namespace memoizee {
max?: number | undefined;
preFetch?: number | true | undefined;
promise?: boolean | 'then' | 'done' | 'done:finally' | undefined;
dispose?(value: unknown): void;
dispose?: (value: unknown) => void;
async?: boolean | undefined;
primitive?: boolean | undefined;
normalizer?(args: Parameters<F>): string;
normalizer?: (args: Parameters<F>) => string;
resolvers?: Array<(arg: unknown) => unknown> | undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/settings/ShortcutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ShortcutItemProps = {
shortcut: Shortcut;
displayText: string;
categoryName: string;
onChange(shortcut: Shortcut): void;
onChange: (shortcut: Shortcut) => void;
};

export default function ShortcutItem({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function ShortcutSectionContent({
type ShortcutCategoryProps = {
name: string;
shortcuts: Shortcut[];
saveShortcutOverrides(shortcuts: Shortcut[]): void;
saveShortcutOverrides: (shortcuts: Shortcut[]) => void;
};

function ShortcutCategory({
Expand Down
18 changes: 9 additions & 9 deletions packages/console/src/command-history/CommandHistoryStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface CommandHistoryStorageItem extends StorageItem {

export interface CommandHistoryTable
extends StorageTable<CommandHistoryStorageItem> {
setSearch(search: string): void;
setSearch: (search: string) => void;
}

export interface CommandHistoryStorage {
Expand All @@ -32,11 +32,11 @@ export interface CommandHistoryStorage {
* @param scope The scope of this command history, to keep different command histories separate
* @param timestamp The time this command history scope was started
*/
getTable(
getTable: (
language: string,
scope: string,
timestamp: number
): Promise<CommandHistoryTable>;
) => Promise<CommandHistoryTable>;

/**
* Add a command to the command history
Expand All @@ -45,22 +45,22 @@ export interface CommandHistoryStorage {
* @param command The command to add to the history
* @param data The data to save with the command
*/
addItem(
addItem: (
language: string,
scope: string,
command: string,
data: CommandHistoryStorageData
): Promise<CommandHistoryStorageItem>;
) => Promise<CommandHistoryStorageItem>;

/**
* Save a modified CommandHistoryStorageItem
* @param language The language of the item to save
* @param item The modified item to save
*/
updateItem(
updateItem: (
language: string,
item: CommandHistoryStorageItem
): Promise<CommandHistoryStorageItem>;
) => Promise<CommandHistoryStorageItem>;

/**
* Listen to an item with a specific id
Expand All @@ -69,12 +69,12 @@ export interface CommandHistoryStorage {
* @param id The id of the item to listen to
* @param listener Called whenever there is an update on the item
*/
listenItem(
listenItem: (
language: string,
id: string,
listener: StorageItemListener<CommandHistoryStorageItem>,
onError?: StorageErrorListener
): StorageListenerRemover;
) => StorageListenerRemover;
}

export default CommandHistoryStorage;
6 changes: 3 additions & 3 deletions packages/console/src/csv/ZipStreamHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type { JSZipObject, OnUpdateCallback, JSZipStreamHelper } from 'jszip';
*/
interface ZipStreamHelper extends JSZipStreamHelper<string> {
readable: boolean;
read(): void;
removeListener(): void;
read: () => void;
removeListener: () => void;
}

export default function makeZipStreamHelper(
Expand All @@ -20,7 +20,7 @@ export default function makeZipStreamHelper(
// The type could be anything except nodebuffer from https://stuk.github.io/jszip/documentation/api_zipobject/internal_stream.html
// We only need it as a string though
// JSZip types don't include this method for some reason
internalStream(type: 'string'): JSZipStreamHelper<string>;
internalStream: (type: 'string') => JSZipStreamHelper<string>;
}
).internalStream('string') as ZipStreamHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ interface FilterSetManagerProps {
isValueShown: boolean;
selectedId?: string;
filterSets: FilterSet[];
getFilterState(): FilterSetPanel[];
onChange(args: ChangeHandlerArgs): void;
onApply(filterSet: FilterSet): void;
onUpdateSets(filterSets: FilterSet[], editId?: string): void;
getFilterState: () => FilterSetPanel[];
onChange: (args: ChangeHandlerArgs) => void;
onApply: (filterSet: FilterSet) => void;
onUpdateSets: (filterSets: FilterSet[], editId?: string) => void;
}

interface FilterSetManagerState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ it('shows the loading spinner until grid is ready', async () => {
await expectLoading(container);
const params = (
MockIrisGrid.mock.calls[MockIrisGrid.mock.calls.length - 1] as unknown as {
onStateChange(param1: unknown, param2: unknown);
onStateChange: (param1: unknown, param2: unknown) => any;
}[]
)[0];
params.onStateChange({}, {});
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = {
'default-param-last': 'off',
'@typescript-eslint/default-param-last': ['error'],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/method-signature-style': 'error',
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions packages/file-explorer/src/FileExplorerToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { vsNewFile, vsNewFolder } from '@deephaven/icons';
import './FileExplorerToolbar.scss';

type FileExplorerToolbarProps = {
createFile(): void;
createFolder(): void;
onSearchChange?(text: string): void;
createFile: () => void;
createFolder: () => void;
onSearchChange?: (text: string) => void;
defaultSearchText?: string;
};

Expand Down
8 changes: 4 additions & 4 deletions packages/file-explorer/src/FileListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export type FileListRenderItemProps = RenderItemProps<FileStorageItem> & {
isDragInProgress: boolean;
isDropTargetValid: boolean;

onDragStart(index: number, e: React.DragEvent<HTMLDivElement>): void;
onDragOver(index: number, e: React.DragEvent<HTMLDivElement>): void;
onDragEnd(index: number, e: React.DragEvent<HTMLDivElement>): void;
onDrop(index: number, e: React.DragEvent<HTMLDivElement>): void;
onDragStart: (index: number, e: React.DragEvent<HTMLDivElement>) => void;
onDragOver: (index: number, e: React.DragEvent<HTMLDivElement>) => void;
onDragEnd: (index: number, e: React.DragEvent<HTMLDivElement>) => void;
onDrop: (index: number, e: React.DragEvent<HTMLDivElement>) => void;
};

export function FileListItem(props: FileListRenderItemProps): JSX.Element {
Expand Down
22 changes: 11 additions & 11 deletions packages/file-explorer/src/FileStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ export interface File extends FileMetadata {
}

export interface FileStorageTable extends StorageTable<FileStorageItem> {
setSearch(search: string): void;
setSearch: (search: string) => void;

/**
* @param path The path to expand
* @param expanded What expanded state to set
*/
setExpanded(path: string, expanded: boolean): void;
setExpanded: (path: string, expanded: boolean) => void;

/**
* Collapses all directories
*/
collapseAll(): void;
collapseAll: () => void;
}

/**
Expand All @@ -57,53 +57,53 @@ export interface FileStorage {
/**
* Retrieve a table to view the file list
*/
getTable(): Promise<FileStorageTable>;
getTable: () => Promise<FileStorageTable>;

/**
* Save a file
* @param file The file to save
*/
saveFile(file: File): Promise<File>;
saveFile: (file: File) => Promise<File>;

/**
* Load the contents of a file
* @param name The file to load, including the full path
*/
loadFile(name: string): Promise<File>;
loadFile: (name: string) => Promise<File>;

/**
* Delete a file
* @param name The full name of the file to delete
*/
deleteFile(name: string): Promise<void>;
deleteFile: (name: string) => Promise<void>;

/**
* Move a file to a new location
* @param name Source file name
* @param newName The new file name, including path
*/
moveFile(name: string, newName: string): Promise<void>;
moveFile: (name: string, newName: string) => Promise<void>;

/**
* Copy a file to a new location
* @param name The name of the file to copy
* @param newName The new file name, including path
*/
copyFile(name: string, newName: string): Promise<void>;
copyFile: (name: string, newName: string) => Promise<void>;

/**
* Get the info for the file at the specified path.
* If the file does not exists, rejects with a FileNotFoundError
* @param name The file name to check, including path
* @returns The FileStorageItem for the path specified, or reject with a FileNotFoundError if it does not exist.
*/
info(name: string): Promise<FileStorageItem>;
info: (name: string) => Promise<FileStorageItem>;

/**
* Create the directory at the given path
* @param name The full directory path
*/
createDirectory(name: string): Promise<FileStorageItem>;
createDirectory: (name: string) => Promise<FileStorageItem>;
}

export default FileStorage;
2 changes: 1 addition & 1 deletion packages/grid/src/ColumnHeaderGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface IColumnHeaderGroup {
name: string;
depth: number;
color?: string;
getVisibleRange(movedColumns: readonly MoveOperation[]): BoundedAxisRange;
getVisibleRange: (movedColumns: readonly MoveOperation[]) => BoundedAxisRange;
}
4 changes: 2 additions & 2 deletions packages/grid/src/DataBarGridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export function isDataBarGridModel(
}

export interface DataBarGridModel extends GridModel {
dataBarOptionsForCell(
dataBarOptionsForCell: (
column: ModelIndex,
row: ModelIndex,
theme: GridThemeType
): DataBarOptions;
) => DataBarOptions;
}
21 changes: 14 additions & 7 deletions packages/grid/src/EditableGridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export interface EditableGridModel extends GridModel {
* @param range The range to check if it is editable
* @returns True if the range is editable
*/
isEditableRange(range: GridRange): boolean;
isEditableRange: (range: GridRange) => boolean;

/**
* Get the edit text for a cell as a string
* @param column Column to get
* @param row Row to get
* @returns The value to use for editing
*/
editValueForCell(column: ModelIndex, row: ModelIndex): string;
editValueForCell: (column: ModelIndex, row: ModelIndex) => string;

/**
* Set value in an editable table
Expand All @@ -66,26 +66,29 @@ export interface EditableGridModel extends GridModel {
* @param value The value to set
* @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
*/
setValueForCell(
setValueForCell: (
column: ModelIndex,
row: ModelIndex,
value: string
): Promise<void>;
) => Promise<void>;

/**
* Set value in an editable table
* @param ranges The ranges to set
* @param value The value to set
* @returns A promise that resolves successfully when the operation is complete, or rejects if there's an error
*/
setValueForRanges(ranges: readonly GridRange[], value: string): Promise<void>;
setValueForRanges: (
ranges: readonly GridRange[],
value: string
) => Promise<void>;

/**
* Apply edits to the model
* @param edits Edits to apply to the model
* @returns A promise that resolves successfully when the operation is complete or rejects if there's an error
*/
setValues(edits: readonly EditOperation[]): Promise<void>;
setValues: (edits: readonly EditOperation[]) => Promise<void>;

/**
* Check if a text value is a valid edit for a cell
Expand All @@ -94,7 +97,11 @@ export interface EditableGridModel extends GridModel {
* @param value Value to check if it's a valid value or not
* @returns True if it's a valid value, false otherwise
*/
isValidForCell(column: ModelIndex, row: ModelIndex, value: string): boolean;
isValidForCell: (
column: ModelIndex,
row: ModelIndex,
value: string
) => boolean;
}

export default EditableGridModel;
14 changes: 7 additions & 7 deletions packages/grid/src/ExpandableGridModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@ export interface ExpandableGridModel extends GridModel {
* @param row Row to check
* @returns True if the row is expandable
*/
isRowExpandable(row: ModelIndex): boolean;
isRowExpandable: (row: ModelIndex) => boolean;

/**
* @param row Row to check
* @returns True if the row is currently expanded
*/
isRowExpanded(row: ModelIndex): boolean;
isRowExpanded: (row: ModelIndex) => boolean;

/**
* Change the expanded status of an expandable row
* @param row Row to expand
* @param isExpanded True to expand the row, false to collapse
* @param expandDescendants True to expand nested rows, false otherwise
*/
setRowExpanded(
setRowExpanded: (
row: ModelIndex,
isExpanded: boolean,
expandDescendants?: boolean
): void;
) => void;

/**
* Expand all rows
*/
expandAll(): void;
expandAll: () => void;

/**
* Collapse all rows
*/
collapseAll(): void;
collapseAll: () => void;

/**
* Get the depth of a row (ie. How indented the row should be)
* @param row Row to check
* @returns Depth of the row
*/
depthForRow(row: ModelIndex): number;
depthForRow: (row: ModelIndex) => number;
}

export default ExpandableGridModel;
Loading

0 comments on commit 971ccba

Please sign in to comment.