Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tests and linter #421

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
],
"rules": {
"no-console": "error",
"complexity": ["warn", 15],
"no-unused-vars": ["warn", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["warn", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
Expand Down
2 changes: 0 additions & 2 deletions src/acl/access-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import { graph, NamedNode, UpdateManager } from 'rdflib'
import { AccessGroups } from './access-groups'
import { DataBrowserContext } from 'pane-registry'
import { shortNameForFolder } from './acl-control'
import { currentUser } from '../authn/authn'
import * as utils from '../utils'
import * as debug from '../debug'
import ns from '../ns'

/**
* Rendered HTML component used in the databrowser's Sharing pane.
Expand Down
10 changes: 3 additions & 7 deletions src/authn/authn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,16 @@ export async function findAppInstances (
} catch (err) {
}
const index = context.index as { [key: string]: Array<NamedNode> }
// eslint-disable-next-line no-console
console.log({ index, visibility })
const thisIndex = index[visibility]
// eslint-disable-next-line no-console
console.log('Failing test?', thisIndex.map(ix => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix)))
const registrations = thisIndex
.map(ix => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix))
.flat()
.reduce((acc, curr) => acc.concat(curr), [])
const instances = registrations
.map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instance')))
.flat()
.reduce((acc, curr) => acc.concat(curr), [])
const containers = registrations
.map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instanceContainer')))
.flat()
.reduce((acc, curr) => acc.concat(curr), [])

function unique (arr: NamedNode[]): NamedNode[] {
return Array.from(new Set(arr))
Expand Down
3 changes: 2 additions & 1 deletion src/chat/infinite.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,10 @@ export async function infiniteMessageArea (dom, kb, chatChannel, options) {
const todayDocument = dateFolder.leafDocumentFromDate(now)
live = todayDocument.sameTerm(selectedDocument)
}
let selectedMessageTable
if (options.selectedMessage && !live) {
const selectedDate = dateFolder.dateFromLeafDocument(selectedDocument)
var selectedMessageTable = await createMessageTable(selectedDate, live)
selectedMessageTable = await createMessageTable(selectedDate, live)
div.appendChild(selectedMessageTable)
earliest.messageTable = selectedMessageTable
latest.messageTable = selectedMessageTable
Expand Down
6 changes: 3 additions & 3 deletions src/chat/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export function thread (dom, kb, subject, messageStore, options) {
})
}

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

var renderMessage = function (bindings, fresh) {
const renderMessage = function (bindings, fresh) {
const creator = bindings['?creator']
const message = bindings['?msg']
const date = bindings['?date']
Expand Down Expand Up @@ -329,7 +329,7 @@ export function thread (dom, kb, subject, messageStore, options) {
},
false
)
var sureButton = dom.createElement('button')
const sureButton = dom.createElement('button')
sureButton.textContent = 'Delete message'
td3.appendChild(sureButton).addEventListener(
'click',
Expand Down
1 change: 0 additions & 1 deletion src/folders.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { store } from './logic'
import * as ns from './ns'
import * as rdf from 'rdflib' // pull in first avoid cross-refs
import * as style from './style'
import * as utils from './utils'
import * as widgets from './widgets'

const UI = { authn, icons, ns, rdf, store, style, widgets }
Expand Down
6 changes: 3 additions & 3 deletions src/messageArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function messageArea (dom, kb, subject, messageStore, options) {
})
}

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

var renderMessage = function (bindings, fresh) {
const renderMessage = function (bindings, fresh) {
const creator = bindings['?creator']
const message = bindings['?msg']
const date = bindings['?date']
Expand Down Expand Up @@ -321,7 +321,7 @@ export function messageArea (dom, kb, subject, messageStore, options) {
},
false
)
var sureButton = dom.createElement('button')
const sureButton = dom.createElement('button')
sureButton.textContent = 'Delete message'
td3.appendChild(sureButton).addEventListener(
'click',
Expand Down
7 changes: 3 additions & 4 deletions src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
// 2014 Core table widget moved into common/table.js - timbl
//

import { authn } from './authn/index'
import * as debug from './debug'
import { icons } from './iconBase'
import { store } from './logic'
import * as log from './log'
import * as ns from './ns'
import * as rdf from 'rdflib' // pull in first avoid cross-refs
import * as style from './style'
import * as utils from './utils'
import * as widgets from './widgets'

Expand Down Expand Up @@ -109,8 +107,9 @@ export function renderTableViewPane (doc, options) {
}

// A specifically asked-for query
let table
if (givenQuery) {
var table = renderTableForQuery(givenQuery)
table = renderTableForQuery(givenQuery)
// lastQuery = givenQuery
tableDiv.appendChild(table)
} else {
Expand Down Expand Up @@ -1440,7 +1439,7 @@ export function renderTableViewPane (doc, options) {
for (let i = 0; i < columns.length; ++i) {
const column = columns[i]
const td = doc.createElement('td')
var orig
let orig

const columnKey = column.getKey()

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { linkIcon, createLinkForURI } from './buttons/iconLinks'

/* global alert */

const { iconBase, originalIconBase } = icons
const { iconBase } = icons

const cancelIconURI = iconBase + 'noun_1180156.svg' // black X
const checkIconURI = iconBase + 'noun_1180158.svg' // green checkmark; Continue
Expand Down
9 changes: 5 additions & 4 deletions src/widgets/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,9 @@ export function makeDescription (
}

const editable = kb.updater.editable(dataDoc.uri)
let submit
if (editable) {
var submit = widgets.continueButton(dom, saveChange)
submit = widgets.continueButton(dom, saveChange)
submit.disabled = true // until the filled has been modified
submit.style.visibility = 'hidden'
submit.style.float = 'right'
Expand Down Expand Up @@ -1293,7 +1294,7 @@ export function makeSelectForOptions (
return errorMessageBlock(dom, "Selector: can't mint new with no subform.")
}
log.debug('makeSelectForOptions: dataDoc=' + dataDoc)

let actual
const getActual = function () {
actual = {}
if (predicate.sameTerm(ns.rdf('type'))) {
Expand All @@ -1305,7 +1306,7 @@ export function makeSelectForOptions (
}
return actual
}
var actual = getActual()
actual = getActual()

const onChange = function (_e) {
select.disabled = true // until data written back - gives user feedback too
Expand All @@ -1316,10 +1317,10 @@ export function makeSelectForOptions (
ds.push($rdf.st(subject, predicate, t, dataDoc))
}
}
let newObject
for (let i = 0; i < select.options.length; i++) {
const opt = select.options[i]
if (opt.selected && opt.AJAR_mint) {
var newObject
if (options.mintClass) {
const thisForm = promptForNew(
dom,
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/forms/autocomplete/autocompleteField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function autocompleteField (
callbackFunction(true, '')
}

async function deleteOne (result:NamedNode | Literal, name: Literal) {
async function deleteOne (_result:NamedNode | Literal, _name: Literal) {
const oldValue = kb.the(subject, property as any, null, doc)
if (!oldValue) {
callbackFunction(false, 'NO data to elete')
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/forms/autocomplete/autocompletePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { filterByLanguage, getPreferredLanguages, defaultPreferedLangages } from
const AUTOCOMPLETE_THRESHOLD = 4 // don't check until this many characters typed
const AUTOCOMPLETE_ROWS = 20 // 20?
const AUTOCOMPLETE_ROWS_STRETCH = 40
const AUTOCOMPLETE_DEBOUNCE_MS = 300

/*
Autocomplete happens in 6 phases:
Expand Down Expand Up @@ -271,7 +270,6 @@ export async function renderAutoComplete (dom: HTMLDocument,
// var candidatesLoaded = false
let lastBindings
let loadedEnough = false
const runningTimeout = undefined as any
let inputEventHandlerLock = false
let allDisplayed = false
let lastFilter = undefined as (string | undefined)
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*/
/* eslint-disable no-console */

import * as debug from '../debug'

// Each widget should ideally live in its own file. In order to break up this
// monolithic widget index over time, we should add new widgets to the
// 'lib/widgets/' directory, and re-export them by merging the module namespaces:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/widgets/buttons/iconLink.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { silenceDebugMessages } from '../../../helpers/setup'
import { JSDOM, DOMWindow } from 'jsdom'
import { sym, NamedNode } from 'rdflib'
import { NamedNode } from 'rdflib'
import {
linkIcon,
createLinkForURI
Expand Down
4 changes: 2 additions & 2 deletions test/unit/widgets/forms/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { silenceDebugMessages } from '../../../helpers/setup'
import { namedNode, graph } from 'rdflib'
import { namedNode } from 'rdflib'
import * as ns from '../../../../src/ns'
import { solidLogicSingleton, store, kb } from '../../../../src/logic'
import { kb } from '../../../../src/logic'

// console.log('@@ solidLogicSingleton', solidLogicSingleton)
// @ts-ignore
Expand Down