Skip to content

Commit

Permalink
style: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Sep 24, 2022
1 parent f4655e7 commit 9c7aa6c
Show file tree
Hide file tree
Showing 40 changed files with 361 additions and 355 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"semi": false,
"singleQuote": true
"singleQuote": true,
"trailingComma" : "none"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"build:workspaces": "npm run build --workspaces --if-present",
"build-declaration": "tsc --declaration --allowJs false",
"watch": "npm run build -- -w",
"prettier": "prettier -w src/",
"lint": "eslint -c .eslintrc.js --ext .ts --ext .js --fix src/",
"ci-lint": "eslint -c .eslintrc.js --ext .ts --ext .js src/",
"format": "npm run prettier && npm run lint",
"ci-lint": "eslint -c .eslintrc.js --ext .ts --ext .js src/ && npm run prettier src/",
"prepublishOnly": "npm run lint && npm run build:all && npm run build-declaration",
"update-latest-release": "git checkout master && git branch -D latest-release || git checkout -b latest-release && git push -f origin/latest-release",
"start": "node bin/signalk-server",
Expand Down
2 changes: 1 addition & 1 deletion src/@types/baconjs.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module 'baconjs'
declare module 'baconjs'
18 changes: 9 additions & 9 deletions src/@types/signalk_signalk-schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module '@signalk/signalk-schema' {
import { EventEmitter } from 'events'
import { EventEmitter } from 'events'

export function getSourceId(source: any): string
export class FullSignalK extends EventEmitter {
constructor(selfId: string, selfType: string, defaults?: any)
addDelta: (_: any) => void
retrieve: () => any
pruneContexts: () => void
}
}
export function getSourceId(source: any): string
export class FullSignalK extends EventEmitter {
constructor(selfId: string, selfType: string, defaults?: any)
addDelta: (_: any) => void
retrieve: () => any
pruneContexts: () => void
}
}
2 changes: 1 addition & 1 deletion src/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getCategories(thePackage: NpmPackageData): string[] {
)
}
const categoryNames = categoryKeywords.map(
category => CAT_KEYWORDS_TO_NAMES[category]
(category) => CAT_KEYWORDS_TO_NAMES[category]
)

if (categoryNames.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const { isUndefined } = require('lodash')

module.exports = function(app) {
module.exports = function (app) {
'use strict'

if (app.get('env') === 'development') {
Expand Down
2 changes: 1 addition & 1 deletion src/config/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const appModules = addModules(appPath)
const getAppPath = get('config.appPath')

// Build path to the public dir of a module. getInstalledPathSync(moduleName, { local: true })
const getModulePublic = moduleName =>
const getModulePublic = (moduleName) =>
flow(getAppPath, addModules, partialRight(path.join, [moduleName, 'public']))

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion src/config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const { isUndefined } = require('lodash')

module.exports = function(app) {
module.exports = function (app) {
'use strict'

if (app.get('env') === 'production') {
Expand Down
8 changes: 4 additions & 4 deletions src/deltacache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class DeltaCache {

constructor(app: SignalKServer, streambundle: StreamBundle) {
this.app = app
streambundle.keys.onValue(key => {
streambundle.keys.onValue((key) => {
streambundle.getBus(key).onValue(this.onValue.bind(this))
})
}
Expand All @@ -67,7 +67,7 @@ export default class DeltaCache {
if (msg.path.length !== 0) {
leaf[sourceRef] = msg
} else if (msg.value) {
_.keys(msg.value).forEach(key => {
_.keys(msg.value).forEach((key) => {
if (!leaf[key]) {
leaf[key] = {}
}
Expand Down Expand Up @@ -155,8 +155,8 @@ export default class DeltaCache {

getCachedDeltas(contextFilter: ContextMatcher, user?: string, key?: string) {
const contexts: any[] = []
_.keys(this.cache).forEach(type => {
_.keys(this.cache[type]).forEach(id => {
_.keys(this.cache).forEach((type) => {
_.keys(this.cache[type]).forEach((id) => {
const context = `${type}.${id}`
if (contextFilter({ context })) {
contexts.push(this.cache[type][id])
Expand Down
18 changes: 9 additions & 9 deletions src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const dgram = require('dgram')
const mdns = require('mdns-js')
const { networkInterfaces } = require('os')

module.exports.runDiscovery = function(app) {
module.exports.runDiscovery = function (app) {
if (canboatjs.discover) {
try {
canboatjs.discover(app)
Expand All @@ -36,7 +36,7 @@ module.exports.runDiscovery = function(app) {
discoverSignalkWs('wss')

function findUDPProvider(port) {
return app.config.settings.pipedProviders.find(provider => {
return app.config.settings.pipedProviders.find((provider) => {
return (
provider.pipeElements &&
provider.pipeElements.length === 1 &&
Expand All @@ -50,7 +50,7 @@ module.exports.runDiscovery = function(app) {
}

function findTCPProvider(host, port) {
return app.config.settings.pipedProviders.find(provider => {
return app.config.settings.pipedProviders.find((provider) => {
return (
provider.pipeElements &&
provider.pipeElements.length === 1 &&
Expand All @@ -65,7 +65,7 @@ module.exports.runDiscovery = function(app) {
}

function findWSProvider(ip, wsType, host, port) {
return app.config.settings.pipedProviders.find(provider => {
return app.config.settings.pipedProviders.find((provider) => {
return (
provider.pipeElements &&
provider.pipeElements.length === 1 &&
Expand All @@ -84,14 +84,14 @@ module.exports.runDiscovery = function(app) {
function discoverGoFree() {
const socket = dgram.createSocket('udp4')
const found = []
socket.on('message', function(buffer, remote) {
socket.on('message', function (buffer, remote) {
const msg = buffer.toString('utf8')
if (msg[0] === '{') {
try {
const json = JSON.parse(msg)
const serial = json.SerialNumber
if (json.Services && found.indexOf(serial) === -1) {
json.Services.forEach(service => {
json.Services.forEach((service) => {
if (
service.Service === 'nmea-0183' &&
!findTCPProvider(json.IP, service.Port)
Expand Down Expand Up @@ -124,7 +124,7 @@ module.exports.runDiscovery = function(app) {
}
}
})
socket.on('error', error => {
socket.on('error', (error) => {
debug('discoverGoFree:', error)
})
socket.on('close', () => {
Expand Down Expand Up @@ -152,7 +152,7 @@ module.exports.runDiscovery = function(app) {
function discoverWLN10() {
if (!findUDPProvider('2000')) {
let socket = dgram.createSocket('udp4')
socket.on('message', function(buffer, remote) {
socket.on('message', function (buffer, remote) {
const msg = buffer.toString('utf8')
if (msg[0] === '$') {
socket.close()
Expand All @@ -174,7 +174,7 @@ module.exports.runDiscovery = function(app) {
})
}
})
socket.on('error', error => {
socket.on('error', (error) => {
debug('discoverWLN10:', error)
})
socket.on('close', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/dummysecurity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/* tslint:disable */

export default function() {
export default function () {
return {
getConfiguration: () => {
return {}
Expand Down Expand Up @@ -69,11 +69,11 @@ export default function() {

deleteUser: (_config: any, _username: any, _callback: any) => {},

shouldAllowWrite: function(_req: any, _delta: any) {
shouldAllowWrite: function (_req: any, _delta: any) {
return true
},

shouldAllowPut: function(
shouldAllowPut: function (
_req: any,
_context: any,
_source: any,
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class Server {
debug('ID type: ' + app.selfType)
debug('ID: ' + app.selfId)

sendBaseDeltas((app as unknown) as ConfigApp)
sendBaseDeltas(app as unknown as ConfigApp)

startInterfaces(app)
startMdns(app)
Expand Down Expand Up @@ -415,10 +415,10 @@ class Server {
this.app.config.settings = settings
}

this.stop().catch(e => console.error(e))
this.stop().catch((e) => console.error(e))

setTimeout(() => {
self.start().catch(e => console.error(e))
self.start().catch((e) => console.error(e))
}, 1000)

return this
Expand All @@ -440,11 +440,11 @@ class Server {
}
})

this.app.intervals.forEach(interval => {
this.app.intervals.forEach((interval) => {
clearInterval(interval)
})

this.app.providers.forEach(providerHolder => {
this.app.providers.forEach((providerHolder) => {
providerHolder.pipeElements[0].end()
})

Expand Down
10 changes: 5 additions & 5 deletions src/interfaces/applicationData.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const userApplicationDataUrls = [
`${prefix}/user/:appid/:version`
]

module.exports = function(app) {
module.exports = function (app) {
if (app.securityStrategy.isDummy()) {
debug('ApplicationData disabled because security is off')

Expand All @@ -49,11 +49,11 @@ module.exports = function(app) {
return
}

applicationDataUrls.forEach(url => {
applicationDataUrls.forEach((url) => {
app.securityStrategy.addAdminWriteMiddleware(url)
})

userApplicationDataUrls.forEach(url => {
userApplicationDataUrls.forEach((url) => {
app.securityStrategy.addWriteMiddleware(url)
})

Expand Down Expand Up @@ -96,7 +96,7 @@ module.exports = function(app) {
return
}

res.json(fs.readdirSync(dir).map(file => file.slice(0, -5)))
res.json(fs.readdirSync(dir).map((file) => file.slice(0, -5)))
}

function getApplicationData(req, res, isUser) {
Expand Down Expand Up @@ -161,7 +161,7 @@ module.exports = function(app) {
applicationData = req.body
}

saveApplicationData(req, appid, version, isUser, applicationData, err => {
saveApplicationData(req, appid, version, isUser, applicationData, (err) => {
if (err) {
console.log(err)
res.status(500).send(err.message)
Expand Down
Loading

0 comments on commit 9c7aa6c

Please sign in to comment.