From ceba520e34406c97f96ae25821c74014347e6af8 Mon Sep 17 00:00:00 2001 From: AOHUA MU Date: Sat, 12 Jan 2019 23:40:17 +0800 Subject: [PATCH] fix lint --- types/redux-state-sync/index.d.ts | 94 +++++++++---------- .../redux-state-sync-tests.ts | 25 +++-- 2 files changed, 57 insertions(+), 62 deletions(-) diff --git a/types/redux-state-sync/index.d.ts b/types/redux-state-sync/index.d.ts index 51aec60404..329f56908b 100644 --- a/types/redux-state-sync/index.d.ts +++ b/types/redux-state-sync/index.d.ts @@ -4,54 +4,52 @@ // AntonioMendez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "redux-state-sync" { - import { Store, Reducer, Middleware, AnyAction } from "redux"; - import BroadcastChannel from "broadcast-channel"; +import { Store, Reducer, Middleware, AnyAction } from "redux"; +import BroadcastChannel from "broadcast-channel"; - export let lastUuid: number; - export const GET_INIT_STATE: string; - export const SEND_INIT_STATE: string; - export const RECEIVE_INIT_STATE: string; +export let lastUuid: number; +export const GET_INIT_STATE: string; +export const SEND_INIT_STATE: string; +export const RECEIVE_INIT_STATE: string; - type Stamp = { - $uuid: string; - $wuid: string; - }; - export type StampedAction = Stamp & AnyAction; - - export interface Config { - channel?: string; - predicate?: Function | null; - blacklist?: Array; - whitelist?: Array; - broadcastChannelOption?: object | null; - } - - export interface MessageListenerConfig { - channel: BroadcastChannel; - dispatch: (action: AnyAction | StampedAction) => void; - allowed: (type?: string) => boolean; - } - - export const defaultConfig: Config; - export const WINDOW_STATE_SYNC_ID: string; - export let isMessageListenerCreated: boolean; - - export function myMethod(a: string): string; - export function myOtherMethod(a: number): number; - - export function getIniteState(): AnyAction; - export function sendIniteState(): AnyAction; - export function receiveIniteState(store: Store): AnyAction; - export function s4(): string; - export function guid(): string; - - export function generateUuidForAction(action: AnyAction): StampedAction; - export function isActionAllowed(config: Config): (type?: any) => boolean; - export function createMessageListener(config: MessageListenerConfig): void; - export function createStateSyncMiddleware(config?: Config): Middleware; - export function withReduxStateSync( - appReducer: Reducer - ): (state: any, action: AnyAction) => Reducer; - export function initStateWithPrevTab(store: Store): Store; +export interface Stamp { + $uuid: string; + $wuid: string; } +export type StampedAction = Stamp & AnyAction; + +export interface Config { + channel?: string; + predicate?: (type?: string) => boolean | null; + blacklist?: string[]; + whitelist?: string[]; + broadcastChannelOption?: object | null; +} + +export interface MessageListenerConfig { + channel: BroadcastChannel; + dispatch: (action: AnyAction | StampedAction) => void; + allowed: (type?: string) => boolean; +} + +export const defaultConfig: Config; +export const WINDOW_STATE_SYNC_ID: string; +export let isMessageListenerCreated: boolean; + +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +export function getIniteState(): AnyAction; +export function sendIniteState(): AnyAction; +export function receiveIniteState(store: Store): AnyAction; +export function s4(): string; +export function guid(): string; + +export function generateUuidForAction(action: AnyAction): StampedAction; +export function isActionAllowed(config: Config): (type?: any) => boolean; +export function createMessageListener(config: MessageListenerConfig): void; +export function createStateSyncMiddleware(config?: Config): Middleware; +export function withReduxStateSync( + appReducer: Reducer +): (state: any, action: AnyAction) => Reducer; +export function initStateWithPrevTab(store: Store): Store; diff --git a/types/redux-state-sync/redux-state-sync-tests.ts b/types/redux-state-sync/redux-state-sync-tests.ts index d23c317f09..0e9207cea0 100644 --- a/types/redux-state-sync/redux-state-sync-tests.ts +++ b/types/redux-state-sync/redux-state-sync-tests.ts @@ -1,27 +1,24 @@ -import { createStore, applyMiddleware, Action } from 'redux' -import { createStateSyncMiddleware, initStateWithPrevTab, withReduxStateSync } from 'redux-state-sync' - +import { createStore, applyMiddleware, Action } from 'redux'; +import { createStateSyncMiddleware, initStateWithPrevTab, withReduxStateSync } from 'redux-state-sync'; interface TestState { a: number; b: string; c: string; } -const config = { - channel: 'test', - predicate: () => {}, - blacklist: [], - whitelist: [], - broadcastChannelOption: {} -} const middlewares = [ - createStateSyncMiddleware(config), + createStateSyncMiddleware({ + channel: 'test', + predicate: (type) => true, + blacklist: [], + whitelist: [], + broadcastChannelOption: {} + }), ]; function rootReducer(state: TestState, action: Action): TestState { return state; } - -const store = createStore(withReduxStateSync(rootReducer), ['test'], ...applyMiddleware(middlewares)) -initStateWithPrevTab(store); +const store = createStore(withReduxStateSync(rootReducer), ['test'], ...applyMiddleware(middlewares)); +initStateWithPrevTab(store);