Skip to content

Commit

Permalink
fix lint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jun 9, 2020
1 parent e3c05ab commit 4029294
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 54 deletions.
2 changes: 1 addition & 1 deletion packages-premium
2 changes: 1 addition & 1 deletion packages/__tests__/src/lib/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function oneCall(func) {
}

function spyOnMethod(Class, methodName, dontCallThrough) {
var origMethod = Class.prototype.hasOwnProperty(methodName)
var origMethod = Class.prototype.hasOwnProperty(methodName) // eslint-disable-line no-prototype-builtins
? Class.prototype[methodName]
: null

Expand Down
4 changes: 3 additions & 1 deletion packages/__tests__/src/lib/simulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ $.simulate.prototype.simulateWindowResize = function() {
if (typeof Event !== 'undefined') {
try {
event = new Event('resize')
} catch (ex) {}
} catch (ex) {
// why would fail?
}
}

if (!event) {
Expand Down
7 changes: 4 additions & 3 deletions packages/common/src/common/DayCellRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BaseComponent } from '../vdom-util'
import { DateProfile } from '../DateProfileGenerator'
import { memoizeObjArg } from '../util/memoize'
import { DateEnv } from '../datelib/env'
import { Dictionary } from '../options'


const DAY_NUM_FORMAT = createFormatter({ day: 'numeric' })
Expand All @@ -21,7 +22,7 @@ interface DayCellHookPropsInput {
dateEnv: DateEnv
viewApi: ViewApi
showDayNumber?: boolean // defaults to false
extraProps?: object // so can include a resource
extraProps?: Dictionary // so can include a resource
}

export interface DayCellHookProps extends DateMeta {
Expand All @@ -38,7 +39,7 @@ export interface DayCellRootProps {
dateProfile: DateProfile
todayRange: DateRange
showDayNumber?: boolean // defaults to false
extraHookProps?: object
extraHookProps?: Dictionary
children: (
rootElRef: Ref<any>,
classNames: string[],
Expand Down Expand Up @@ -96,7 +97,7 @@ export interface DayCellContentProps {
dateProfile: DateProfile
todayRange: DateRange
showDayNumber?: boolean // defaults to false
extraHookProps?: object
extraHookProps?: Dictionary
defaultContent?: (hookProps: DayCellHookProps) => ComponentChildren
children: (
innerElRef: Ref<any>,
Expand Down
5 changes: 3 additions & 2 deletions packages/common/src/common/DayTableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DaySeriesModel } from './DaySeriesModel'
import { DateRange } from '../datelib/date-range'
import { DateMarker } from '../datelib/marker'
import { Seg } from '../component/DateComponent'
import { Dictionary } from '../options'

export interface DayTableSeg extends Seg {
row: number
Expand All @@ -12,8 +13,8 @@ export interface DayTableSeg extends Seg {
export interface DayTableCell {
key: string // probably just the serialized date, but could be other metadata if this col is specific to another entity
date: DateMarker
extraHookProps?: object
extraDataAttrs?: object
extraHookProps?: Dictionary
extraDataAttrs?: Dictionary
extraClassNames?: string[]
}

Expand Down
9 changes: 5 additions & 4 deletions packages/common/src/common/TableDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RenderHook } from './render-hook'
import { buildNavLinkData } from './nav-link'
import { DateProfile } from '../DateProfileGenerator'
import { DayHeaderHookProps } from '../render-hook-misc'
import { Dictionary } from '../options'


export interface TableDateCellProps {
Expand All @@ -19,8 +20,8 @@ export interface TableDateCellProps {
dayHeaderFormat: DateFormatter
colSpan?: number
isSticky?: boolean // TODO: get this outta here somehow
extraDataAttrs?: object
extraHookProps?: object
extraDataAttrs?: Dictionary
extraHookProps?: Dictionary
}

const CLASS_NAME = 'fc-col-header-cell' // do the cushion too? no
Expand Down Expand Up @@ -97,8 +98,8 @@ export interface TableDowCellProps {
dayHeaderFormat: DateFormatter
colSpan?: number
isSticky?: boolean // TODO: get this outta here somehow
extraHookProps?: object
extraDataAttrs?: object
extraHookProps?: Dictionary
extraDataAttrs?: Dictionary
extraClassNames?: string[]
}

Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/component/DateComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { elementClosest } from '../util/dom-manip'
import { isDateSelectionValid, isInteractionValid } from '../validation'
import { EventInteractionState } from '../interactions/event-interaction-state'
import { guid } from '../util/misc'
import { Dictionary } from '../options'

export type DateComponentHash = { [uid: string]: DateComponent<any, any> }

Expand Down Expand Up @@ -36,7 +37,7 @@ PURPOSES:
- hook up to fg, fill, and mirror renderers
- interface for dragging and hits
*/
export abstract class DateComponent<Props={}, State={}> extends BaseComponent<Props, State> {
export abstract class DateComponent<Props=Dictionary, State=Dictionary> extends BaseComponent<Props, State> {

uid = guid()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { identity, Identity } from '../options'
import { identity, Identity, Dictionary } from '../options'

export const EVENT_SOURCE_REFINERS = {
method: String,
extraParams: identity as Identity<object | (() => object)>,
extraParams: identity as Identity<Dictionary | (() => Dictionary)>,
startParam: String,
endParam: String,
timeZoneParam: String
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/interactions/event-resizing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Hit } from './hit'
import { Dictionary } from '../options'

export type EventResizeJoinTransforms = (hit0: Hit, hit1: Hit) => false | object
export type EventResizeJoinTransforms = (hit0: Hit, hit1: Hit) => false | Dictionary
2 changes: 1 addition & 1 deletion packages/common/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { ViewApi } from './ViewApi'
export * from './api-type-deps'

export { // things for plugins. everything else is exported in api-type-deps
BASE_OPTION_DEFAULTS, BASE_OPTION_REFINERS, identity, Identity, GenericObject, refineProps,
BASE_OPTION_DEFAULTS, BASE_OPTION_REFINERS, identity, Identity, Dictionary, refineProps,
BaseOptionRefiners, BaseOptionsRefined, CalendarOptionRefiners, CalendarOptionsRefined,
ViewOptionRefiners, ViewOptionsRefined, RawOptionsFromRefiners, RefinedOptionsFromRefiners,
CalendarListenerRefiners
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ export type ViewOptionsRefined =
// ----------------------------------------------------------------------------------------------------


export function mergeRawOptions(optionSets: GenericObject[]) {
export function mergeRawOptions(optionSets: Dictionary[]) {
return mergeProps(optionSets, COMPLEX_CALENDAR_OPTIONS)
}


export function refineProps<Refiners extends GenericRefiners, Raw extends RawOptionsFromRefiners<Refiners>>(input: Raw, refiners: Refiners): { refined: RefinedOptionsFromRefiners<Refiners>, extra: GenericObject } {
export function refineProps<Refiners extends GenericRefiners, Raw extends RawOptionsFromRefiners<Refiners>>(input: Raw, refiners: Refiners): { refined: RefinedOptionsFromRefiners<Refiners>, extra: Dictionary } {
let refined = {} as any
let extra = {} as any

Expand Down Expand Up @@ -434,12 +434,12 @@ export type RefinedOptionsFromRefiners<Refiners extends GenericRefiners> = {
Refiners[Prop] extends ((input: any) => infer RefinedType) ? RefinedType : never
}

export type DefaultedRefinedOptions<RefinedOptions extends GenericObject, DefaultKey extends keyof RefinedOptions> =
export type DefaultedRefinedOptions<RefinedOptions extends Dictionary, DefaultKey extends keyof RefinedOptions> =
Required<Pick<RefinedOptions, DefaultKey>> &
Partial<Omit<RefinedOptions, DefaultKey>>


export type GenericObject = { [prop: string]: any } // TODO: Partial<{}>
export type Dictionary = Record<string, any>

export type Identity<T = any> = (raw: T) => T

Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/reducers/CalendarDataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Emitter } from '../common/Emitter'
import { EventUiHash, EventUi, createEventUi } from '../component/event-ui'
import { EventDefHash } from '../structs/event-def'
import { parseToolbars } from '../toolbar-parse'
import { CalendarOptionsRefined, CalendarOptions, CALENDAR_OPTION_REFINERS, ViewOptions, ViewOptionsRefined, BASE_OPTION_DEFAULTS, mergeRawOptions, BASE_OPTION_REFINERS, VIEW_OPTION_REFINERS, CalendarListeners, CALENDAR_LISTENER_REFINERS } from '../options'
import { CalendarOptionsRefined, CalendarOptions, CALENDAR_OPTION_REFINERS, ViewOptions, ViewOptionsRefined, BASE_OPTION_DEFAULTS, mergeRawOptions, BASE_OPTION_REFINERS, VIEW_OPTION_REFINERS, CalendarListeners, CALENDAR_LISTENER_REFINERS, Dictionary } from '../options'
import { rangeContainsMarker } from '../datelib/date-range'
import { ViewApi } from '../ViewApi'
import { parseBusinessHours } from '../structs/business-hours'
Expand All @@ -45,10 +45,10 @@ export interface CalendarDataManagerProps {
}

export type ReducerFunc = ( // TODO: rename to CalendarDataInjector. move view-props-manip hook here as well?
currentState: object | null,
currentState: Dictionary | null,
action: Action | null,
context: CalendarContext & CalendarDataManagerState // more than just context
) => object
) => Dictionary


// in future refactor, do the redux-style function(state=initial) for initial-state
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/structs/drag-meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createDuration, Duration } from '../datelib/duration'
import { refineProps, RawOptionsFromRefiners } from '../options'
import { refineProps, RawOptionsFromRefiners, Dictionary } from '../options'

/*
Information about what will happen when an external element is dragged-and-dropped
Expand All @@ -22,7 +22,7 @@ export interface DragMeta {
duration: Duration | null
create: boolean // create an event when dropped?
sourceId: string // similar to addEvent's parameter
leftoverProps: object
leftoverProps: Dictionary
}


Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/structs/event-def.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Duration } from '../datelib/duration'
import { EventUi } from '../component/event-ui'
import { GenericObject } from '../options'
import { Dictionary } from '../options'

export interface EventDef { // TODO: add recurring type here?
defId: string
Expand All @@ -13,7 +13,7 @@ export interface EventDef { // TODO: add recurring type here?
title: string
url: string
ui: EventUi
extendedProps: GenericObject
extendedProps: Dictionary
}

export type EventDefHash = { [defId: string]: EventDef }
6 changes: 3 additions & 3 deletions packages/common/src/structs/event-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CalendarContext } from '../CalendarContext'
import { EventDef } from './event-def'
import { createEventInstance, EventInstance } from './event-instance'
import { EventSource } from './event-source'
import { RefinedOptionsFromRefiners, RawOptionsFromRefiners, identity, Identity, GenericObject, refineProps } from '../options'
import { RefinedOptionsFromRefiners, RawOptionsFromRefiners, identity, Identity, Dictionary, refineProps } from '../options'
import { EVENT_UI_REFINERS, createEventUi, EventUiInput, EventUiRefined } from '../component/event-ui'


Expand All @@ -28,7 +28,7 @@ export const EVENT_DATE_REFINERS = {
const EVENT_REFINERS = { // does NOT include EVENT_UI_REFINERS
...EVENT_NON_DATE_REFINERS,
...EVENT_DATE_REFINERS,
extendedProps: identity as Identity<GenericObject>
extendedProps: identity as Identity<Dictionary>
}

type BuiltInEventRefiners = typeof EVENT_REFINERS
Expand Down Expand Up @@ -113,7 +113,7 @@ export function buildEventRefiners(context: CalendarContext) {
Will NOT populate extendedProps with the leftover properties.
Will NOT populate date-related props.
*/
export function parseEventDef(refined: EventRefined, extra: GenericObject, sourceId: string, allDay: boolean, hasEnd: boolean, context: CalendarContext): EventDef {
export function parseEventDef(refined: EventRefined, extra: Dictionary, sourceId: string, allDay: boolean, hasEnd: boolean, context: CalendarContext): EventDef {
let def: EventDef = {
title: refined.title || '',
groupId: refined.groupId || '',
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/structs/event-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DateRange } from '../datelib/date-range'
import { EventUi } from '../component/event-ui'
import { CalendarContext } from '../CalendarContext'
import { CalendarApi } from '../CalendarApi'
import { GenericObject } from '../options'
import { Dictionary } from '../options'

/*
TODO: "EventSource" is the same name as a built-in type in TypeScript. Rethink.
Expand Down Expand Up @@ -34,7 +34,7 @@ export interface EventSource<Meta> {
ui: EventUi
success: EventSourceSuccessResponseHandler | null
failure: EventSourceErrorResponseHandler | null
extendedProps: GenericObject // undocumented
extendedProps: Dictionary // undocumented
}


Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/util/dom-manip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isArraysEqual } from './array'
import { Dictionary } from '../options'


export function htmlToElement(html: string): HTMLElement {
Expand Down Expand Up @@ -120,7 +121,7 @@ export function findDirectChildren(parent: HTMLElement[] | HTMLElement, selector

const PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i

export function applyStyle(el: HTMLElement, props: object) {
export function applyStyle(el: HTMLElement, props: Dictionary) {
for (let propName in props) {
applyStyleProp(el, propName, props[propName])
}
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/util/memoize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isArraysEqual } from './array'
import { isPropsEqual } from './object'
import { Dictionary } from '../options'


export function memoize<Args extends any[], Res>(
Expand Down Expand Up @@ -36,7 +37,7 @@ export function memoize<Args extends any[], Res>(
}


export function memoizeObjArg<Arg extends object, Res>(
export function memoizeObjArg<Arg extends Dictionary, Res>(
workerFunc: (arg: Arg) => Res,
resEquality?: (res0: Res, res1: Res) => boolean,
teardownFunc?: (res: Res) => void
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/util/requestJson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Dictionary } from '../options'

export function requestJson(method: string, url: string, params: object, successCallback, failureCallback) {
export function requestJson(method: string, url: string, params: Dictionary, successCallback, failureCallback) {
method = method.toUpperCase()

let body = null
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/vdom-util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { Component, Ref } from './vdom'
import { ViewContextType, ViewContext } from './ViewContext'
import { __assign } from 'tslib'
import { compareObjs, EqualityFuncs, getUnequalProps } from './util/object'
import { Dictionary } from './options'


// TODO: make a HOC instead
export abstract class BaseComponent<Props={}, State={}> extends Component<Props, State> {
export abstract class BaseComponent<Props=Dictionary, State=Dictionary> extends Component<Props, State> {

static addPropsEquality = addPropsEquality
static addStateEquality = addStateEquality
Expand Down
4 changes: 2 additions & 2 deletions packages/daygrid/src/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
createElement, ComponentChildren, applyStyle, BaseComponent, DelayedRunner, Ref, setRef
createElement, ComponentChildren, applyStyle, BaseComponent, DelayedRunner, Ref, setRef, Dictionary
} from '@fullcalendar/common'


export interface PopoverProps {
title: string
extraClassNames?: string[]
extraAttrs?: object
extraAttrs?: Dictionary
alignmentEl: HTMLElement
topAlignmentEl?: HTMLElement
onClose?: () => void
Expand Down
11 changes: 6 additions & 5 deletions packages/daygrid/src/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import {
setRef,
createFormatter,
ViewApi,
Dictionary,
} from '@fullcalendar/common'
import { TableSeg } from './TableSeg'


export interface TableCellProps {
date: DateMarker
dateProfile: DateProfile
extraHookProps?: object
extraDataAttrs?: object
extraHookProps?: Dictionary
extraDataAttrs?: Dictionary
extraClassNames?: string[]
elRef?: Ref<HTMLTableCellElement>
innerElRef?: Ref<HTMLDivElement>
Expand All @@ -49,8 +50,8 @@ export interface TableCellProps {
export interface TableCellModel { // TODO: move somewhere else. combine with DayTableCell?
key: string
date: DateMarker
extraHookProps?: object
extraDataAttrs?: object
extraHookProps?: Dictionary
extraDataAttrs?: Dictionary
extraClassNames?: string[]
}

Expand Down Expand Up @@ -219,7 +220,7 @@ interface TableCellTopProps {
dateProfile: DateProfile
showDayNumber: boolean
todayRange: DateRange
extraHookProps?: object
extraHookProps?: Dictionary
}

class TableCellTop extends BaseComponent<TableCellTopProps> {
Expand Down

0 comments on commit 4029294

Please sign in to comment.