Skip to content

Commit

Permalink
Fixing more eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Sep 5, 2023
1 parent 25833ba commit 020bbda
Show file tree
Hide file tree
Showing 22 changed files with 1,053 additions and 305 deletions.
42 changes: 37 additions & 5 deletions packages/inferno-clone-vnode/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { createComponentVNode, createFragment, createTextVNode, createVNode, EMPTY_OBJ, normalizeProps, VNode } from 'inferno';
import {
createComponentVNode,
createFragment,
createTextVNode,
createVNode,
EMPTY_OBJ,
normalizeProps,
type VNode,
} from 'inferno';
import { ChildFlags, VNodeFlags } from 'inferno-vnode-flags';

/*
Expand All @@ -16,7 +24,10 @@ import { ChildFlags, VNodeFlags } from 'inferno-vnode-flags';
*/
export function cloneVNode(vNodeToClone: VNode, props?, _children?): VNode {
const flags = vNodeToClone.flags;
let children = flags & VNodeFlags.Component ? vNodeToClone.props && vNodeToClone.props.children : vNodeToClone.children;
let children =
flags & VNodeFlags.Component
? vNodeToClone.props?.children
: vNodeToClone.children;
let childLen = arguments.length - 2;
let className = vNodeToClone.className;
let key = vNodeToClone.key;
Expand Down Expand Up @@ -51,18 +62,39 @@ export function cloneVNode(vNodeToClone: VNode, props?, _children?): VNode {
props.children = children;

if (flags & VNodeFlags.Component) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : {...vNodeToClone.props, ...props}, key, ref);
return createComponentVNode(
flags,
vNodeToClone.type,
!vNodeToClone.props && !props
? EMPTY_OBJ
: { ...vNodeToClone.props, ...props },
key,
ref,
);
}

if (flags & VNodeFlags.Text) {
return createTextVNode(children);
}

if (flags & VNodeFlags.Fragment) {
return createFragment(childLen === 1 ? [children] : children, ChildFlags.UnknownChildren, key);
return createFragment(
childLen === 1 ? [children] : children,
ChildFlags.UnknownChildren,
key,
);
}

return normalizeProps(
createVNode(flags, vNodeToClone.type, className, null, ChildFlags.HasInvalidChildren, {...vNodeToClone.props, ...props}, key, ref)
createVNode(
flags,
vNodeToClone.type,
className,
null,
ChildFlags.HasInvalidChildren,
{ ...vNodeToClone.props, ...props },
key,
ref,
),
);
}
10 changes: 6 additions & 4 deletions packages/inferno-compat/src/InfernoCompatPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@ const ATTRS = [
'xml:base',
'xmlns:xlink',
'xml:lang',
'xml:space'
'xml:space',
];

export const InfernoCompatPropertyMap = {
htmlFor: 'for',
onDoubleClick: 'onDblClick'
onDoubleClick: 'onDblClick',
};

const CAMELIZE = /[\-:]([a-z])/g;
const capitalize = (token) => token[1].toUpperCase();
const CAMELIZE = /[-:]([a-z])/g;
function capitalize(token: string): string {
return token[1].toUpperCase();
}

ATTRS.forEach((original) => {
const reactName = original.replace(CAMELIZE, capitalize);
Expand Down
9 changes: 6 additions & 3 deletions packages/inferno-compat/src/PropTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
* Inlined PropTypes, there is propType checking ATM.
*/

// tslint:disable-next-line:no-empty
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
function proptype() {}
(proptype as any).isRequired = proptype;

const getProptype = () => proptype;
// eslint-disable-next-line @typescript-eslint/ban-types
function getProptype(): Function {
return proptype;
}

const PropTypes = {
any: getProptype,
Expand All @@ -28,7 +31,7 @@ const PropTypes = {
oneOfType: getProptype,
shape: getProptype,
string: proptype,
symbol: proptype
symbol: proptype,
};

export default PropTypes;
Loading

0 comments on commit 020bbda

Please sign in to comment.