Skip to content

Commit 3d7ed6d

Browse files
committed
Fixed tests and linter
1 parent c2d0c8a commit 3d7ed6d

File tree

16 files changed

+27
-41
lines changed

16 files changed

+27
-41
lines changed

.eslintrc

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
],
1616
"rules": {
1717
"no-console": "error",
18-
"complexity": ["warn", 15],
19-
"no-unused-vars": ["warn", {
20-
"argsIgnorePattern": "^_",
21-
"varsIgnorePattern": "^_"
22-
}],
18+
"no-unused-vars": "off",
2319
"@typescript-eslint/no-unused-vars": ["warn", {
2420
"argsIgnorePattern": "^_",
2521
"varsIgnorePattern": "^_"

src/acl/access-controller.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import { graph, NamedNode, UpdateManager } from 'rdflib'
88
import { AccessGroups } from './access-groups'
99
import { DataBrowserContext } from 'pane-registry'
1010
import { shortNameForFolder } from './acl-control'
11-
import { currentUser } from '../authn/authn'
1211
import * as utils from '../utils'
1312
import * as debug from '../debug'
14-
import ns from '../ns'
1513

1614
/**
1715
* Rendered HTML component used in the databrowser's Sharing pane.

src/authn/authn.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,16 @@ export async function findAppInstances (
400400
} catch (err) {
401401
}
402402
const index = context.index as { [key: string]: Array<NamedNode> }
403-
// eslint-disable-next-line no-console
404-
console.log({ index, visibility })
405403
const thisIndex = index[visibility]
406-
// eslint-disable-next-line no-console
407-
console.log('Failing test?', thisIndex.map(ix => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix)))
408404
const registrations = thisIndex
409405
.map(ix => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix))
410-
.flat()
406+
.reduce((acc, curr) => acc.concat(curr), [])
411407
const instances = registrations
412408
.map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instance')))
413-
.flat()
409+
.reduce((acc, curr) => acc.concat(curr), [])
414410
const containers = registrations
415411
.map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instanceContainer')))
416-
.flat()
412+
.reduce((acc, curr) => acc.concat(curr), [])
417413

418414
function unique (arr: NamedNode[]): NamedNode[] {
419415
return Array.from(new Set(arr))

src/chat/infinite.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,10 @@ export async function infiniteMessageArea (dom, kb, chatChannel, options) {
843843
const todayDocument = dateFolder.leafDocumentFromDate(now)
844844
live = todayDocument.sameTerm(selectedDocument)
845845
}
846+
let selectedMessageTable
846847
if (options.selectedMessage && !live) {
847848
const selectedDate = dateFolder.dateFromLeafDocument(selectedDocument)
848-
var selectedMessageTable = await createMessageTable(selectedDate, live)
849+
selectedMessageTable = await createMessageTable(selectedDate, live)
849850
div.appendChild(selectedMessageTable)
850851
earliest.messageTable = selectedMessageTable
851852
latest.messageTable = selectedMessageTable

src/chat/thread.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export function thread (dom, kb, subject, messageStore, options) {
249249
})
250250
}
251251

252-
var addMessage = function (message) {
252+
const addMessage = function (message) {
253253
const bindings = {
254254
'?msg': message,
255255
'?creator': kb.any(message, ns.foaf('maker')),
@@ -259,7 +259,7 @@ export function thread (dom, kb, subject, messageStore, options) {
259259
renderMessage(bindings, true) // fresh from elsewhere
260260
}
261261

262-
var renderMessage = function (bindings, fresh) {
262+
const renderMessage = function (bindings, fresh) {
263263
const creator = bindings['?creator']
264264
const message = bindings['?msg']
265265
const date = bindings['?date']
@@ -329,7 +329,7 @@ export function thread (dom, kb, subject, messageStore, options) {
329329
},
330330
false
331331
)
332-
var sureButton = dom.createElement('button')
332+
const sureButton = dom.createElement('button')
333333
sureButton.textContent = 'Delete message'
334334
td3.appendChild(sureButton).addEventListener(
335335
'click',

src/folders.js

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { store } from './logic'
1010
import * as ns from './ns'
1111
import * as rdf from 'rdflib' // pull in first avoid cross-refs
1212
import * as style from './style'
13-
import * as utils from './utils'
1413
import * as widgets from './widgets'
1514

1615
const UI = { authn, icons, ns, rdf, store, style, widgets }

src/messageArea.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function messageArea (dom, kb, subject, messageStore, options) {
241241
})
242242
}
243243

244-
var addMessage = function (message) {
244+
const addMessage = function (message) {
245245
const bindings = {
246246
'?msg': message,
247247
'?creator': kb.any(message, ns.foaf('maker')),
@@ -251,7 +251,7 @@ export function messageArea (dom, kb, subject, messageStore, options) {
251251
renderMessage(bindings, true) // fresh from elsewhere
252252
}
253253

254-
var renderMessage = function (bindings, fresh) {
254+
const renderMessage = function (bindings, fresh) {
255255
const creator = bindings['?creator']
256256
const message = bindings['?msg']
257257
const date = bindings['?date']
@@ -321,7 +321,7 @@ export function messageArea (dom, kb, subject, messageStore, options) {
321321
},
322322
false
323323
)
324-
var sureButton = dom.createElement('button')
324+
const sureButton = dom.createElement('button')
325325
sureButton.textContent = 'Delete message'
326326
td3.appendChild(sureButton).addEventListener(
327327
'click',

src/table.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
// 2014 Core table widget moved into common/table.js - timbl
1414
//
1515

16-
import { authn } from './authn/index'
1716
import * as debug from './debug'
1817
import { icons } from './iconBase'
1918
import { store } from './logic'
2019
import * as log from './log'
2120
import * as ns from './ns'
2221
import * as rdf from 'rdflib' // pull in first avoid cross-refs
23-
import * as style from './style'
2422
import * as utils from './utils'
2523
import * as widgets from './widgets'
2624

@@ -109,8 +107,9 @@ export function renderTableViewPane (doc, options) {
109107
}
110108

111109
// A specifically asked-for query
110+
let table
112111
if (givenQuery) {
113-
var table = renderTableForQuery(givenQuery)
112+
table = renderTableForQuery(givenQuery)
114113
// lastQuery = givenQuery
115114
tableDiv.appendChild(table)
116115
} else {
@@ -1440,7 +1439,7 @@ export function renderTableViewPane (doc, options) {
14401439
for (let i = 0; i < columns.length; ++i) {
14411440
const column = columns[i]
14421441
const td = doc.createElement('td')
1443-
var orig
1442+
let orig
14441443

14451444
const columnKey = column.getKey()
14461445

src/widgets/buttons.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { linkIcon, createLinkForURI } from './buttons/iconLinks'
2121

2222
/* global alert */
2323

24-
const { iconBase, originalIconBase } = icons
24+
const { iconBase } = icons
2525

2626
const cancelIconURI = iconBase + 'noun_1180156.svg' // black X
2727
const checkIconURI = iconBase + 'noun_1180158.svg' // green checkmark; Continue

src/widgets/forms.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,9 @@ export function makeDescription (
12171217
}
12181218

12191219
const editable = kb.updater.editable(dataDoc.uri)
1220+
let submit
12201221
if (editable) {
1221-
var submit = widgets.continueButton(dom, saveChange)
1222+
submit = widgets.continueButton(dom, saveChange)
12221223
submit.disabled = true // until the filled has been modified
12231224
submit.style.visibility = 'hidden'
12241225
submit.style.float = 'right'
@@ -1293,7 +1294,7 @@ export function makeSelectForOptions (
12931294
return errorMessageBlock(dom, "Selector: can't mint new with no subform.")
12941295
}
12951296
log.debug('makeSelectForOptions: dataDoc=' + dataDoc)
1296-
1297+
let actual
12971298
const getActual = function () {
12981299
actual = {}
12991300
if (predicate.sameTerm(ns.rdf('type'))) {
@@ -1305,7 +1306,7 @@ export function makeSelectForOptions (
13051306
}
13061307
return actual
13071308
}
1308-
var actual = getActual()
1309+
actual = getActual()
13091310

13101311
const onChange = function (_e) {
13111312
select.disabled = true // until data written back - gives user feedback too
@@ -1316,10 +1317,10 @@ export function makeSelectForOptions (
13161317
ds.push($rdf.st(subject, predicate, t, dataDoc))
13171318
}
13181319
}
1320+
let newObject
13191321
for (let i = 0; i < select.options.length; i++) {
13201322
const opt = select.options[i]
13211323
if (opt.selected && opt.AJAR_mint) {
1322-
var newObject
13231324
if (options.mintClass) {
13241325
const thisForm = promptForNew(
13251326
dom,

src/widgets/forms/autocomplete/autocompleteField.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function autocompleteField (
7373
callbackFunction(true, '')
7474
}
7575

76-
async function deleteOne (result:NamedNode | Literal, name: Literal) {
76+
async function deleteOne (_result:NamedNode | Literal, _name: Literal) {
7777
const oldValue = kb.the(subject, property as any, null, doc)
7878
if (!oldValue) {
7979
callbackFunction(false, 'NO data to elete')

src/widgets/forms/autocomplete/autocompletePicker.ts

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { filterByLanguage, getPreferredLanguages, defaultPreferedLangages } from
1414
const AUTOCOMPLETE_THRESHOLD = 4 // don't check until this many characters typed
1515
const AUTOCOMPLETE_ROWS = 20 // 20?
1616
const AUTOCOMPLETE_ROWS_STRETCH = 40
17-
const AUTOCOMPLETE_DEBOUNCE_MS = 300
1817

1918
/*
2019
Autocomplete happens in 6 phases:
@@ -271,7 +270,6 @@ export async function renderAutoComplete (dom: HTMLDocument,
271270
// var candidatesLoaded = false
272271
let lastBindings
273272
let loadedEnough = false
274-
const runningTimeout = undefined as any
275273
let inputEventHandlerLock = false
276274
let allDisplayed = false
277275
let lastFilter = undefined as (string | undefined)

src/widgets/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*/
1212
/* eslint-disable no-console */
1313

14-
import * as debug from '../debug'
15-
1614
// Each widget should ideally live in its own file. In order to break up this
1715
// monolithic widget index over time, we should add new widgets to the
1816
// 'lib/widgets/' directory, and re-export them by merging the module namespaces:

test/unit/widgets/buttons/iconLink.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { silenceDebugMessages } from '../../../helpers/setup'
22
import { JSDOM, DOMWindow } from 'jsdom'
3-
import { sym, NamedNode } from 'rdflib'
3+
import { NamedNode } from 'rdflib'
44
import {
55
linkIcon,
66
createLinkForURI

test/unit/widgets/forms/autocomplete/__snapshots__/autocomplete.test.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ exports[`autocompleteField on inpt fetches data (fixing wikidata timeout issue)
223223
<tr
224224
style="padding: 0.3em; color: rgb(0, 136, 0);"
225225
>
226-
abbazia di San Massimino
226+
abbazia di Sant'Angelo in Massa
227227
</tr>
228228
<tr
229229
style="padding: 0.3em; color: rgb(0, 136, 0);"
230230
>
231-
abbazia di Sant'Angelo in Massa
231+
abbazia di San Massimino
232232
</tr>
233233
<tr
234234
style="padding: 0.3em; color: rgb(0, 136, 0);"

test/unit/widgets/forms/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { silenceDebugMessages } from '../../../helpers/setup'
2-
import { namedNode, graph } from 'rdflib'
2+
import { namedNode } from 'rdflib'
33
import * as ns from '../../../../src/ns'
4-
import { solidLogicSingleton, store, kb } from '../../../../src/logic'
4+
import { kb } from '../../../../src/logic'
55

66
// console.log('@@ solidLogicSingleton', solidLogicSingleton)
77
// @ts-ignore

0 commit comments

Comments
 (0)