Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw authored and njpearman committed Nov 13, 2020
1 parent 239fb75 commit c0d6d95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/icalendar/package.json
Expand Up @@ -9,8 +9,8 @@
"tslib": "^2.0.0",
"ical.js": "^1.4.0"
},
"type": "module",
"main": "main.js",
"main": "main.cjs.js",
"module": "main.js",
"types": "main.d.ts",
"jsdelivr": "main.global.min.js",
"browserGlobal": "FullCalendarICalendar",
Expand Down
27 changes: 11 additions & 16 deletions packages/icalendar/src/main.ts
Expand Up @@ -6,11 +6,10 @@ type Success = (rawFeed: string, xhr: XMLHttpRequest) => void
type Failure = (error: string, xhr: XMLHttpRequest) => void

export function requestICal(url: string, successCallback: Success, failureCallback: Failure) {

const xhr = new XMLHttpRequest()
xhr.open('GET', url, true)

xhr.onload = function() {
xhr.onload = () => {
if (xhr.status >= 200 && xhr.status < 400) {
successCallback(xhr.responseText, xhr)
} else {
Expand All @@ -23,7 +22,6 @@ export function requestICal(url: string, successCallback: Success, failureCallba
xhr.send(null)
}


interface ICalFeedMeta {
feedUrl: string
extraParams?: any
Expand All @@ -32,21 +30,20 @@ interface ICalFeedMeta {
let buildIcalEvents = (rawFeed: string): ICAL.Event[] => {
try {
const iCalFeed = ICAL.parse(rawFeed)
const iCalComponent = new ICAL.Component(iCalFeed);
return iCalComponent.getAllSubcomponents("vevent");
const iCalComponent = new ICAL.Component(iCalFeed)
return iCalComponent.getAllSubcomponents('vevent')
} catch (err) {
console.log(`Error parsing feed: ${err}`)
console.warn(`Error parsing feed: ${err}`)
return []
}
}

let buildEvents = (vevents: ICAL.Event[]): EventInput[] => {
return vevents.map((vevent) => {
let buildEvents = (vevents: ICAL.Event[]): EventInput[] => vevents.map((vevent) => {
const event = new ICAL.Event(vevent)

if (!event.startDate) {
// no start date so corrupt / invalid event
return null;
return null
}

const fcEvent = {
Expand All @@ -64,12 +61,11 @@ let buildEvents = (vevents: ICAL.Event[]): EventInput[] => {
}

return fcEvent
} catch(error) {
console.log(`Unable to process item in calendar: ${error}.`)
} catch (error) {
console.warn(`Unable to process item in calendar: ${error}.`)
return null
}
}).filter((item: EventInput | null) => { return item !== null })
}
}).filter((item: EventInput | null) => item !== null)

let eventSourceDef: EventSourceDef<ICalFeedMeta> = {

Expand Down Expand Up @@ -100,11 +96,10 @@ let eventSourceDef: EventSourceDef<ICalFeedMeta> = {
},
)
})
}
},
}


export default createPlugin({
eventSourceRefiners: EVENT_SOURCE_REFINERS,
eventSourceDefs: [ eventSourceDef ]
eventSourceDefs: [eventSourceDef],
})

0 comments on commit c0d6d95

Please sign in to comment.