Permalink
Browse files

Linting pass

  • Loading branch information...
pfrazee committed Oct 1, 2017
1 parent c9def77 commit 3b2acd66e39c60fae6db04105846dec58e2974d8
Showing with 163 additions and 322 deletions.
  1. +8 −8 .eslintrc
  2. +0 −1 app/background-process/browser.js
  3. +1 −1 app/background-process/dbs/apps.js
  4. +0 −1 app/background-process/dbs/archives.js
  5. +1 −1 app/background-process/dbs/sitedata.js
  6. +1 −1 app/background-process/networks/dat/garbage-collector.js
  7. +0 −6 app/background-process/networks/dat/library.js
  8. +2 −5 app/background-process/protocols/app.js
  9. +4 −3 app/background-process/protocols/dat.js
  10. +0 −1 app/background-process/web-apis.js
  11. +0 −1 app/background-process/web-apis/apps.js
  12. +3 −27 app/background-process/web-apis/archives.js
  13. +1 −5 app/background-process/web-apis/bookmarks.js
  14. +7 −8 app/background-process/web-apis/dat-archive.js
  15. +2 −2 app/background-process/web-apis/profiles.js
  16. +0 −3 app/builtin-pages/com/crop-popup.js
  17. +2 −3 app/builtin-pages/com/downloads-list.js
  18. +2 −0 app/builtin-pages/com/edit-app-popup.js
  19. +0 −1 app/builtin-pages/com/edit-bookmark-popup.js
  20. +15 −16 app/builtin-pages/com/files-columns-view.js
  21. +2 −7 app/builtin-pages/com/files-list-header.js
  22. +0 −12 app/builtin-pages/com/files-list-sidebar.js
  23. +16 −17 app/builtin-pages/com/files-list.js
  24. +1 −1 app/builtin-pages/com/img-with-fallbacks.js
  25. +0 −1 app/builtin-pages/icon/avatar.js
  26. +0 −1 app/builtin-pages/icon/box.js
  27. +0 −1 app/builtin-pages/icon/close.js
  28. +0 −1 app/builtin-pages/icon/file-o.js
  29. +0 −1 app/builtin-pages/icon/file-text-o.js
  30. +0 −1 app/builtin-pages/icon/filesystem.js
  31. +0 −1 app/builtin-pages/icon/folder-color.js
  32. +0 −1 app/builtin-pages/icon/folder.js
  33. +0 −1 app/builtin-pages/icon/gear.js
  34. +0 −1 app/builtin-pages/icon/globe.js
  35. +0 −1 app/builtin-pages/icon/grid.js
  36. +0 −1 app/builtin-pages/icon/heart.js
  37. +0 −1 app/builtin-pages/icon/history.js
  38. +0 −1 app/builtin-pages/icon/home-grayscale.js
  39. +0 −1 app/builtin-pages/icon/home.js
  40. +0 −1 app/builtin-pages/icon/list-expanded.js
  41. +0 −1 app/builtin-pages/icon/list.js
  42. +0 −2 app/builtin-pages/icon/network.js
  43. +0 −1 app/builtin-pages/icon/news.js
  44. +0 −1 app/builtin-pages/icon/padlock.js
  45. +0 −1 app/builtin-pages/icon/pencil.js
  46. +0 −1 app/builtin-pages/icon/photos.js
  47. +0 −1 app/builtin-pages/icon/pin.js
  48. +0 −1 app/builtin-pages/icon/replies.js
  49. +0 −1 app/builtin-pages/icon/restore.js
  50. +0 −1 app/builtin-pages/icon/rss.js
  51. +0 −1 app/builtin-pages/icon/search.js
  52. +0 −1 app/builtin-pages/icon/star-fill.js
  53. +0 −1 app/builtin-pages/icon/star.js
  54. +0 −1 app/builtin-pages/icon/three-dots.js
  55. +0 −1 app/builtin-pages/icon/trash-grayscale.js
  56. +0 −1 app/builtin-pages/icon/trash.js
  57. +0 −1 app/builtin-pages/icon/videos.js
  58. +6 −18 app/builtin-pages/views/bookmarks.js
  59. +1 −1 app/builtin-pages/views/create-archive-modal.js
  60. +1 −1 app/builtin-pages/views/fork-archive-modal.js
  61. +1 −8 app/builtin-pages/views/history.js
  62. +3 −1 app/builtin-pages/views/install-modal.js
  63. +15 −11 app/builtin-pages/views/library.js
  64. +3 −5 app/builtin-pages/views/profile.js
  65. +1 −1 app/builtin-pages/views/select-archive-modal.js
  66. +5 −9 app/builtin-pages/views/settings.js
  67. +1 −29 app/builtin-pages/views/start.js
  68. +8 −8 app/builtin-pages/views/timeline.js
  69. +2 −3 app/builtin-pages/views/view-source.js
  70. +1 −1 app/lib/const.js
  71. +4 −4 app/lib/fg/archive-progress-monitor.js
  72. +2 −0 app/lib/fg/event-handlers.js
  73. +12 −12 app/lib/fg/progress-pie-svg.js
  74. +3 −3 app/lib/fg/svg.js
  75. +1 −1 app/lib/perms.js
  76. +4 −0 app/lib/strings.js
  77. +2 −2 app/lib/web-apis/dat-archive.js
  78. +3 −3 app/shell-window/pages.js
  79. +0 −1 app/shell-window/ui.js
  80. +0 −1 app/shell-window/ui/icon/close.js
  81. +0 −1 app/shell-window/ui/icon/nav-arrow.js
  82. +0 −1 app/shell-window/ui/icon/padlock.js
  83. +0 −1 app/shell-window/ui/icon/refresh.js
  84. +1 −3 app/shell-window/ui/navbar.js
  85. +2 −2 app/shell-window/ui/navbar/bookmark-menu.js
  86. +1 −6 app/shell-window/ui/navbar/browser-menu.js
  87. +2 −3 app/shell-window/ui/navbar/datsite-menu.js
  88. +6 −6 app/shell-window/ui/navbar/page-menu.js
  89. +1 −8 app/shell-window/ui/navbar/site-info.js
  90. +1 −1 app/shell-window/ui/navbar/updates.js
  91. +1 −1 app/shell-window/webview-async.js
  92. +1 −1 app/webview-preload/exit-full-screen-hackfix.js
@@ -30,7 +30,7 @@
"accessor-pairs": "error",
"arrow-spacing": ["error", { "before": true, "after": true }],
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"brace-style": ["off", "1tbs", { "allowSingleLine": true }],
"camelcase": "off",
"comma-dangle": ["error", {
"arrays": "never",
@@ -44,7 +44,7 @@
"constructor-super": "error",
"curly": ["error", "multi-line"],
"dot-location": ["error", "property"],
"eol-last": "error",
"eol-last": "off",
"eqeqeq": "off",
"func-call-spacing": ["error", "never"],
"generator-star-spacing": ["error", { "before": true, "after": true }],
@@ -97,7 +97,7 @@
"allowSamePrecedence": true
}],
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
"no-negated-in-lhs": "error",
@@ -130,7 +130,7 @@
"no-undef-init": "error",
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
"no-unneeded-ternary": ["off", { "defaultAssignment": false }],
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
@@ -147,7 +147,7 @@
"no-with": "error",
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
"one-var": ["error", { "initialized": "never" }],
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" } }],
"operator-linebreak": ["off", "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": ["error", { "blocks": "never", "switches": "never", "classes": "never" }],
"prefer-promise-reject-errors": "off",
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
@@ -157,9 +157,9 @@
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-infix-ops": "off",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"spaced-comment": ["error", "always", {
"spaced-comment": ["off", "always", {
"line": { "markers": ["*package", "!", "/", ","] },
"block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] }
}],
@@ -181,7 +181,7 @@
"node/no-deprecated-api": "error",
"node/process-exit-as-throw": "error",
"promise/param-names": "error",
"promise/param-names": "off",
"standard/array-bracket-even-spacing": ["error", "either"],
"standard/computed-property-even-spacing": ["error", "even"],
@@ -2,7 +2,6 @@ import {app, dialog, autoUpdater, BrowserWindow, webContents, ipcMain, shell, Me
import os from 'os'
import path from 'path'
import fs from 'fs'
import jetpack from 'fs-jetpack'
import emitStream from 'emit-stream'
import EventEmitter from 'events'
var debug = require('debug')('beaker')
@@ -29,5 +29,5 @@ export function unbind (profileId, name) {
}
export function unbindUrlFromAllNames (profileId, url) {
return db.run(`DELETE FROM apps WHERE profileId = ? AND url = ?`, [profileId, url])
return db.run(`DELETE FROM apps WHERE profileId = ? AND url = ?`, [profileId, url])
}
@@ -125,7 +125,6 @@ export async function query (profileId, query) {
// get all archives that should be unsaved
export async function listExpiredArchives () {
var now = Date.now()
return db.all(`
SELECT archives.key
FROM archives

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -28,7 +28,7 @@ export async function collect ({olderThan} = {}) {
for (let i = 0; i < unusedArchives.length; i++) {
await archivesDb.deleteArchive(unusedArchives[i].key)
}
debug('GC completed in %d ms', Date.now() - startTime)
schedule(DAT_GC_REGULAR_COLLECT_WAIT)
}
@@ -1,12 +1,10 @@
import {app} from 'electron'
import crypto from 'crypto'
import emitStream from 'emit-stream'
import EventEmitter from 'events'
import datEncoding from 'dat-encoding'
import pify from 'pify'
import pda from 'pauls-dat-api'
import signatures from 'sodium-signatures'
import slugify from 'slugify'
var debug = require('debug')('dat')
import * as siteData from '../../dbs/sitedata'
import {throttle, debounce} from '../../../lib/functions'
@@ -22,10 +20,7 @@ import swarmDefaults from 'datland-swarm-defaults'
import discoverySwarm from 'discovery-swarm'
// file modules
import path from 'path'
import mkdirp from 'mkdirp'
import jetpack from 'fs-jetpack'
const du = pify(require('du'))
// constants
// =
@@ -177,7 +172,6 @@ export async function forkArchive (srcArchiveUrl, manifest = {}, settings = fals
var srcManifest = await pda.readManifest(srcArchive).catch(_ => {})
srcManifest = srcManifest || {}
// override any manifest data
var dstManifest = {
title: (manifest.title) ? manifest.title : srcManifest.title,
@@ -78,7 +78,7 @@ export function setup () {
// create the internal app HTTP server
var server = http.createServer(appServer)
listenRandomPort(server, { host: '127.0.0.1' }, (err, port) => serverPort = port)
listenRandomPort(server, { host: '127.0.0.1' }, (err, port) => { serverPort = port })
}
// internal methods
@@ -101,7 +101,6 @@ async function appServer (req, res) {
})
try {
// read the parameters
const {requestUrl, bindingUrl, nonce} = url.parse(req.url, true).query
const requestUrlParsed = url.parse(requestUrl)
@@ -130,7 +129,7 @@ async function appServer (req, res) {
if (!stat) {
return cb(404, 'Not Found')
}
// check for an index.html
if (stat.isDirectory) {
let requestPathname2 = path.join(requestPathname, 'index.html')
@@ -201,7 +200,6 @@ async function appServer (req, res) {
fileReadStream.once('error', err => {
if (!headersSent) cb(500, 'Failed to read file')
})
} catch (e) {
cb(500, e.toString())
}
@@ -231,7 +229,6 @@ const styles = `<style>
async function renderDirectoryListingPage (scopedFS, dirPath, names) {
// stat each file
var entries = await Promise.all(names.map(async (name) => {
var entry
var entryPath = path.join(dirPath, name)
var entry = await new Promise(resolve => scopedFS.stat(entryPath, (err, st) => resolve(st)))
if (entry) {
@@ -15,7 +15,6 @@ import slugify from 'slugify'
import {ProtocolSetupError} from 'beaker-error-constants'
import datDns from '../networks/dat/dns'
import * as datLibrary from '../networks/dat/library'
import * as sitedataDb from '../dbs/sitedata'
import directoryListingPage from '../networks/dat/directory-listing-page'
import errorPage from '../../lib/error-page'
import * as mime from '../../lib/mime'
@@ -296,10 +295,12 @@ async function datServer (req, res) {
if (!entry) {
cleanup()
return cb(404, 'File Not Found',
{ errorDescription: 'File Not Found',
{
errorDescription: 'File Not Found',
errorInfo: `Beaker could not find the file ${urlp.path}`,
title: 'File Not Found'
})
}
)
}
}
@@ -1,4 +1,3 @@
import {ipcMain} from 'electron'
import rpc from 'pauls-electron-rpc'
import {internalOnly, secureOnly} from '../lib/bg/rpc'
@@ -1,4 +1,3 @@
import {parse as parseURL} from 'url'
import parseDatUrl from 'parse-dat-url'
import * as archivesDb from '../dbs/archives'
import * as appsDb from '../dbs/apps'
@@ -1,28 +1,17 @@
import {BrowserWindow} from 'electron'
import {parse as parseURL} from 'url'
import pda from 'pauls-dat-api'
import datDns from '../networks/dat/dns'
import * as datLibrary from '../networks/dat/library'
import * as archivesDb from '../dbs/archives'
import * as profilesIngest from '../ingests/profiles'
import {DAT_HASH_REGEX, DEFAULT_DAT_API_TIMEOUT} from '../../lib/const'
import {showModal} from '../ui/modals'
import {timer} from '../../lib/time'
import {DAT_HASH_REGEX} from '../../lib/const'
import {
ArchiveNotWritableError,
InvalidURLError,
InvalidPathError,
UserDeniedError
PermissionsError
} from 'beaker-error-constants'
// exported api
// =
const to = (opts) =>
(opts && typeof opts.timeout !== 'undefined')
? opts.timeout
: DEFAULT_DAT_API_TIMEOUT
export default {
// system state
@@ -46,7 +35,7 @@ export default {
// pull metadata
var archive = await datLibrary.getOrLoadArchive(key)
var meta = await datLibrary.pullLatestArchiveMeta(archive)
await datLibrary.pullLatestArchiveMeta(archive)
// update settings
return archivesDb.setUserSettings(0, key, {isSaved: true, expiresAt: opts.expiresAt})
@@ -129,19 +118,6 @@ export default {
}
}
async function assertSenderIsFocused (sender) {
if (!sender.isFocused()) {
throw new UserDeniedError('Application must be focused to spawn a prompt')
}
}
async function assertArchiveOfflineable (key) {
var profileRecord = await profilesIngest.getProfileRecord(0)
if ('dat://' + key === profileRecord.url) {
throw new PermissionsError('Unable to set the user archive to offline.')
}
}
async function assertArchiveDeletable (key) {
var profileRecord = await profilesIngest.getProfileRecord(0)
if ('dat://' + key === profileRecord.url) {
@@ -144,7 +144,7 @@ export default {
await assertPermission(this.sender, 'app:bookmarks:read')
var [privateTags, publicTags] = await Promise.all([
privateBookmarksDb.listBookmarkTags(0),
getAPI().listBookmarkTags(),
getAPI().listBookmarkTags()
])
return Array.from(new Set(privateTags.concat(publicTags)))
}
@@ -158,10 +158,6 @@ async function assertPermission (sender, perm) {
throw new PermissionsError()
}
function assertArchive (v, msg) {
assert(!!v && (typeof v === 'string' || typeof v.url === 'string'), msg)
}
function assertString (v, msg) {
assert(!!v && typeof v === 'string', msg)
}
@@ -106,7 +106,7 @@ export default {
},
async unlinkArchive (url) {
var {archive, filepath} = await lookupArchive(url)
var {archive} = await lookupArchive(url)
await assertDeleteArchivePermission(archive, this.sender)
await assertArchiveDeletable(archive)
await archivesDb.setUserSettings(0, archive.key, {isSaved: false})
@@ -149,7 +149,7 @@ export default {
},
async configure (url, settings, opts) {
var {archive, filepath, version} = await lookupArchive(url, opts)
var {archive, version} = await lookupArchive(url, opts)
if (version) throw new ArchiveNotWritableError('Cannot modify a historic version')
if (!settings || typeof settings !== 'object') throw new Error('Invalid argument')
var senderOrigin = archivesDb.extractOrigin(this.sender.getURL())
@@ -163,14 +163,14 @@ export default {
if (settings.networked === false) {
await assertArchiveOfflineable(archive)
}
await archivesDb.setUserSettings(0, archive.key, {networked: settings.networked})
await archivesDb.setUserSettings(0, archive.key, {networked: settings.networked})
}
},
async history (url, opts = {}) {
var reverse = opts.reverse === true
var {start, end} = opts
var {archive, version} = await lookupArchive(url, opts)
var {archive} = await lookupArchive(url, opts)
// if reversing the output, modify start/end
start = start || 0
@@ -226,7 +226,7 @@ export default {
return pda.unlink(archive, filepath)
},
async copy(url, dstPath) {
async copy (url, dstPath) {
return timer(to(), async (checkin) => {
checkin('searching for archive')
var {archive, filepath} = await lookupArchive(url)
@@ -240,12 +240,11 @@ export default {
})
},
async rename(url, dstpath) {
async rename (url, dstpath) {
return timer(to(), async (checkin) => {
checkin('searching for archive')
var {archive, filepath} = await lookupArchive(url)
if (checkin('renaming file')) return
var senderOrigin = archivesDb.extractOrigin(this.sender.getURL())
await assertWritePermission(archive, this.sender)
await assertValidFilePath(dstpath)
await assertUnprotectedFilePath(filepath, this.sender)
@@ -486,7 +485,7 @@ async function assertArchiveOfflineable (archive) {
var profileRecord = await getProfileRecord(0)
if ('dat://' + archive.key.toString('hex') === profileRecord.url) {
throw new PermissionsError('Unable to set the user archive to offline.')
}
}
}
async function assertArchiveDeletable (archive) {
@@ -67,7 +67,7 @@ export default {
assertBuffer(imgData, 'Parameter one must be an ArrayBuffer or base64-encoded string')
assertString(imgExtension, 'Parameter two must be a string')
var profileRecord = await getProfileRecord(0)
imgData = typeof imgData === 'string' ? new Buffer(imgData, 'base64') : imgData
imgData = typeof imgData === 'string' ? Buffer.from(imgData, 'base64') : imgData
await getAPI().setAvatar(profileRecord.url, imgData, imgExtension)
},
@@ -172,7 +172,7 @@ function assertObject (v, msg) {
function assertBuffer (v, msg) {
if (v && typeof v === 'string') {
try {
v = new Buffer(v, 'base64')
v = Buffer.from(v, 'base64')
} catch (e) {
throw new Error(msg)
}
@@ -1,6 +1,4 @@
import yo from 'yo-yo'
import * as toast from './toast'
import {writeToClipboard} from '../../lib/fg/event-handlers'
const CANVAS_SIZE = 256
@@ -26,7 +24,6 @@ var img
var imgWidth
var imgHeight
// exported api
// =
Oops, something went wrong.

0 comments on commit 3b2acd6

Please sign in to comment.