Skip to content

Commit 0d21bfb

Browse files
committed
lint lib/config
Signed-off-by: Raccoon <raccoon@hackmd.io>
1 parent fa048d9 commit 0d21bfb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

lib/config/dockerSecret.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ function getSecret(secret) {
99
return undefined
1010
}
1111

12-
let dockerSecretConfig: any = {}
12+
// eslint-disable-next-line
13+
let dockerSecretConfig: Record<string, any> = {}
14+
1315
if (fs.existsSync(basePath)) {
1416
dockerSecretConfig = {
1517
dbURL: getSecret('dburl'),

lib/config/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const configFilePath = path.resolve(appRootPath, process.env.CMD_CONFIG_FILE ||
3434
// eslint-disable-next-line @typescript-eslint/no-var-requires
3535
const fileConfig = fs.existsSync(configFilePath) ? require(configFilePath)[env] : undefined
3636

37-
// eslint-disable-next-line @typescript-eslint/no-var-requires
37+
// eslint-disable-next-line
3838
let config: any = require('./default')
3939
// eslint-disable-next-line @typescript-eslint/no-var-requires
4040
merge(config, require('./defaultSSL'))
@@ -214,7 +214,9 @@ config.defaultNotePath = path.resolve(appRootPath, config.defaultNotePath)
214214
config.docsPath = path.resolve(appRootPath, config.docsPath)
215215
config.uploadsPath = path.resolve(appRootPath, config.uploadsPath)
216216
config.env = env
217+
217218
// make config readonly
219+
// eslint-disable-next-line
218220
config = deepFreeze(config) as any
219221

220222
export = config

lib/config/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import * as fs from "fs";
22
import * as path from "path";
33

4-
export function toBooleanConfig(configValue) {
4+
export function toBooleanConfig(configValue: string | boolean): boolean {
55
if (configValue && typeof configValue === 'string') {
66
return (configValue === 'true')
77
}
8-
return configValue
8+
return configValue as boolean
99
}
1010

11-
export function toArrayConfig(configValue, separator = ',', fallback ?: any) {
11+
export function toArrayConfig(configValue: string | [], separator = ',', fallback ?: string[]): string[] {
1212
if (configValue && typeof configValue === 'string') {
1313
return (configValue.split(separator).map(arrayItem => arrayItem.trim()))
1414
}
1515
return fallback
1616
}
1717

18-
export function toIntegerConfig(configValue) {
18+
export function toIntegerConfig(configValue: string | number): number {
1919
if (configValue && typeof configValue === 'string') {
2020
return parseInt(configValue)
2121
}
22-
return configValue
22+
return configValue as number
2323
}
2424

25-
export function getGitCommit(repodir) {
25+
export function getGitCommit(repodir: string): string {
2626
if (!fs.existsSync(repodir + '/.git/HEAD')) {
2727
return undefined
2828
}
@@ -35,7 +35,7 @@ export function getGitCommit(repodir) {
3535
return reference
3636
}
3737

38-
export function getGitHubURL(repo, reference) {
38+
export function getGitHubURL(repo: string, reference: string): string {
3939
// if it's not a github reference, we handle handle that anyway
4040
if (!repo.startsWith('https://github.com') && !repo.startsWith('git@github.com')) {
4141
return repo

0 commit comments

Comments
 (0)