Skip to content

Commit 77c6a13

Browse files
lint
1 parent a483827 commit 77c6a13

4 files changed

Lines changed: 54 additions & 49 deletions

File tree

src/widgets/buttons.ts

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -400,48 +400,48 @@ function deleteButtonWithCheck (
400400
img.setAttribute('src', minusIconURI) // plus sign
401401
img.setAttribute('style', 'margin: 0.2em; width: 1em; height:1em')
402402
img.title = 'Remove this ' + noun
403-
var delButton = img
403+
var deleteButtonElt = img
404404

405-
container.appendChild(delButton)
405+
container.appendChild(deleteButtonElt)
406406
container.setAttribute('class', 'hoverControl') // See tabbedtab.css (sigh global CSS)
407-
delButton.setAttribute('class', 'hoverControlHide')
407+
deleteButtonElt.setAttribute('class', 'hoverControlHide')
408408
// delButton.setAttribute('style', 'color: red; margin-right: 0.3em; foat:right; text-align:right')
409-
delButton.addEventListener(
409+
deleteButtonElt.addEventListener(
410410
'click',
411411
function (_event) {
412-
container.removeChild(delButton) // Ask -- are you sure?
413-
var cancelButton = dom.createElement('button')
412+
container.removeChild(deleteButtonElt) // Ask -- are you sure?
413+
var cancelButtonElt = dom.createElement('button')
414414
// cancelButton.textContent = 'cancel'
415-
cancelButton.setAttribute('style', UI.style.buttonStyle)
416-
var img = cancelButton.appendChild(dom.createElement('img'))
415+
cancelButtonElt.setAttribute('style', UI.style.buttonStyle)
416+
var img = cancelButtonElt.appendChild(dom.createElement('img'))
417417
img.setAttribute('src', cancelIconURI)
418418
img.setAttribute('style', UI.style.buttonStyle)
419419

420-
container.appendChild(cancelButton).addEventListener(
420+
container.appendChild(cancelButtonElt).addEventListener(
421421
'click',
422422
function (_event) {
423-
container.removeChild(sureButton)
424-
container.removeChild(cancelButton)
425-
container.appendChild(delButton)
423+
container.removeChild(sureButtonElt)
424+
container.removeChild(cancelButtonElt)
425+
container.appendChild(deleteButtonElt)
426426
},
427427
false
428428
)
429-
var sureButton = dom.createElement('button')
430-
sureButton.textContent = 'Delete ' + noun
431-
sureButton.setAttribute('style', UI.style.buttonStyle)
432-
container.appendChild(sureButton).addEventListener(
429+
var sureButtonElt = dom.createElement('button')
430+
sureButtonElt.textContent = 'Delete ' + noun
431+
sureButtonElt.setAttribute('style', UI.style.buttonStyle)
432+
container.appendChild(sureButtonElt).addEventListener(
433433
'click',
434434
function (_event) {
435-
container.removeChild(sureButton)
436-
container.removeChild(cancelButton)
435+
container.removeChild(sureButtonElt)
436+
container.removeChild(cancelButtonElt)
437437
deleteFunction()
438438
},
439439
false
440440
)
441441
},
442442
false
443443
)
444-
return delButton
444+
return deleteButtonElt
445445
}
446446

447447
/* Make a button
@@ -514,16 +514,14 @@ function askName (dom, kb, container, predicate, klass, noun) {
514514

515515
form.appendChild(dom.createElement('br'))
516516

517-
const cancelButtonElt = form.appendChild(cancelButton(dom))
518-
cancelButtonElt.addEventListener('click', function (_event) {
517+
form.appendChild(cancelButton(dom, function (_event) {
519518
form.parentNode.removeChild(form)
520519
resolve(null)
521-
}, false)
520+
}))
522521

523-
const continueButtonElt = form.appendChild(continueButton(dom))
524-
continueButtonElt.addEventListener('click', function (_event) {
522+
form.appendChild(continueButton(dom, function (_event) {
525523
gotName()
526-
}, false)
524+
}))
527525
namefield.focus()
528526
}) // Promise
529527
}
@@ -533,7 +531,7 @@ function askName (dom, kb, container, predicate, klass, noun) {
533531
// A little link icon
534532
//
535533
//
536-
function linkIcon (dom, subject, iconURI) {
534+
function linkIcon (dom, subject, iconURI?) {
537535
var anchor = dom.createElement('a')
538536
anchor.setAttribute('href', subject.uri)
539537
if (subject.uri.startsWith('http')) {
@@ -632,13 +630,13 @@ function attachmentList (dom, subject, div, options) {
632630
if (ok) {
633631
refresh()
634632
} else {
635-
complain('Error deleting one: ' + errorBody)
633+
complain(undefined, 'Error deleting one: ' + errorBody)
636634
}
637635
})
638636
}
639637
var createNewRow = function (target) {
640638
var theTarget = target
641-
var opt = { noun: noun }
639+
var opt: any = { noun: noun }
642640
if (modify) {
643641
opt.deleteFunction = function () {
644642
deleteAttachment(theTarget)
@@ -655,7 +653,7 @@ function attachmentList (dom, subject, div, options) {
655653
refresh()
656654

657655
var droppedURIHandler = function (uris) {
658-
var ins = []
656+
var ins: any = []
659657
uris.map(function (u) {
660658
var target = $rdf.sym(u) // Attachment needs text label to disinguish I think not icon.
661659
console.log('Dropped on attachemnt ' + u) // icon was: UI.icons.iconBase + 'noun_25830.svg'
@@ -665,7 +663,7 @@ function attachmentList (dom, subject, div, options) {
665663
if (ok) {
666664
refresh()
667665
} else {
668-
complain('Error adding one: ' + errorBody)
666+
complain(undefined, 'Error adding one: ' + errorBody)
669667
}
670668
})
671669
}
@@ -694,12 +692,12 @@ function openHrefInOutlineMode (e) {
694692
var uri = target.getAttribute('href')
695693
if (!uri) return console.log('openHrefInOutlineMode: No href found!\n')
696694
const dom = window.document
697-
if (dom.outlineManager) {
695+
if ((dom as any).outlineManager) {
698696
// @@ TODO Remove the use of document as a global object
699-
dom.outlineManager.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
700-
} else if (window && window.panes && window.panes.getOutliner) {
697+
;(dom as any).outlineManager.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
698+
} else if (window && (window as any).panes && (window as any).panes.getOutliner) {
701699
// @@ TODO Remove the use of window as a global object
702-
window.panes
700+
;(window as any).panes
703701
.getOutliner()
704702
.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
705703
} else {
@@ -762,7 +760,7 @@ function allClassURIs () {
762760
*/
763761

764762
function propertyTriage (kb) {
765-
var possibleProperties = {}
763+
var possibleProperties: any = {}
766764
// if (possibleProperties === undefined) possibleProperties = {}
767765
// var kb = UI.store
768766
var dp = {}
@@ -900,7 +898,7 @@ function selectorPanelRefresh (
900898
) {
901899
var style0 =
902900
'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;'
903-
var selected = null
901+
var selected: any = null
904902
list.innerHTML = ''
905903

906904
var refreshItem = function (box, x) {
@@ -979,23 +977,20 @@ function selectorPanelRefresh (
979977
//
980978
// Small compact views of things
981979
//
982-
const index = {}
983-
index.line = {} // Approx 80em
984-
index.twoLine = {} // Approx 40em * 2.4em
985-
980+
let index: any = {}
986981
// ///////////////////////////////////////////////////////////////////////////
987982
// We need these for anything which is a subject of an attachment.
988983
//
989984
// These should be moved to type-dependeent UI code. Related panes maybe
990985

991-
index.twoLine[''] = function (dom, x) {
986+
function twoLineDefault (dom, x) {
992987
// Default
993988
var box = dom.createElement('div')
994989
box.textContent = utils.label(x)
995990
return box
996991
}
997992

998-
index.twoLine.widgetForClass = function (c) {
993+
function twoLineWidgetForClass (c) {
999994
var widget = index.twoLine[c.uri]
1000995
var kb = UI.store
1001996
if (widget) return widget
@@ -1007,7 +1002,7 @@ index.twoLine.widgetForClass = function (c) {
10071002
return index.twoLine['']
10081003
}
10091004

1010-
index.twoLine['http://www.w3.org/2000/10/swap/pim/qif#Transaction'] = function (dom, x) {
1005+
function twoLineTransaction (dom, x) {
10111006
var failed = ''
10121007
var enc = function (p) {
10131008
var y = UI.store.any(x, UI.ns.qu(p))
@@ -1032,7 +1027,7 @@ index.twoLine['http://www.w3.org/2000/10/swap/pim/qif#Transaction'] = function (
10321027
return box
10331028
}
10341029

1035-
index.twoLine['http://www.w3.org/ns/pim/trip#Trip'] = function (
1030+
function twoLineTrip (
10361031
dom,
10371032
x
10381033
) {
@@ -1140,6 +1135,17 @@ function fileUploadButtonDiv (
11401135
return div
11411136
}
11421137

1138+
index = {
1139+
line: { // Approx 80em
1140+
},
1141+
twoLine: { // Approx 40em * 2.4em
1142+
'': twoLineDefault,
1143+
'http://www.w3.org/2000/10/swap/pim/qif#Transaction': twoLineTransaction,
1144+
'http://www.w3.org/ns/pim/trip#Trip': twoLineTrip,
1145+
widgetForClass: twoLineWidgetForClass
1146+
}
1147+
}
1148+
11431149
module.exports = {
11441150
complain,
11451151
clearElement,

test/unit/acl/access-groups.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { AccessGroups, AccessGroupsOptions } from '../../../src/acl/access-groups'
2-
import { NamedNode, IndexedFormula, graph } from 'rdflib'
1+
import { AccessGroups } from '../../../src/acl/access-groups'
2+
import { IndexedFormula, graph } from 'rdflib'
33
import { instantiateAccessGroups } from '../helpers/instantiateAccessGroups'
44

55
jest.mock('rdflib')

test/unit/acl/add-agent-buttons.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { JSDOM } from 'jsdom'
21
import { AddAgentButtons } from '../../../src/acl/add-agent-buttons'
32
import { instantiateAccessGroups } from '../helpers/instantiateAccessGroups'
43
// import { button } from '../../../src/widgets'
54

65
jest.mock('rdflib')
76
jest.mock('solid-auth-client')
8-
const dom = new JSDOM('<!DOCTYPE html><p>Hello world</p>').window.document
7+
98
// jest.mock('../../../src/widgets')
109
// button.mockReturnValue(document.createElement('button'))
1110

test/unit/widgets/buttons.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
shortDate,
3838
shortTime,
3939
timestamp
40-
} from '../../../src/widgenpm rts/buttons'
40+
} from '../../../src/widgets/buttons'
4141

4242
jest.mock('rdflib')
4343
jest.mock('solid-auth-client')

0 commit comments

Comments
 (0)