chore(react): migrate to eslint, add prettier (#26633)

This commit is contained in:
Liam DeBeasi
2023-01-18 16:49:25 -05:00
committed by GitHub
parent 2dca54a457
commit b02190d71f
70 changed files with 4508 additions and 1002 deletions

View File

@ -1,9 +1,9 @@
import { AnimationBuilder } from '@ionic/core/components';
import type { AnimationBuilder } from '@ionic/core/components';
import React, { createElement } from 'react';
import { NavContext } from '../contexts/NavContext';
import { RouterOptions } from '../models';
import { RouterDirection } from '../models/RouterDirection';
import type { RouterOptions } from '../models';
import type { RouterDirection } from '../models/RouterDirection';
import {
attachProps,
@ -27,24 +27,21 @@ interface IonicReactInternalProps<ElementType> extends React.HTMLAttributes<Elem
routerAnimation?: AnimationBuilder;
}
export const createRoutingComponent = <PropType, ElementType>(
tagName: string,
customElement?: any
) => {
export const createRoutingComponent = <PropType, ElementType>(tagName: string, customElement?: any) => {
defineCustomElement(tagName, customElement);
const displayName = dashToPascalCase(tagName);
const ReactComponent = class extends React.Component<IonicReactInternalProps<PropType>> {
context!: React.ContextType<typeof NavContext>;
ref: React.RefObject<HTMLElement>;
stableMergedRefs: React.RefCallback<HTMLElement>
stableMergedRefs: React.RefCallback<HTMLElement>;
constructor(props: IonicReactInternalProps<PropType>) {
super(props);
// Create a local ref to to attach props to the wrapped element.
this.ref = React.createRef();
// React refs must be stable (not created inline).
this.stableMergedRefs = mergeRefs(this.ref, this.props.forwardedRef)
this.stableMergedRefs = mergeRefs(this.ref, this.props.forwardedRef);
}
componentDidMount() {
@ -60,17 +57,12 @@ export const createRoutingComponent = <PropType, ElementType>(
const { routerLink, routerDirection, routerOptions, routerAnimation } = this.props;
if (routerLink !== undefined) {
e.preventDefault();
this.context.navigate(
routerLink,
routerDirection,
undefined,
routerAnimation,
routerOptions
);
this.context.navigate(routerLink, routerDirection, undefined, routerAnimation, routerOptions);
}
};
render() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
const propsToPass = Object.keys(cProps).reduce((acc, name) => {