diff --git a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts b/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts index ed78b5c9..ba9a4716 100644 --- a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts +++ b/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts @@ -61,7 +61,7 @@ export function getSelectPropsWithoutValue(dom: HorizonSelect, properties: Objec }; } -export function updateSelectValue(dom: HorizonSelect, props: Props, isInit: boolean = false) { +export function updateSelectValue(dom: HorizonSelect, props: Props, isInit = false) { const {value, defaultValue, multiple} = props; const oldMultiple = dom._multiple !== undefined ? dom._multiple : dom.multiple; diff --git a/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts b/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts index 595fd663..ea344f23 100644 --- a/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts +++ b/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts @@ -45,7 +45,7 @@ export function getTextareaPropsWithoutValue(dom: HTMLTextAreaElement, propertie }; } -export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isInit: boolean = false) { +export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isInit = false) { if (isInit) { const initValue = getInitValue(props); if (initValue !== '') { diff --git a/libs/horizon/src/horizonx/adapters/reduxReact.ts b/libs/horizon/src/horizonx/adapters/reduxReact.ts index 4b1ff6e6..58321399 100644 --- a/libs/horizon/src/horizonx/adapters/reduxReact.ts +++ b/libs/horizon/src/horizonx/adapters/reduxReact.ts @@ -19,7 +19,7 @@ import { createContext } from '../../renderer/components/context/CreateContext'; import { createElement } from '../../external/JSXElement'; import { BoundActionCreator } from './redux'; import { ReduxAction } from './redux'; -import { ReduxStoreHandler } from '../store/StoreHandler' +import { ReduxStoreHandler } from '../store/StoreHandler'; const DefaultContext = createContext(null); type Context = typeof DefaultContext; diff --git a/libs/horizon/src/horizonx/proxy/Observer.ts b/libs/horizon/src/horizonx/proxy/Observer.ts index 6a2216db..950c16c6 100644 --- a/libs/horizon/src/horizonx/proxy/Observer.ts +++ b/libs/horizon/src/horizonx/proxy/Observer.ts @@ -109,7 +109,7 @@ export class Observer implements IObserver { } allChange(): void { - let keyIt = this.keyVNodes.keys(); + const keyIt = this.keyVNodes.keys(); let keyItem = keyIt.next(); while (!keyItem.done) { this.setProp(keyItem.value); diff --git a/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts b/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts index ac871e90..6074b28b 100644 --- a/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts +++ b/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts @@ -42,8 +42,8 @@ export function get(rawObj: object, key: string | symbol, receiver: any, singleL observer.watchers[prop].push(handler); return ()=>{ observer.watchers[prop]=observer.watchers[prop].filter(cb=>cb!==handler); - } - } + }; + }; } if (key === 'addListener') { diff --git a/libs/horizon/src/renderer/ErrorHandler.ts b/libs/horizon/src/renderer/ErrorHandler.ts index 34461b14..10ec83f3 100644 --- a/libs/horizon/src/renderer/ErrorHandler.ts +++ b/libs/horizon/src/renderer/ErrorHandler.ts @@ -78,7 +78,7 @@ function createClassErrorUpdate( return update; } function isPromise(error: any): error is PromiseType { - return error !== null && typeof error === 'object' && typeof error.then === 'function' + return error !== null && typeof error === 'object' && typeof error.then === 'function'; } // 处理capture和bubble阶段抛出的错误 export function handleRenderThrowError( diff --git a/libs/horizon/src/renderer/components/CreatePortal.ts b/libs/horizon/src/renderer/components/CreatePortal.ts index 767bb21e..f477d528 100644 --- a/libs/horizon/src/renderer/components/CreatePortal.ts +++ b/libs/horizon/src/renderer/components/CreatePortal.ts @@ -19,7 +19,7 @@ import type {PortalType} from '../Types'; export function createPortal( children: any, realNode: any, - key: string = '', + key = '', ): PortalType { return { vtype: TYPE_PORTAL, diff --git a/libs/horizon/src/renderer/components/context/Context.ts b/libs/horizon/src/renderer/components/context/Context.ts index 4c1242af..c1899b9c 100644 --- a/libs/horizon/src/renderer/components/context/Context.ts +++ b/libs/horizon/src/renderer/components/context/Context.ts @@ -35,7 +35,7 @@ function collectDeps(vNode: VNode, context: ContextType) { } } -export function getNewContext(vNode: VNode, ctx: ContextType, isUseContext: boolean = false): T { +export function getNewContext(vNode: VNode, ctx: ContextType, isUseContext = false): T { // 如果来自于useContext,则需要在函数组件中调用 if (isUseContext && getHookStage() === null) { throwNotInFuncError(); diff --git a/libs/horizon/src/renderer/hooks/HookExternal.ts b/libs/horizon/src/renderer/hooks/HookExternal.ts index 45e87ef2..d869aae8 100644 --- a/libs/horizon/src/renderer/hooks/HookExternal.ts +++ b/libs/horizon/src/renderer/hooks/HookExternal.ts @@ -37,7 +37,7 @@ export function useContext( return getNewContext(processingVNode!, Context, true); } -export function useState(initialState: (() => S) | S,): [S, Dispatch>] { +export function useState(initialState: (() => S) | S): [S, Dispatch>] { return useStateImpl(initialState); } diff --git a/libs/horizon/src/renderer/hooks/UseEffectHook.ts b/libs/horizon/src/renderer/hooks/UseEffectHook.ts index 7e57a5cf..e44f0f6c 100644 --- a/libs/horizon/src/renderer/hooks/UseEffectHook.ts +++ b/libs/horizon/src/renderer/hooks/UseEffectHook.ts @@ -26,7 +26,7 @@ import {getHookStage, HookStage} from './HookStage'; import {isArrayEqual} from '../utils/compare'; import {getProcessingVNode} from '../GlobalVar'; -export function useEffectImpl(effectFunc: () => (() => void) | void, deps?: Array | null,): void { +export function useEffectImpl(effectFunc: () => (() => void) | void, deps?: Array | null): void { // 异步触发的effect useEffect(effectFunc, deps, EffectConstant.Effect); } diff --git a/libs/horizon/src/renderer/hooks/UseMemoHook.ts b/libs/horizon/src/renderer/hooks/UseMemoHook.ts index 9a4a8a19..db12d545 100644 --- a/libs/horizon/src/renderer/hooks/UseMemoHook.ts +++ b/libs/horizon/src/renderer/hooks/UseMemoHook.ts @@ -21,7 +21,7 @@ import { import {getHookStage, HookStage} from './HookStage'; import {isArrayEqual} from '../utils/compare'; -export function useMemoImpl(fun: () => V, deps?: Array | null,): V { +export function useMemoImpl(fun: () => V, deps?: Array | null): V { const stage = getHookStage(); if (stage === null) { throwNotInFuncError(); diff --git a/libs/horizon/src/renderer/hooks/UseReducerHook.ts b/libs/horizon/src/renderer/hooks/UseReducerHook.ts index 39d227e1..3637f775 100644 --- a/libs/horizon/src/renderer/hooks/UseReducerHook.ts +++ b/libs/horizon/src/renderer/hooks/UseReducerHook.ts @@ -137,7 +137,7 @@ function updateReducerHookState(currentHookUpdates, currentHook, reducer): // 计算stateValue值 function calculateNewState(currentHookUpdates: Array>, currentHook, reducer: (S, A) => S) { - let reducerObj = currentHook.state; + const reducerObj = currentHook.state; let state = reducerObj.stateValue; // 循环遍历更新数组,计算新的状态值 diff --git a/libs/horizon/src/renderer/submit/HookEffectHandler.ts b/libs/horizon/src/renderer/submit/HookEffectHandler.ts index c0c31f21..88e4b1fc 100644 --- a/libs/horizon/src/renderer/submit/HookEffectHandler.ts +++ b/libs/horizon/src/renderer/submit/HookEffectHandler.ts @@ -31,7 +31,7 @@ import {EffectConstant} from '../hooks/EffectConstant'; let hookEffects: Array = []; let hookRemoveEffects: Array = []; // 是否正在异步调度effects -let isScheduling: boolean = false; +let isScheduling = false; export function setSchedulingEffects(value) { isScheduling = value; diff --git a/libs/horizon/src/renderer/submit/LifeCycleHandler.ts b/libs/horizon/src/renderer/submit/LifeCycleHandler.ts index 5a639aa7..f844b3de 100644 --- a/libs/horizon/src/renderer/submit/LifeCycleHandler.ts +++ b/libs/horizon/src/renderer/submit/LifeCycleHandler.ts @@ -172,7 +172,7 @@ function attachRef(vNode: VNode) { } function detachRef(vNode: VNode, isOldRef?: boolean) { - let ref = (isOldRef ? vNode.oldRef : vNode.ref); + const ref = (isOldRef ? vNode.oldRef : vNode.ref); handleRef(vNode, ref, null); } diff --git a/libs/horizon/src/renderer/submit/Submit.ts b/libs/horizon/src/renderer/submit/Submit.ts index ecdab322..30ec1bf9 100644 --- a/libs/horizon/src/renderer/submit/Submit.ts +++ b/libs/horizon/src/renderer/submit/Submit.ts @@ -41,7 +41,7 @@ let rootThrowError = null; // 防止死循环调用update const LOOPING_UPDATE_LIMIT = 50; -let loopingUpdateCount: number = 0; +let loopingUpdateCount = 0; let lastRoot: VNode | null = null; export function submitToRender(treeRoot) { diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/horizon/src/renderer/vnode/VNodeCreator.ts index 6b96e49e..cc596c03 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/horizon/src/renderer/vnode/VNodeCreator.ts @@ -74,7 +74,7 @@ export function getLazyVNodeTag(lazyComp: any): string { } else if (lazyComp !== undefined && lazyComp !== null && typeLazyMap[lazyComp.vtype]) { return typeLazyMap[lazyComp.vtype]; } - throw Error("Horizon can't resolve the content of lazy"); + throw Error('Horizon can\'t resolve the content of lazy'); } // 创建processing diff --git a/package.json b/package.json index c939f970..c8b44fb3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "libs/*" ], "scripts": { - "lint": "eslint . --ext .ts", + "lint": "eslint . --ext .ts --fix", + "prettier": "prettier -w libs/**/*.ts", "build": "rollup --config ./scripts/rollup/rollup.config.js", "build:watch": "rollup --watch --config ./scripts/rollup/rollup.config.js", "build:3rdLib": "node ./scripts/gen3rdLib.js build:3rdLib",