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

style: Enable method-signature-style TypeScript ESLint rule #1584

Merged
merged 8 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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
10 changes: 5 additions & 5 deletions packages/code-studio/src/main/AppControlsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function DragSourceMenuItem(props: DragSourceMenuItemProps): JSX.Element {
}

interface AppControlsMenuProps {
handleControlSelect: (type: string, event?: KeyboardEvent) => void;
handleControlSelect: (type: string, event: Event) => void;
handleToolSelect: (type: string) => void;
onClearFilter: () => void;
}
Expand All @@ -151,7 +151,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement {
title: 'Input Filter',
icon: dhInput,
menuElement: <DragSourceMenuItem />,
action: (dragEvent?: KeyboardEvent) => {
action: (dragEvent: Event) => {
handleControlSelect(ControlType.INPUT_FILTER, dragEvent);
},
order: 10,
Expand All @@ -160,7 +160,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement {
title: 'Dropdown Filter',
icon: dhTriangleDownSquare,
menuElement: <DragSourceMenuItem />,
action: (dragEvent?: KeyboardEvent) => {
action: (dragEvent: Event) => {
handleControlSelect(ControlType.DROPDOWN_FILTER, dragEvent);
},
order: 15,
Expand All @@ -169,7 +169,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement {
title: 'Markdown Widget',
icon: vsMarkdown,
menuElement: <DragSourceMenuItem />,
action: (dragEvent?: KeyboardEvent) => {
action: (dragEvent: Event) => {
handleControlSelect(ControlType.MARKDOWN, dragEvent);
},
order: 20,
Expand All @@ -178,7 +178,7 @@ function AppControlsMenu(props: AppControlsMenuProps): ReactElement {
title: 'Filter Sets',
icon: vsDeviceCamera,
menuElement: <DragSourceMenuItem />,
action: (dragEvent?: KeyboardEvent) => {
action: (dragEvent: Event) => {
handleControlSelect(ControlType.FILTER_SET_MANAGER, dragEvent);
},
order: 25,
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export class AppMainContainer extends Component<
this.setState({ isSettingsMenuShown: true });
}

handleControlSelect(type: string, dragEvent?: KeyboardEvent): void {
handleControlSelect(type: string, dragEvent: Event): void {
log.debug('handleControlSelect', type);

switch (type) {
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
4 changes: 1 addition & 3 deletions packages/code-studio/src/styleguide/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class Dialog extends Component<unknown, DialogState> {
};
}

handleUpdateCheckboxMap(
checkBoxMap: Map<string, Map<string, boolean>>
): void {
handleUpdateCheckboxMap(checkBoxMap: HierarchicalCheckboxValueMap): void {
this.setState({
checkBoxMap,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/code-studio/src/styleguide/DraggableListInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface DraggableListInputProps {
isDropDisabled: boolean;
isMultiSelect: boolean;
items: Array<unknown>;
onSelectionChange: (listSelectedRanges: Range[]) => void;
onSelectionChange: (listSelectedRanges: readonly Range[]) => void;
selectedRanges: Range[];
}
interface DraggableListInputState {
Expand Down Expand Up @@ -73,7 +73,7 @@ class DraggableListInput extends PureComponent<
}
}

handleSelectionChange(selectedRanges: Array<Range>): void {
handleSelectionChange(selectedRanges: readonly Range[]): void {
console.log('Selection changed', selectedRanges);

const { onSelectionChange } = this.props;
Expand Down
7 changes: 5 additions & 2 deletions packages/code-studio/src/styleguide/DraggableLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,13 @@ class DraggableLists extends Component<
);
}

handleSelectionChange(listIndex: number, listSelectedRanges: Range[]): void {
handleSelectionChange(
listIndex: number,
listSelectedRanges: readonly Range[]
): void {
this.setState(({ selectedRanges }) => {
const newSelectedRanges = [...selectedRanges];
newSelectedRanges[listIndex] = listSelectedRanges;
newSelectedRanges[listIndex] = [...listSelectedRanges];
return { selectedRanges: newSelectedRanges };
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/code-studio/src/styleguide/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ function Inputs(): React.ReactElement {
onChange={setCustomTimeValue}
customText="Custom Timeout"
placeholder="Select a timeout"
valueToTime={(value: number) => Math.round(value / 1000)}
timeToValue={time => time * 1000}
/>
</div>
Expand Down
7 changes: 5 additions & 2 deletions packages/code-studio/src/styleguide/MockIrisGridTreeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MockIrisGridTreeModel
return this.isEditable;
}

setValues(edits: EditOperation[]): never {
setValues(edits: readonly EditOperation[]): never {
throw new Error('Method not implemented.');
}

Expand Down Expand Up @@ -259,7 +259,10 @@ class MockIrisGridTreeModel
);
}

async setValueForRanges(ranges: GridRange[], text: string): Promise<void> {
async setValueForRanges(
ranges: readonly GridRange[],
text: string
): Promise<void> {
GridRange.forEachCell(ranges, (x, y) => {
this.setValueForCell(x, y, text);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/AutoCompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ interface AutoCompleteOption {
interface AutoCompleteInputProps {
options: AutoCompleteOption[];
popperOptions: PopperOptions;
onChange(value: string, isValid: boolean): void;
onChange: (value: string, isValid: boolean) => void;
inputPlaceholder: string;
disabled: boolean;
className: string;
defaultTitle: string;
spellCheck: boolean;
onEnter(): void;
onEnter: () => void;
noMatchText: string;
'data-testid'?: string;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ interface ComboBoxOption {
interface ComboBoxProps {
options: ComboBoxOption[];
popperOptions: PopperOptions;
onChange(value: string): void;
onChange: (value: string) => void;
inputPlaceholder: string;
searchPlaceholder: string;
disabled: boolean;
className: string;
defaultValue: string;
spellCheck: boolean;
onEnter(): void;
onEnter: () => void;
'data-testid'?: string;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/CustomTimeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ type CustomTimeSelectProps = {
options: { title: string; value: number }[];
popperOptions: PopperOptions;
value: number | null;
onChange(value: number): void;
onChange: (value: number) => void;
disabled: boolean;
icon: IconDefinition;
placeholder: string;
customText: string;
// Defaults to converting the value in milliseconds to time in seconds
valueToTime(val: number | null): number;
valueToTime: (val: number | null) => number;
// Defaults to converting the time in seconds to value in milliseconds
timeToValue(time: number): number;
timeToValue: (time: number) => number;
invalid: boolean;
'data-testid'?: string;
};
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const DATE_FORMAT = 'YYYY-MM-DD';

type DateInputProps = {
className?: string;
onChange?(date?: string): void;
onChange?: (date?: string) => void;
defaultValue?: string;
onFocus?(): void;
onBlur?(): void;
onFocus?: () => void;
onBlur?: () => void;
'data-testid'?: string;
};

Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/DateTimeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const FULL_DATE_FORMAT = 'YYYY-MM-DD HH:MM:SS.SSSSSSSSS';

type DateTimeInputProps = {
className?: string;
onChange?(value?: string): void;
onChange?: (value?: string) => void;
defaultValue?: string;
onFocus?(): void;
onBlur?(): void;
onSubmit?(event?: KeyboardEvent<HTMLInputElement>): void;
onFocus?: () => void;
onBlur?: () => void;
onSubmit?: (event: KeyboardEvent<HTMLInputElement>) => void;
'data-testid'?: string;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/DebouncedSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SearchInput from './SearchInput';
interface DebouncedSearchInputProps {
value: string;
placeholder: string;
onChange(value: string): void;
onChange: (value: string) => void;
className: string;
matchCount: number;
debounceMs: number;
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/DragUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DragUtils {
*/
static reorder<T>(
sourceList: T[],
selectedRanges: Range[],
selectedRanges: readonly Range[],
destinationList: T[],
destinationIndex: number
): T[] {
Expand All @@ -32,7 +32,7 @@ class DragUtils {
* @param ranges Array of the ranges to remove.
* @returns The removed items, in the order of the ranges removed.
*/
static removeItems<T>(list: T[], ranges: Range[]): T[] {
static removeItems<T>(list: T[], ranges: readonly Range[]): T[] {
const items = [];

// Sort them in reverse, so we don't screw up the range indexes
Expand All @@ -56,7 +56,7 @@ class DragUtils {
*/
static adjustDestinationIndex(
destinationIndex: number,
ranges: Range[]
ranges: readonly Range[]
): number {
let adjustedIndex = destinationIndex;
for (let i = 0; i < ranges.length; i += 1) {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/DraggableItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class DraggableItemList<T> extends PureComponent<
{ max: ItemList.CACHE_SIZE }
);

handleSelectionChange(selectedRanges: Range[]): void {
handleSelectionChange(selectedRanges: readonly Range[]): void {
this.setState({ selectedCount: RangeUtils.count(selectedRanges) });

const { onSelectionChange } = this.props;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/EditableItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function EditableItemList(props: EditableItemListProps): React.ReactElement {
validate = () => null,
} = props;
const [inputError, setInputError] = useState<Error | null>(null);
const [selectedRanges, setSelectedRanges] = useState<Range[]>([]);
const [selectedRanges, setSelectedRanges] = useState<readonly Range[]>([]);
const [value, setValue] = useState('');

const handleSelectionChange = useCallback((ranges: Range[]) => {
const handleSelectionChange = useCallback((ranges: readonly Range[]) => {
setSelectedRanges(ranges);
}, []);

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/HierarchicalCheckboxMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HierarchicalCheckboxMenuProps = {
className: string;
menuText: string;
valueMap: HierarchicalCheckboxValueMap;
onUpdateValueMap(map: HierarchicalCheckboxValueMap): void;
onUpdateValueMap: (map: HierarchicalCheckboxValueMap) => void;
icon: IconDefinition | null;
id: string;
'data-testid'?: string;
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/ItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export type ItemListProps<T> = {
// Set to true if you want the list to scroll when new items are added and it's already at the bottom
isStickyBottom: boolean;
// Fired when an item gets focused
onFocusChange(index: number | null): void;
onFocusChange: (index: number | null) => void;

// Fired when an item is clicked. With multiple selection, fired on double click.
onSelect(index: number, event: React.SyntheticEvent): void;
onSelectionChange(ranges: readonly Range[]): void;
onViewportChange(topRow: number, bottomRow: number): void;
onSelect: (index: number, event: React.SyntheticEvent) => void;
onSelectionChange: (ranges: readonly Range[]) => void;
onViewportChange: (topRow: number, bottomRow: number) => void;
overscanCount: number;
selectedRanges: readonly Range[];
disableSelect: boolean;
Expand Down
26 changes: 13 additions & 13 deletions packages/components/src/ItemListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ interface ItemListItemProps {
itemIndex: number;
// eslint-disable-next-line react/no-unused-prop-types
disableSelect: boolean;
onBlur(index: number, e: React.FocusEvent<HTMLDivElement>): void;
onClick(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onContextMenu(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onDragStart(index: number, e: React.DragEvent<HTMLDivElement>): void;
onDrag(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;
onDoubleClick(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onFocus(index: number, e: React.FocusEvent<HTMLDivElement>): void;
onMouseDown(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onMouseMove(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onMouseUp(index: number, e: React.MouseEvent<HTMLDivElement>): void;
onBlur: (index: number, e: React.FocusEvent<HTMLDivElement>) => void;
onClick: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
onContextMenu: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
onDragStart: (index: number, e: React.DragEvent<HTMLDivElement>) => void;
onDrag: (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;
onDoubleClick: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
onFocus: (index: number, e: React.FocusEvent<HTMLDivElement>) => void;
onMouseDown: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
onMouseMove: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
onMouseUp: (index: number, e: React.MouseEvent<HTMLDivElement>) => void;
style: React.CSSProperties;
children: React.ReactNode;
'data-testid'?: string;
Expand Down
14 changes: 7 additions & 7 deletions packages/components/src/MaskedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ type MaskedInputProps = {
/** The current selection to use for the input */
selection?: SelectionSegment;
/** Called when the value changes. Note the value may still be incomplete. */
onChange?(value: string): void;
onChange?: (value: string) => void;
/** Called when selection changes */
onSelect?(segment: SelectionSegment): void;
onSelect?: (segment: SelectionSegment) => void;
/** Called when enter is pressed */
onSubmit?(event?: KeyboardEvent<HTMLInputElement>): void;
onSubmit?: (event: KeyboardEvent<HTMLInputElement>) => void;
/** Retrieve the next value for a provided segment */
getNextSegmentValue?(
getNextSegmentValue?: (
segment: SelectionSegment,
delta: number,
segmentValue: string,
value: string
): string;
getPreferredReplacementString?(
) => string;
getPreferredReplacementString?: (
value: string,
replaceIndex: number,
replaceChar: string,
selectionStart: number,
selectionEnd: number
): string;
) => string;
onFocus?: React.FocusEventHandler;
onBlur?: React.FocusEventHandler;

Expand Down
Loading
Loading