Fix some unbound-method ESLint errors (#1576)

* Fix some unbound-method ESLint errors

* Keep that one
This commit is contained in:
Nathan Bierema 2023-12-17 22:03:02 -05:00 committed by GitHub
parent e9afa8fb27
commit b79b2c3bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 31 additions and 38 deletions

View File

@ -9,7 +9,6 @@ import InstanceSelector from './InstanceSelector';
import SyncButton from './buttons/SyncButton'; import SyncButton from './buttons/SyncButton';
import { Options, State } from '../reducers/instances'; import { Options, State } from '../reducers/instances';
// eslint-disable-next-line @typescript-eslint/unbound-method
const { reset, rollback, commit, sweep } = ActionCreators; const { reset, rollback, commit, sweep } = ActionCreators;
interface Props { interface Props {

View File

@ -27,6 +27,7 @@ class DevTools extends Component<Props> {
LiftedState<unknown, Action<string>, unknown> LiftedState<unknown, Action<string>, unknown>
> & { > & {
update( update(
this: void,
monitorProps: unknown, monitorProps: unknown,
state: unknown | undefined, state: unknown | undefined,
action: Action<string>, action: Action<string>,
@ -44,7 +45,6 @@ class DevTools extends Component<Props> {
this.monitorProps = monitorElement.props; this.monitorProps = monitorElement.props;
this.Monitor = monitorElement.type; this.Monitor = monitorElement.type;
// eslint-disable-next-line @typescript-eslint/unbound-method
const update = this.Monitor!.update; const update = this.Monitor!.update;
if (update) { if (update) {
let newMonitorState; let newMonitorState;

View File

@ -11,7 +11,7 @@ import type { Options } from 'd3-state-visualizer';
import reducer, { ChartMonitorState } from './reducers'; import reducer, { ChartMonitorState } from './reducers';
import Chart, { Props } from './Chart'; import Chart, { Props } from './Chart';
// eslint-disable-next-line @typescript-eslint/unbound-method
const { reset, rollback, commit, sweep, toggleAction } = ActionCreators; const { reset, rollback, commit, sweep, toggleAction } = ActionCreators;
const styles: { container: CSSProperties } = { const styles: { container: CSSProperties } = {

View File

@ -25,17 +25,11 @@ import {
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
const { const {
// eslint-disable-next-line @typescript-eslint/unbound-method
commit, commit,
// eslint-disable-next-line @typescript-eslint/unbound-method
sweep, sweep,
// eslint-disable-next-line @typescript-eslint/unbound-method
toggleAction, toggleAction,
// eslint-disable-next-line @typescript-eslint/unbound-method
jumpToAction, jumpToAction,
// eslint-disable-next-line @typescript-eslint/unbound-method
jumpToState, jumpToState,
// eslint-disable-next-line @typescript-eslint/unbound-method
reorderAction, reorderAction,
} = ActionCreators; } = ActionCreators;

View File

@ -133,6 +133,7 @@ export type LiftedAction<S, A extends Action<string>, MonitorState> =
*/ */
export const ActionCreators = { export const ActionCreators = {
performAction<A extends Action<string>>( performAction<A extends Action<string>>(
this: void,
action: A, action: A,
trace?: ((action: A) => string | undefined) | boolean, trace?: ((action: A) => string | undefined) | boolean,
traceLimit?: number, traceLimit?: number,
@ -203,27 +204,28 @@ export const ActionCreators = {
}; };
}, },
reset(): ResetAction { reset(this: void): ResetAction {
return { type: ActionTypes.RESET, timestamp: Date.now() }; return { type: ActionTypes.RESET, timestamp: Date.now() };
}, },
rollback(): RollbackAction { rollback(this: void): RollbackAction {
return { type: ActionTypes.ROLLBACK, timestamp: Date.now() }; return { type: ActionTypes.ROLLBACK, timestamp: Date.now() };
}, },
commit(): CommitAction { commit(this: void): CommitAction {
return { type: ActionTypes.COMMIT, timestamp: Date.now() }; return { type: ActionTypes.COMMIT, timestamp: Date.now() };
}, },
sweep(): SweepAction { sweep(this: void): SweepAction {
return { type: ActionTypes.SWEEP }; return { type: ActionTypes.SWEEP };
}, },
toggleAction(id: number): ToggleAction { toggleAction(this: void, id: number): ToggleAction {
return { type: ActionTypes.TOGGLE_ACTION, id }; return { type: ActionTypes.TOGGLE_ACTION, id };
}, },
setActionsActive( setActionsActive(
this: void,
start: number, start: number,
end: number, end: number,
active = true, active = true,
@ -231,30 +233,35 @@ export const ActionCreators = {
return { type: ActionTypes.SET_ACTIONS_ACTIVE, start, end, active }; return { type: ActionTypes.SET_ACTIONS_ACTIVE, start, end, active };
}, },
reorderAction(actionId: number, beforeActionId: number): ReorderAction { reorderAction(
this: void,
actionId: number,
beforeActionId: number,
): ReorderAction {
return { type: ActionTypes.REORDER_ACTION, actionId, beforeActionId }; return { type: ActionTypes.REORDER_ACTION, actionId, beforeActionId };
}, },
jumpToState(index: number): JumpToStateAction { jumpToState(this: void, index: number): JumpToStateAction {
return { type: ActionTypes.JUMP_TO_STATE, index }; return { type: ActionTypes.JUMP_TO_STATE, index };
}, },
jumpToAction(actionId: number): JumpToActionAction { jumpToAction(this: void, actionId: number): JumpToActionAction {
return { type: ActionTypes.JUMP_TO_ACTION, actionId }; return { type: ActionTypes.JUMP_TO_ACTION, actionId };
}, },
importState<S, A extends Action<string>, MonitorState = null>( importState<S, A extends Action<string>, MonitorState = null>(
this: void,
nextLiftedState: LiftedState<S, A, MonitorState> | readonly A[], nextLiftedState: LiftedState<S, A, MonitorState> | readonly A[],
noRecompute?: boolean, noRecompute?: boolean,
): ImportStateAction<S, A, MonitorState> { ): ImportStateAction<S, A, MonitorState> {
return { type: ActionTypes.IMPORT_STATE, nextLiftedState, noRecompute }; return { type: ActionTypes.IMPORT_STATE, nextLiftedState, noRecompute };
}, },
lockChanges(status: boolean): LockChangesAction { lockChanges(this: void, status: boolean): LockChangesAction {
return { type: ActionTypes.LOCK_CHANGES, status }; return { type: ActionTypes.LOCK_CHANGES, status };
}, },
pauseRecording(status: boolean): PauseRecordingAction { pauseRecording(this: void, status: boolean): PauseRecordingAction {
return { type: ActionTypes.PAUSE_RECORDING, status }; return { type: ActionTypes.PAUSE_RECORDING, status };
}, },
}; };

View File

@ -17,7 +17,6 @@ import reducer, { LogMonitorState } from './reducers';
import LogMonitorButtonBar from './LogMonitorButtonBar'; import LogMonitorButtonBar from './LogMonitorButtonBar';
import LogMonitorEntryList from './LogMonitorEntryList'; import LogMonitorEntryList from './LogMonitorEntryList';
// eslint-disable-next-line @typescript-eslint/unbound-method
const { toggleAction, setActionsActive } = ActionCreators; const { toggleAction, setActionsActive } = ActionCreators;
const styles: { const styles: {

View File

@ -6,7 +6,6 @@ import LogMonitorButton from './LogMonitorButton';
import { LogMonitorAction } from './actions'; import { LogMonitorAction } from './actions';
import { LogMonitorState } from './reducers'; import { LogMonitorState } from './reducers';
// eslint-disable-next-line @typescript-eslint/unbound-method
const { reset, rollback, commit, sweep } = ActionCreators; const { reset, rollback, commit, sweep } = ActionCreators;
const style: CSSProperties = { const style: CSSProperties = {

View File

@ -73,10 +73,10 @@ export type TodoAction =
| ClearMarkedAction; | ClearMarkedAction;
export interface TodoActions { export interface TodoActions {
addTodo(text: string): AddTodoAction; addTodo(this: void, text: string): AddTodoAction;
deleteTodo(id: number): DeleteTodoAction; deleteTodo(this: void, id: number): DeleteTodoAction;
editTodo(id: number, text: string): EditTodoAction; editTodo(this: void, id: number, text: string): EditTodoAction;
markTodo(id: number): MarkTodoAction; markTodo(this: void, id: number): MarkTodoAction;
markAll(): MarkAllAction; markAll(this: void): MarkAllAction;
clearMarked(): ClearMarkedAction; clearMarked(this: void): ClearMarkedAction;
} }

View File

@ -70,7 +70,6 @@ export default class MainSection extends Component<Props, State> {
className="toggle-all" className="toggle-all"
type="checkbox" type="checkbox"
checked={markedCount === todos.length} checked={markedCount === todos.length}
// eslint-disable-next-line @typescript-eslint/unbound-method
onChange={actions.markAll} onChange={actions.markAll}
/> />
); );

View File

@ -18,7 +18,6 @@ interface Props {
const TodoApp: FunctionComponent<Props> = ({ todos, actions }) => ( const TodoApp: FunctionComponent<Props> = ({ todos, actions }) => (
<div> <div>
{/* eslint-disable-next-line @typescript-eslint/unbound-method */}
<Header addTodo={actions.addTodo} /> <Header addTodo={actions.addTodo} />
<MainSection todos={todos} actions={actions} /> <MainSection todos={todos} actions={actions} />
</div> </div>

View File

@ -18,7 +18,6 @@ import {
import reducer from './reducers'; import reducer from './reducers';
import SliderButton from './SliderButton'; import SliderButton from './SliderButton';
// eslint-disable-next-line @typescript-eslint/unbound-method
const { reset, jumpToAction } = ActionCreators; const { reset, jumpToAction } = ActionCreators;
interface ExternalProps<S, A extends Action<string>> { interface ExternalProps<S, A extends Action<string>> {

View File

@ -73,10 +73,10 @@ export type TodoAction =
| ClearMarkedAction; | ClearMarkedAction;
export interface TodoActions { export interface TodoActions {
addTodo(text: string): AddTodoAction; addTodo(this: void, text: string): AddTodoAction;
deleteTodo(id: number): DeleteTodoAction; deleteTodo(this: void, id: number): DeleteTodoAction;
editTodo(id: number, text: string): EditTodoAction; editTodo(this: void, id: number, text: string): EditTodoAction;
markTodo(id: number): MarkTodoAction; markTodo(this: void, id: number): MarkTodoAction;
markAll(): MarkAllAction; markAll(this: void): MarkAllAction;
clearMarked(): ClearMarkedAction; clearMarked(this: void): ClearMarkedAction;
} }

View File

@ -77,7 +77,6 @@ export default class MainSection extends Component<Props, State> {
className="toggle-all" className="toggle-all"
type="checkbox" type="checkbox"
checked={markedCount === todos.length} checked={markedCount === todos.length}
// eslint-disable-next-line @typescript-eslint/unbound-method
onChange={actions.markAll} onChange={actions.markAll}
/> />
<label htmlFor={this.htmlFormInputId}>Mark all as complete</label> <label htmlFor={this.htmlFormInputId}>Mark all as complete</label>

View File

@ -22,7 +22,6 @@ class TodoApp extends Component<Props> {
return ( return (
<div> <div>
{/* eslint-disable-next-line @typescript-eslint/unbound-method */}
<Header addTodo={actions.addTodo} /> <Header addTodo={actions.addTodo} />
<MainSection todos={todos} actions={actions} /> <MainSection todos={todos} actions={actions} />
</div> </div>