chore(react-router): migrate to eslint, add prettier (#26634)

This commit is contained in:
Liam DeBeasi
2023-01-18 17:22:16 -05:00
committed by GitHub
parent b02190d71f
commit 6d4c52aa5b
12 changed files with 4701 additions and 600 deletions

View File

@ -1,11 +1,8 @@
import {
Action as HistoryAction,
History,
Location as HistoryLocation,
createBrowserHistory as createHistory,
} from 'history';
import type { Action as HistoryAction, History, Location as HistoryLocation } from 'history';
import { createBrowserHistory as createHistory } from 'history';
import React from 'react';
import { BrowserRouterProps, Router } from 'react-router-dom';
import type { BrowserRouterProps } from 'react-router-dom';
import { Router } from 'react-router-dom';
import { IonRouter } from './IonRouter';
@ -25,21 +22,21 @@ export class IonReactRouter extends React.Component<IonReactRouterProps> {
this.registerHistoryListener = this.registerHistoryListener.bind(this);
}
/**
* history@4.x passes separate location and action
* params. history@5.x passes location and action
* together as a single object.
* TODO: If support for React Router <=5 is dropped
* this logic is no longer needed. We can just assume
* a single object with both location and action.
*/
/**
* history@4.x passes separate location and action
* params. history@5.x passes location and action
* together as a single object.
* TODO: If support for React Router <=5 is dropped
* this logic is no longer needed. We can just assume
* a single object with both location and action.
*/
handleHistoryChange(location: HistoryLocation, action: HistoryAction) {
const locationValue = (location as any).location || location;
const actionValue = (location as any).action || action;
if (this.historyListenHandler) {
this.historyListenHandler(locationValue, actionValue);
}
}
const locationValue = (location as any).location || location;
const actionValue = (location as any).action || action;
if (this.historyListenHandler) {
this.historyListenHandler(locationValue, actionValue);
}
}
registerHistoryListener(cb: (location: HistoryLocation, action: HistoryAction) => void) {
this.historyListenHandler = cb;