chore: eslint cleanup (#10160)

This commit is contained in:
farfromrefuge
2023-01-09 17:40:20 +00:00
committed by GitHub
parent bff35e5163
commit 0632215793
18 changed files with 97 additions and 71 deletions

View File

@ -24,7 +24,22 @@
{ {
"files": ["*.ts", "*.tsx"], "files": ["*.ts", "*.tsx"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nrwl/nx/typescript"], "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nrwl/nx/typescript"],
"rules": {} "rules": {
"no-empty": "off",
"no-useless-escape": "off",
"no-inner-declarations": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-inferrable-types": "off"
}
}, },
{ {
"files": ["*.js", "*.jsx"], "files": ["*.js", "*.jsx"],

View File

@ -38,7 +38,7 @@ export namespace CoreTypes {
}; };
export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer'; export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer';
export module KeyboardType { export namespace KeyboardType {
export const datetime = 'datetime'; export const datetime = 'datetime';
export const phone = 'phone'; export const phone = 'phone';
export const number = 'number'; export const number = 'number';
@ -47,7 +47,7 @@ export namespace CoreTypes {
export const integer = 'integer'; export const integer = 'integer';
} }
export type AutofillType = 'username' | 'password' | 'none' | string; export type AutofillType = 'username' | 'password' | 'none' | string;
export module AutofillType { export namespace AutofillType {
export const username = 'username'; export const username = 'username';
export const password = 'password'; export const password = 'password';
export const newUsername = 'newUsername'; export const newUsername = 'newUsername';
@ -57,7 +57,7 @@ export namespace CoreTypes {
} }
export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send'; export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send';
export module ReturnKeyType { export namespace ReturnKeyType {
export const done = 'done'; export const done = 'done';
export const next = 'next'; export const next = 'next';
export const go = 'go'; export const go = 'go';
@ -66,7 +66,7 @@ export namespace CoreTypes {
} }
export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right' | 'justify'; export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right' | 'justify';
export module TextAlignment { export namespace TextAlignment {
export const left = 'left'; export const left = 'left';
export const center = 'center'; export const center = 'center';
export const right = 'right'; export const right = 'right';
@ -74,14 +74,14 @@ export namespace CoreTypes {
} }
export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through';
export module TextDecoration { export namespace TextDecoration {
export const none = 'none'; export const none = 'none';
export const underline = 'underline'; export const underline = 'underline';
export const lineThrough = 'line-through'; export const lineThrough = 'line-through';
} }
export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase'; export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase';
export module TextTransform { export namespace TextTransform {
export const none = 'none'; export const none = 'none';
export const capitalize = 'capitalize'; export const capitalize = 'capitalize';
export const uppercase = 'uppercase'; export const uppercase = 'uppercase';
@ -89,7 +89,7 @@ export namespace CoreTypes {
} }
export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap'; export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap';
export module WhiteSpace { export namespace WhiteSpace {
export const normal = 'normal'; export const normal = 'normal';
export const nowrap = 'nowrap'; export const nowrap = 'nowrap';
} }
@ -97,20 +97,20 @@ export namespace CoreTypes {
export type MaxLinesType = number; export type MaxLinesType = number;
export type OrientationType = 'horizontal' | 'vertical'; export type OrientationType = 'horizontal' | 'vertical';
export module Orientation { export namespace Orientation {
export const horizontal = 'horizontal'; export const horizontal = 'horizontal';
export const vertical = 'vertical'; export const vertical = 'vertical';
} }
export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown'; export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown';
export module DeviceOrientation { export namespace DeviceOrientation {
export const portrait = 'portrait'; export const portrait = 'portrait';
export const landscape = 'landscape'; export const landscape = 'landscape';
export const unknown = 'unknown'; export const unknown = 'unknown';
} }
export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch';
export module HorizontalAlignment { export namespace HorizontalAlignment {
export const left = 'left'; export const left = 'left';
export const center = 'center'; export const center = 'center';
export const right = 'right'; export const right = 'right';
@ -120,7 +120,7 @@ export namespace CoreTypes {
} }
export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch'; export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch';
export module VerticalAlignment { export namespace VerticalAlignment {
export const top = 'top'; export const top = 'top';
export const middle = 'middle'; export const middle = 'middle';
export const bottom = 'bottom'; export const bottom = 'bottom';
@ -143,7 +143,7 @@ export namespace CoreTypes {
} }
export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill'; export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill';
export module ImageStretch { export namespace ImageStretch {
export const none: ImageStretchType = 'none'; export const none: ImageStretchType = 'none';
export const aspectFill: ImageStretchType = 'aspectFill'; export const aspectFill: ImageStretchType = 'aspectFill';
export const aspectFit: ImageStretchType = 'aspectFit'; export const aspectFit: ImageStretchType = 'aspectFit';
@ -151,7 +151,7 @@ export namespace CoreTypes {
} }
export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed'; export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed';
export module Visibility { export namespace Visibility {
export const visible: VisibilityType = 'visible'; export const visible: VisibilityType = 'visible';
export const collapse: VisibilityType = 'collapse'; export const collapse: VisibilityType = 'collapse';
export const collapsed: VisibilityType = 'collapsed'; export const collapsed: VisibilityType = 'collapsed';
@ -161,30 +161,30 @@ export namespace CoreTypes {
const parseStrict = makeParser<CoreTypes.VisibilityType>(isValid); const parseStrict = makeParser<CoreTypes.VisibilityType>(isValid);
} }
export module FontAttributes { export namespace FontAttributes {
export const Normal = 0; export const Normal = 0;
export const Bold = 1; export const Bold = 1;
export const Italic = 1 << 1; export const Italic = 1 << 1;
} }
export module DeviceType { export namespace DeviceType {
export const Phone: string = 'Phone'; export const Phone: string = 'Phone';
export const Tablet: string = 'Tablet'; export const Tablet: string = 'Tablet';
} }
export type UpdateTextTriggerType = 'focusLost' | 'textChanged'; export type UpdateTextTriggerType = 'focusLost' | 'textChanged';
export module UpdateTextTrigger { export namespace UpdateTextTrigger {
export const focusLost: UpdateTextTriggerType = 'focusLost'; export const focusLost: UpdateTextTriggerType = 'focusLost';
export const textChanged: UpdateTextTriggerType = 'textChanged'; export const textChanged: UpdateTextTriggerType = 'textChanged';
} }
export module Accuracy { export namespace Accuracy {
export const any: number = 300; export const any: number = 300;
export const high: number = 3; export const high: number = 3;
} }
export type DockType = 'left' | 'top' | 'right' | 'bottom'; export type DockType = 'left' | 'top' | 'right' | 'bottom';
export module Dock { export namespace Dock {
export const left: DockType = 'left'; export const left: DockType = 'left';
export const top: DockType = 'top'; export const top: DockType = 'top';
export const right: DockType = 'right'; export const right: DockType = 'right';
@ -192,48 +192,48 @@ export namespace CoreTypes {
} }
export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters'; export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters';
export module AutocapitalizationType { export namespace AutocapitalizationType {
export const none: AutocapitalizationInputType = 'none'; export const none: AutocapitalizationInputType = 'none';
export const words: AutocapitalizationInputType = 'words'; export const words: AutocapitalizationInputType = 'words';
export const sentences: AutocapitalizationInputType = 'sentences'; export const sentences: AutocapitalizationInputType = 'sentences';
export const allCharacters: AutocapitalizationInputType = 'allcharacters'; export const allCharacters: AutocapitalizationInputType = 'allcharacters';
} }
export module NavigationBarVisibility { export namespace NavigationBarVisibility {
export const auto: string = 'auto'; export const auto: string = 'auto';
export const never: string = 'never'; export const never: string = 'never';
export const always: string = 'always'; export const always: string = 'always';
} }
export module AndroidActionBarIconVisibility { export namespace AndroidActionBarIconVisibility {
export const auto: string = 'auto'; export const auto: string = 'auto';
export const never: string = 'never'; export const never: string = 'never';
export const always: string = 'always'; export const always: string = 'always';
} }
export module AndroidActionItemPosition { export namespace AndroidActionItemPosition {
export const actionBar: string = 'actionBar'; export const actionBar: string = 'actionBar';
export const actionBarIfRoom: string = 'actionBarIfRoom'; export const actionBarIfRoom: string = 'actionBarIfRoom';
export const popup: string = 'popup'; export const popup: string = 'popup';
} }
export module IOSActionItemPosition { export namespace IOSActionItemPosition {
export const left: string = 'left'; export const left: string = 'left';
export const right: string = 'right'; export const right: string = 'right';
} }
export module ImageFormat { export namespace ImageFormat {
export const png: string = 'png'; export const png: string = 'png';
export const jpeg: string = 'jpeg'; export const jpeg: string = 'jpeg';
export const jpg: string = 'jpg'; export const jpg: string = 'jpg';
} }
export module FontStyle { export namespace FontStyle {
export const normal: string = 'normal'; export const normal: string = 'normal';
export const italic: string = 'italic'; export const italic: string = 'italic';
} }
export module FontWeight { export namespace FontWeight {
export const thin: string = '100'; export const thin: string = '100';
export const extraLight: string = '200'; export const extraLight: string = '200';
export const light: string = '300'; export const light: string = '300';
@ -246,7 +246,7 @@ export namespace CoreTypes {
} }
export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
export module BackgroundRepeat { export namespace BackgroundRepeat {
export const repeat: BackgroundRepeatType = 'repeat'; export const repeat: BackgroundRepeatType = 'repeat';
export const repeatX: BackgroundRepeatType = 'repeat-x'; export const repeatX: BackgroundRepeatType = 'repeat-x';
export const repeatY: BackgroundRepeatType = 'repeat-y'; export const repeatY: BackgroundRepeatType = 'repeat-y';
@ -257,26 +257,26 @@ export namespace CoreTypes {
let animation: typeof animationModule; let animation: typeof animationModule;
export module AnimationCurve { export namespace AnimationCurve {
export const ease = 'ease'; export const ease = 'ease';
export const easeIn = 'easeIn'; export const easeIn = 'easeIn';
export const easeOut = 'easeOut'; export const easeOut = 'easeOut';
export const easeInOut = 'easeInOut'; export const easeInOut = 'easeInOut';
export const linear = 'linear'; export const linear = 'linear';
export const spring = 'spring'; export const spring = 'spring';
export function cubicBezier(x1: number, y1: number, x2: number, y2: number): Object { export function cubicBezier(x1: number, y1: number, x2: number, y2: number) {
animation = animation || require('../ui/animation'); animation = animation || require('../ui/animation');
return new animation.CubicBezierAnimationCurve(x1, y1, x2, y2); return new animation.CubicBezierAnimationCurve(x1, y1, x2, y2);
} }
} }
export module StatusBarStyle { export namespace StatusBarStyle {
export const light = 'light'; export const light = 'light';
export const dark = 'dark'; export const dark = 'dark';
} }
export module SystemAppearance { export namespace SystemAppearance {
export const light = 'light'; export const light = 'light';
export const dark = 'dark'; export const dark = 'dark';
} }

View File

@ -460,6 +460,7 @@ function parseArgumentsList<T>(text: string, start: number, argument: (value: st
return { start, end, value }; return { start, end, value };
} }
// eslint-disable-next-line no-constant-condition
for (let index = 0; true; index++) { for (let index = 0; true; index++) {
const arg = argument(text, end, index); const arg = argument(text, end, index);
if (!arg) { if (!arg) {

View File

@ -95,7 +95,7 @@ export class ObservableArray<T> extends Observable {
} }
*[Symbol.iterator]() { *[Symbol.iterator]() {
for (let item of this._array) { for (const item of this._array) {
yield item; yield item;
} }
} }

View File

@ -362,7 +362,7 @@ export function initGlobal() {
} }
} }
declare var jest: any; declare const jest: any;
function isTestingEnv() { function isTestingEnv() {
return typeof jest !== 'undefined'; return typeof jest !== 'undefined';
} }

View File

@ -22,13 +22,14 @@ export class ActionBarBase extends View implements ActionBarDefinition {
public effectiveContentInsetLeft: number; public effectiveContentInsetLeft: number;
public effectiveContentInsetRight: number; public effectiveContentInsetRight: number;
get navigationButton(): NavigationButton {
return this._navigationButton;
}
disposeNativeView() { disposeNativeView() {
this._actionItems = null; this._actionItems = null;
super.disposeNativeView(); super.disposeNativeView();
} }
get navigationButton(): NavigationButton {
return this._navigationButton;
}
set navigationButton(value: NavigationButton) { set navigationButton(value: NavigationButton) {
if (this._navigationButton !== value) { if (this._navigationButton !== value) {
if (this._navigationButton) { if (this._navigationButton) {

View File

@ -51,8 +51,8 @@ const logicalOperators = {
const expressionParsers = { const expressionParsers = {
'ArrayExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => { 'ArrayExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
const parsed = []; const parsed = [];
for (let element of expression.elements) { for (const element of expression.elements) {
let value = convertExpressionToValue(element, model, isBackConvert, changedModel); const value = convertExpressionToValue(element, model, isBackConvert, changedModel);
element.type == 'SpreadElement' ? parsed.push(...value) : parsed.push(value); element.type == 'SpreadElement' ? parsed.push(...value) : parsed.push(value);
} }
return parsed; return parsed;
@ -116,8 +116,8 @@ const expressionParsers = {
} }
const parsedArgs = []; const parsedArgs = [];
for (let argument of expression.arguments) { for (const argument of expression.arguments) {
let value = convertExpressionToValue(argument, model, isBackConvert, changedModel); const value = convertExpressionToValue(argument, model, isBackConvert, changedModel);
argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value); argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value);
} }
return expression.optional ? callback?.(...parsedArgs) : callback(...parsedArgs); return expression.optional ? callback?.(...parsedArgs) : callback(...parsedArgs);
@ -181,8 +181,8 @@ const expressionParsers = {
'NewExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => { 'NewExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
const callback = convertExpressionToValue(expression.callee, model, isBackConvert, changedModel); const callback = convertExpressionToValue(expression.callee, model, isBackConvert, changedModel);
const parsedArgs = []; const parsedArgs = [];
for (let argument of expression.arguments) { for (const argument of expression.arguments) {
let value = convertExpressionToValue(argument, model, isBackConvert, changedModel); const value = convertExpressionToValue(argument, model, isBackConvert, changedModel);
argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value); argument.type == 'SpreadElement' ? parsedArgs.push(...value) : parsedArgs.push(value);
} }
@ -194,7 +194,7 @@ const expressionParsers = {
}, },
'ObjectExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => { 'ObjectExpression': (expression: ASTExpression, model, isBackConvert: boolean, changedModel) => {
const parsedObject = {}; const parsedObject = {};
for (let property of expression.properties) { for (const property of expression.properties) {
const value = convertExpressionToValue(property, model, isBackConvert, changedModel); const value = convertExpressionToValue(property, model, isBackConvert, changedModel);
Object.assign(parsedObject, value); Object.assign(parsedObject, value);
} }
@ -217,7 +217,7 @@ const expressionParsers = {
const length = expression.quasis.length; const length = expression.quasis.length;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let q = expression.quasis[i]; const q = expression.quasis[i];
parsedText += convertExpressionToValue(q, model, isBackConvert, changedModel); parsedText += convertExpressionToValue(q, model, isBackConvert, changedModel);
if (!q.tail) { if (!q.tail) {
parsedText += convertExpressionToValue(expression.expressions[i], model, isBackConvert, changedModel); parsedText += convertExpressionToValue(expression.expressions[i], model, isBackConvert, changedModel);
@ -262,7 +262,7 @@ export function parseExpression(expressionText: string): ASTExpression {
if (expression == null) { if (expression == null) {
const program: any = parse(expressionText, { ecmaVersion: 2020 }); const program: any = parse(expressionText, { ecmaVersion: 2020 });
const statements = program.body; const statements = program.body;
for (let statement of statements) { for (const statement of statements) {
if (statement.type == 'ExpressionStatement') { if (statement.type == 'ExpressionStatement') {
expression = statement.expression; expression = statement.expression;
break; break;

View File

@ -415,7 +415,7 @@ export class Binding {
} }
// Clear added props // Clear added props
for (let prop of addedProps) { for (const prop of addedProps) {
delete context[prop]; delete context[prop];
} }
addedProps.length = 0; addedProps.length = 0;

View File

@ -229,7 +229,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
newInputType = android.text.InputType.TYPE_CLASS_NUMBER; newInputType = android.text.InputType.TYPE_CLASS_NUMBER;
break; break;
default: default: {
const inputType = +value; const inputType = +value;
if (!isNaN(inputType)) { if (!isNaN(inputType)) {
newInputType = inputType; newInputType = inputType;
@ -237,6 +237,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
newInputType = android.text.InputType.TYPE_CLASS_TEXT; newInputType = android.text.InputType.TYPE_CLASS_TEXT;
} }
break; break;
}
} }
this._setInputType(newInputType); this._setInputType(newInputType);

View File

@ -60,7 +60,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
newKeyboardType = UIKeyboardType.NumberPad; newKeyboardType = UIKeyboardType.NumberPad;
break; break;
default: default: {
const kt = +value; const kt = +value;
if (!isNaN(kt)) { if (!isNaN(kt)) {
newKeyboardType = <UIKeyboardType>kt; newKeyboardType = <UIKeyboardType>kt;
@ -68,6 +68,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
newKeyboardType = UIKeyboardType.Default; newKeyboardType = UIKeyboardType.Default;
} }
break; break;
}
} }
this.nativeTextViewProtected.keyboardType = newKeyboardType; this.nativeTextViewProtected.keyboardType = newKeyboardType;
@ -104,9 +105,11 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
break; break;
case 'none': case 'none':
newTextContentType = null; newTextContentType = null;
default: break;
default: {
newTextContentType = value; newTextContentType = value;
break; break;
}
} }
this.nativeTextViewProtected.textContentType = newTextContentType; this.nativeTextViewProtected.textContentType = newTextContentType;
@ -152,7 +155,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
case 'send': case 'send':
newValue = UIReturnKeyType.Send; newValue = UIReturnKeyType.Send;
break; break;
default: default: {
const rkt = +value; const rkt = +value;
if (!isNaN(rkt)) { if (!isNaN(rkt)) {
newValue = <UIKeyboardType>rkt; newValue = <UIKeyboardType>rkt;
@ -160,6 +163,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
newValue = UIKeyboardType.Default; newValue = UIKeyboardType.Default;
} }
break; break;
}
} }
this.nativeTextViewProtected.returnKeyType = newValue; this.nativeTextViewProtected.returnKeyType = newValue;

View File

@ -439,7 +439,7 @@ export class Frame extends FrameBase {
const newFragmentTag = `fragment${fragmentId}[${navDepth}]`; const newFragmentTag = `fragment${fragmentId}[${navDepth}]`;
const newFragment = this.createFragment(newEntry, newFragmentTag); const newFragment = this.createFragment(newEntry, newFragmentTag);
const transaction = manager.beginTransaction(); const transaction = manager.beginTransaction();
let animated = currentEntry ? this._getIsAnimatedNavigation(newEntry.entry) : false; const animated = currentEntry ? this._getIsAnimatedNavigation(newEntry.entry) : false;
// NOTE: Don't use transition for the initial navigation (same as on iOS) // NOTE: Don't use transition for the initial navigation (same as on iOS)
// On API 21+ transition won't be triggered unless there was at least one // On API 21+ transition won't be triggered unless there was at least one
// layout pass so we will wait forever for transitionCompleted handler... // layout pass so we will wait forever for transitionCompleted handler...

View File

@ -84,7 +84,7 @@ export class Frame extends FrameBase {
} }
let navigationTransition: NavigationTransition; let navigationTransition: NavigationTransition;
let animated = this.currentPage ? this._getIsAnimatedNavigation(backstackEntry.entry) : false; const animated = this.currentPage ? this._getIsAnimatedNavigation(backstackEntry.entry) : false;
if (animated) { if (animated) {
navigationTransition = this._getNavigationTransition(backstackEntry.entry); navigationTransition = this._getNavigationTransition(backstackEntry.entry);
if (navigationTransition) { if (navigationTransition) {
@ -183,7 +183,7 @@ export class Frame extends FrameBase {
} }
private pushViewControllerAnimated(viewController: UIViewController, animated: boolean, isModal: boolean) { private pushViewControllerAnimated(viewController: UIViewController, animated: boolean, isModal: boolean) {
let transitionCoordinator = this._ios.controller.transitionCoordinator; const transitionCoordinator = this._ios.controller.transitionCoordinator;
if (!isModal && transitionCoordinator) { if (!isModal && transitionCoordinator) {
transitionCoordinator.animateAlongsideTransitionCompletion(null, () => { transitionCoordinator.animateAlongsideTransitionCompletion(null, () => {
this._ios.controller.pushViewControllerAnimated(viewController, animated); this._ios.controller.pushViewControllerAnimated(viewController, animated);

View File

@ -78,15 +78,15 @@ export class ItemSpec extends Observable implements ItemSpecDefinition {
private _value: number; private _value: number;
private _unitType: GridUnitType; private _unitType: GridUnitType;
constructor() { constructor(...args) {
super(); super();
if (arguments.length === 0) { if (args.length === 0) {
this._value = 1; this._value = 1;
this._unitType = GridUnitType.STAR; this._unitType = GridUnitType.STAR;
} else if (arguments.length === 2) { } else if (arguments.length === 2) {
const value = arguments[0]; const value = args[0];
const type = arguments[1]; const type = args[1];
if (typeof value === 'number' && typeof type === 'string') { if (typeof value === 'number' && typeof type === 'string') {
if (value < 0 || isNaN(value) || !isFinite(value)) { if (value < 0 || isNaN(value) || !isFinite(value)) {
throw new Error(`Value should not be negative, NaN or Infinity: ${value}`); throw new Error(`Value should not be negative, NaN or Infinity: ${value}`);
@ -381,9 +381,9 @@ rowSpanProperty.register(View);
export type GridUnitType = 'pixel' | 'star' | 'auto'; export type GridUnitType = 'pixel' | 'star' | 'auto';
export namespace GridUnitType { export namespace GridUnitType {
export const PIXEL: 'pixel' = 'pixel'; export const PIXEL = 'pixel';
export const STAR: 'star' = 'star'; export const STAR = 'star';
export const AUTO: 'auto' = 'auto'; export const AUTO = 'auto';
export const isValid = makeValidator<GridUnitType>(PIXEL, STAR, AUTO); export const isValid = makeValidator<GridUnitType>(PIXEL, STAR, AUTO);
export const parse = makeParser<GridUnitType>(isValid); export const parse = makeParser<GridUnitType>(isValid);
} }

View File

@ -109,7 +109,7 @@ export class RootLayout extends RootLayoutBase {
backgroundColorAnimator.addUpdateListener( backgroundColorAnimator.addUpdateListener(
new android.animation.ValueAnimator.AnimatorUpdateListener({ new android.animation.ValueAnimator.AnimatorUpdateListener({
onAnimationUpdate(animator: android.animation.ValueAnimator) { onAnimationUpdate(animator: android.animation.ValueAnimator) {
let argb = (<java.lang.Integer>animator.getAnimatedValue()).intValue(); const argb = (<java.lang.Integer>animator.getAnimatedValue()).intValue();
view.backgroundColor = new Color(argb); view.backgroundColor = new Color(argb);
}, },
}) })

View File

@ -734,6 +734,7 @@ function normalizeTransformation({ property, value }: Transformation): Transform
} }
function convertTransformValue(property: string, stringValue: string): TransformationValue { function convertTransformValue(property: string, stringValue: string): TransformationValue {
/* eslint-disable prefer-const */
let [x, y, z] = stringValue.split(',').map(parseFloat); let [x, y, z] = stringValue.split(',').map(parseFloat);
if (property === 'translate') { if (property === 'translate') {
y ??= IDENTITY_TRANSFORMATION.translate.y; y ??= IDENTITY_TRANSFORMATION.translate.y;

View File

@ -159,11 +159,11 @@ export function debounce(fn: any, delay = 300) {
}; };
} }
export function throttle(fn: any, delay = 300) { export function throttle(fn: Function, delay = 300) {
let waiting = false; let waiting = false;
return function () { return function (...args) {
if (!waiting) { if (!waiting) {
fn.apply(this, arguments); fn.apply(this, args);
waiting = true; waiting = true;
setTimeout(function () { setTimeout(function () {
waiting = false; waiting = false;

View File

@ -34,9 +34,10 @@ export function dataDeserialize(nativeData?: any) {
} }
case 'org.json.JSONObject': { case 'org.json.JSONObject': {
store = {}; store = {};
let i = nativeData.keys(); const i = nativeData.keys();
let key;
while (i.hasNext()) { while (i.hasNext()) {
let key = i.next(); key = i.next();
store[key] = dataDeserialize(nativeData.get(key)); store[key] = dataDeserialize(nativeData.get(key));
} }
break; break;

View File

@ -36,8 +36,8 @@ export function dataDeserialize(nativeData?: any) {
case 'NSNull': case 'NSNull':
return null; return null;
case 'NSMutableDictionary': case 'NSMutableDictionary':
case 'NSDictionary': case 'NSDictionary': {
let obj = {}; const obj = {};
const length = nativeData.count; const length = nativeData.count;
const keysArray = nativeData.allKeys as NSArray<any>; const keysArray = nativeData.allKeys as NSArray<any>;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@ -45,14 +45,16 @@ export function dataDeserialize(nativeData?: any) {
obj[nativeKey] = dataDeserialize(nativeData.objectForKey(nativeKey)); obj[nativeKey] = dataDeserialize(nativeData.objectForKey(nativeKey));
} }
return obj; return obj;
}
case 'NSMutableArray': case 'NSMutableArray':
case 'NSArray': case 'NSArray': {
let array = []; const array = [];
const len = nativeData.count; const len = nativeData.count;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
array[i] = dataDeserialize(nativeData.objectAtIndex(i)); array[i] = dataDeserialize(nativeData.objectAtIndex(i));
} }
return array; return array;
}
default: default:
return nativeData; return nativeData;
} }