Skip to content

Commit

Permalink
Merge pull request #1836 from SignalK/update-typescript
Browse files Browse the repository at this point in the history
chore: update typescript
  • Loading branch information
tkurki authored Dec 8, 2024
2 parents d7aca71 + e5df925 commit 0bb173e
Show file tree
Hide file tree
Showing 28 changed files with 87 additions and 132 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true
}
]
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint']
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@
"@types/mocha": "^10.0.1",
"@types/ncp": "^2.0.5",
"@types/node-fetch": "^2.5.3",
"@types/rmfr": "^2.0.1",
"@types/semver": "^7.1.0",
"@types/serialport": "^8.0.2",
"@types/split": "^1.0.0",
"@types/swagger-ui-express": "^4.1.3",
"@types/unzipper": "^0.10.5",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"chai": "^4.0.0",
"chai-json-equal": "0.0.1",
"chai-things": "^0.2.0",
Expand All @@ -169,11 +167,10 @@
"lint-staged": "^10.0.3",
"mocha": "^10.2.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"rmfr": "^2.0.0",
"rimraf": "^6.0.1",
"ts-node": "^10.9.1",
"typedoc": "^0.23.23",
"typescript": "^4.8.3"
"typedoc": "^0.26.11",
"typescript": "5.6.x"
},
"funding": "https://opencollective.com/signalk"
}
25 changes: 0 additions & 25 deletions packages/resources-provider-plugin/.eslintrc.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/resources-provider-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"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/",
"lint": "eslint --ext .ts --ext .js --fix src/",
"format": "npm run prettier && npm run lint",
"ci-lint": "eslint -c .eslintrc.js --ext .ts --ext .js src/ && prettier --check src/",
"ci-lint": "eslint --ext .ts --ext .js src/ && prettier --check src/",
"prepublishOnly": "npm run build && npm run build-declaration",
"test": "npm run build && npm run build-declaration && npm run ci-lint"
},
Expand All @@ -43,8 +43,7 @@
"@types/express": "^4.17.6",
"@types/ngeohash": "^0.6.4",
"@types/node-fetch": "^2.5.6",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"prettier": "^2.8.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/resources-provider-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module.exports = (server: ResourceProviderApp): Plugin => {
}
}
})
} catch (error) {
} catch (_error) {
failed.push(resType)
}
})
Expand Down
10 changes: 5 additions & 5 deletions packages/resources-provider-plugin/src/lib/filestorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class FileStore implements IResourceStore {

try {
await this.checkPath(this.savePath)
} catch (error) {
} catch (_error) {
throw new Error(`Unable to create ${this.savePath}!`)
}
return await this.createSavePaths(enabledResTypes)
Expand All @@ -74,13 +74,13 @@ export class FileStore implements IResourceStore {
try {
await access(this.resources[t].path, constants.W_OK | constants.R_OK)
this.debug(`${this.resources[t].path} - OK....`)
} catch (error) {
} catch (_error) {
this.debug(`${this.resources[t].path} NOT available...`)
this.debug(`Creating ${this.resources[t].path} ...`)
try {
await mkdir(this.resources[t].path, { recursive: true })
this.debug(`Created ${this.resources[t].path} - OK....`)
} catch (error) {
} catch (_error) {
result.error = true
result.message += `ERROR creating ${this.resources[t].path} folder\r\n `
}
Expand Down Expand Up @@ -217,15 +217,15 @@ export class FileStore implements IResourceStore {
)
this.debug(`${path} - OK...`)
return true
} catch (error) {
} catch (_error) {
// if not then create it
this.debug(`${path} does NOT exist...`)
this.debug(`Creating ${path} ...`)
try {
await mkdir(path, { recursive: true })
this.debug(`Created ${path} - OK...`)
return true
} catch (error) {
} catch (_error) {
throw new Error(`Unable to create ${path}!`)
}
}
Expand Down
25 changes: 0 additions & 25 deletions packages/server-api/.eslintrc.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/server-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"prepublishOnly": "npm run build",
"typedoc": "typedoc --out docs src",
"prettier": "prettier -w src/",
"lint": "eslint -c .eslintrc.js --ext .ts --ext .js --fix src/",
"lint": "eslint --ext .ts --ext .js --fix src/",
"format": "npm run prettier && npm run lint",
"ci-lint": "eslint -c .eslintrc.js --ext .ts --ext .js src/ && prettier --check src/",
"ci-lint": "eslint --ext .ts --ext .js src/ && prettier --check src/",
"test": "mocha --require ts-node/register src/**/*.test.ts && npm run ci-lint"
},
"repository": {
Expand All @@ -25,8 +25,7 @@
"@types/chai": "^4.2.15",
"@types/express": "^4.17.1",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"chai": "^4.3.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
Expand Down
4 changes: 3 additions & 1 deletion src/@types/signalk_signalk-schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ declare module '@signalk/signalk-schema' {
constructor(selfId: string, selfType: string, defaults?: any)
addDelta: (_: any) => void
retrieve: () => any
pruneContexts: () => void
pruneContexts: (seconds: number) => void
}
export function getMetadata(path: string): any
export function getAISShipTypeName(shipType: number): string
}
14 changes: 7 additions & 7 deletions src/api/course/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CourseApi {
debug('Found persisted course data')
this.courseInfo = this.validateCourseInfo(storeData)
this.cmdSource = this.courseInfo.nextPoint ? API_CMD_SRC : null
} catch (error) {
} catch (_error) {
debug('No persisted course data (using default)')
}
debug(
Expand Down Expand Up @@ -464,7 +464,7 @@ export class CourseApi {
message: `Vessel position unavailable!`
})
}
} catch (err) {
} catch (_err) {
res.status(400).json({
state: 'FAILED',
statusCode: 400,
Expand Down Expand Up @@ -671,7 +671,7 @@ export class CourseApi {
res.status(400).json(Responses.invalid)
return false
}
} catch (err) {
} catch (_err) {
console.log(`** Course API: Unable to retrieve vessel position!`)
res.status(400).json(Responses.invalid)
return false
Expand Down Expand Up @@ -753,7 +753,7 @@ export class CourseApi {
} else {
throw new Error(`Error: Unable to retrieve vessel position!`)
}
} catch (err) {
} catch (_err) {
throw new Error(`Error: Unable to retrieve vessel position!`)
}
} else {
Expand Down Expand Up @@ -810,7 +810,7 @@ export class CourseApi {
} else {
throw new Error(`Invalid waypoint coordinate data! (${dest.href})`)
}
} catch (err) {
} catch (_err) {
throw new Error(`Error retrieving and validating ${dest.href}`)
}
} else {
Expand Down Expand Up @@ -845,7 +845,7 @@ export class CourseApi {
`Error: navigation.position.value is undefined! (${position})`
)
}
} catch (err) {
} catch (_err) {
throw new Error(`Error: Unable to retrieve vessel position!`)
}

Expand Down Expand Up @@ -943,7 +943,7 @@ export class CourseApi {
return (await this.resourcesApi.getResource(h.type, h.id)) as
| Route
| undefined
} catch (err) {
} catch (_err) {
debug(`** Unable to fetch resource: ${h.type}, ${h.id}`)
return undefined
}
Expand Down
16 changes: 8 additions & 8 deletions src/api/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class ResourcesApi {
}

if (!('resourcesApi' in this.app.config.settings)) {
debug('***** Applying Default Settings ********'),
((this.app.config.settings as any)['resourcesApi'] = defaultSettings)
debug('***** Applying Default Settings ********')
;(this.app.config.settings as any)['resourcesApi'] = defaultSettings
} else {
const s = (this.app.config.settings as any)['resourcesApi']
Object.entries(defaultSettings.defaultProviders).forEach((k) => {
Expand Down Expand Up @@ -570,7 +570,7 @@ export class ResourcesApi {
)
res.json(retVal)
}
} catch (err) {
} catch (_err) {
res.status(404).json({
state: 'FAILED',
statusCode: 404,
Expand Down Expand Up @@ -624,7 +624,7 @@ export class ResourcesApi {
)
res.json(retVal)
}
} catch (err) {
} catch (_err) {
res.status(404).json({
state: 'FAILED',
statusCode: 404,
Expand All @@ -650,7 +650,7 @@ export class ResourcesApi {
try {
acc[name] = JSON.parse(value as string)
return acc
} catch (error) {
} catch (_error) {
acc[name] = value
return acc
}
Expand Down Expand Up @@ -779,7 +779,7 @@ export class ResourcesApi {
statusCode: 201,
id
})
} catch (err) {
} catch (_err) {
res.status(400).json({
state: 'FAILED',
statusCode: 400,
Expand Down Expand Up @@ -868,7 +868,7 @@ export class ResourcesApi {
statusCode: 200,
message: req.params.resourceId
})
} catch (err) {
} catch (_err) {
res.status(404).json({
state: 'FAILED',
statusCode: 404,
Expand Down Expand Up @@ -931,7 +931,7 @@ export class ResourcesApi {
statusCode: 200,
message: req.params.resourceId
})
} catch (err) {
} catch (_err) {
res.status(400).json({
state: 'FAILED',
statusCode: 400,
Expand Down
1 change: 0 additions & 1 deletion src/api/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function mountSwaggerUi(app: IRouter & PluginManager, path: string) {

// custom middleware to re-setup swaggerUI, because plugins have
// not been loaded when this is called early in server startup sequence
// eslint-disable-next-line @typescript-eslint/no-unused-vars
app.use(path, (req: Request, res: Response, next: NextFunction) => {
swaggerUi.setup(undefined, {
explorer: true,
Expand Down
8 changes: 5 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-var-requires */
/*
Expand All @@ -18,6 +19,7 @@
'use strict'

import fs from 'fs'
import os from 'node:os'
import _ from 'lodash'
import path from 'path'
import semver from 'semver'
Expand Down Expand Up @@ -418,7 +420,7 @@ function readSettingsFile(app: ConfigApp) {
debug('Using settings file: ' + settings)
try {
app.config.settings = require(settings)
} catch (e: any) {
} catch (_e: any) {
console.error(
`Error reading settings file ${settings}, using empty settings`
)
Expand Down Expand Up @@ -466,8 +468,8 @@ function getExternalHostname(config: Config) {
return config.settings.hostname
}
try {
return require('os').hostname()
} catch (ex) {
return os.hostname()
} catch (_ex) {
return 'hostname_not_available'
}
}
Expand Down
Loading

0 comments on commit 0bb173e

Please sign in to comment.