Skip to content

Commit 70adf3b

Browse files
committed
fix: lint errors and typing
1 parent bdb0a9f commit 70adf3b

21 files changed

+99
-101
lines changed

src/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {setAccessTokenConfig} from './utils'
77
export default abstract class HackMDCommand extends Command {
88
async getAPIClient() {
99
const token = config.accessToken || await ux.prompt('Enter your access token', {
10-
type: 'hide'
10+
type: 'hide',
1111
})
1212
const APIClient = new API(token, config.hackmdAPIEndpointURL)
1313

src/commands/export.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class Export extends HackMDCommand {
1414

1515
static flags = {
1616
help: Flags.help({char: 'h'}),
17-
noteId
17+
noteId,
1818
}
1919

2020
async run() {
@@ -29,9 +29,9 @@ export default class Export extends HackMDCommand {
2929
const APIClient = await this.getAPIClient()
3030
const note = await APIClient.getNote(noteId)
3131
this.log(note.content)
32-
} catch (e) {
32+
} catch (error) {
3333
this.log('Export note content failed')
34-
this.error(e as Error)
34+
this.error(error as Error)
3535
}
3636
}
3737
}

src/commands/history.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ BnC6gN0_TfStV2KKmPPXeg Welcome to your team's workspace null C
3131
},
3232
title: {},
3333
userPath: {
34-
header: 'User Path'
34+
header: 'User Path',
3535
},
3636
teamPath: {
37-
header: 'Team Path'
37+
header: 'Team Path',
3838
},
3939
}, {
4040
printLine: this.log.bind(this),
41-
...flags
41+
...flags,
4242
})
43-
} catch (e) {
43+
} catch (error) {
4444
this.log('Fetch history failed')
45-
this.error(e as Error)
45+
this.error(error as Error)
4646
}
4747
}
4848
}

src/commands/login.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ export default class Login extends HackMDCommand {
1111
Enter your access token: MY_ACCESS_TOKEN
1212
1313
Login successfully
14-
`
14+
`,
1515
]
1616

1717
static flags = {
18-
help: Flags.help({char: 'h'})
18+
help: Flags.help({char: 'h'}),
1919
}
2020

2121
async run() {
2222
try {
2323
await this.getAPIClient()
2424
this.log('Login successfully')
25-
} catch (err) {
25+
} catch (error) {
2626
this.log('Login failed')
27-
this.error(err as Error)
27+
this.error(error as Error)
2828
}
2929
}
3030
}

src/commands/logout.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ export default class Logout extends HackMDCommand {
1010
`$ hackmd-cli logout
1111
1212
You've logged out successfully
13-
`
13+
`,
1414
]
1515

1616
static flags = {
17-
help: Flags.help({char: 'h'})
17+
help: Flags.help({char: 'h'}),
1818
}
1919

2020
async run() {
2121
try {
2222
setAccessTokenConfig('')
2323
this.log("You've logged out successfully")
24-
} catch (err) {
25-
this.error(String(err))
24+
} catch (error) {
25+
this.error(String(error))
2626
}
2727
}
2828
}

src/commands/notes/create.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
NotePermissionRole,
55
} from '@hackmd/api/dist/type'
66
import {Flags, ux} from '@oclif/core'
7-
import * as fs from 'fs'
7+
import * as fs from 'node:fs'
88

99
import HackMDCommand from '../../command'
1010
import {
@@ -60,8 +60,8 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
6060
await openEditor(mdFile)
6161

6262
options.content = fs.readFileSync(mdFile).toString()
63-
} catch (e) {
64-
this.error(e as Error)
63+
} catch (error) {
64+
this.error(error as Error)
6565
}
6666
}
6767

@@ -86,11 +86,11 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q
8686
{
8787
printLine: this.log.bind(this),
8888
...flags,
89-
}
89+
},
9090
)
91-
} catch (e) {
91+
} catch (error) {
9292
this.log('Create note failed')
93-
this.error(e as Error)
93+
this.error(error as Error)
9494
}
9595
}
9696
}

src/commands/notes/delete.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default class Delete extends HackMDCommand {
77
static description = 'Delete a note'
88

99
static examples = [
10-
'$ hackmd-cli notes delete --noteId=WNkLM6gkS0Cg2cQ8rv7bYA'
10+
'$ hackmd-cli notes delete --noteId=WNkLM6gkS0Cg2cQ8rv7bYA',
1111
]
1212

1313
static flags = {
@@ -26,9 +26,9 @@ export default class Delete extends HackMDCommand {
2626
try {
2727
const APIClient = await this.getAPIClient()
2828
await APIClient.deleteNote(noteId)
29-
} catch (e) {
29+
} catch (error) {
3030
this.log('Delete note failed')
31-
this.error(e as Error)
31+
this.error(error as Error)
3232
}
3333
}
3434
}

src/commands/notes/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ raUuSTetT5uQbqQfLnz9lA CLI test note gvfz2UB5THiKABQJQnLs6Q n
3232
},
3333
title: {},
3434
userPath: {
35-
header: 'User Path'
35+
header: 'User Path',
3636
},
3737
teamPath: {
38-
header: 'Team Path'
38+
header: 'Team Path',
3939
},
4040
}, {
4141
printLine: this.log.bind(this),
42-
...flags
42+
...flags,
4343
})
44-
} catch (e) {
44+
} catch (error) {
4545
this.log('Fetch user notes failed')
46-
this.error(e as Error)
46+
this.error(error as Error)
4747
}
4848
}
4949
}

src/commands/notes/update.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export default class Update extends HackMDCommand {
77
static description = 'Update note content'
88

99
static examples = [
10-
"$ hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --content='# A new title'"
10+
"$ hackmd-cli notes update --noteId=WNkLM6gkS0Cg2cQ8rv7bYA --content='# A new title'",
1111
]
1212

1313
static flags = {
1414
help: Flags.help({char: 'h'}),
1515
noteId,
16-
content: noteContent
16+
content: noteContent,
1717
}
1818

1919
async run() {
@@ -27,9 +27,9 @@ export default class Update extends HackMDCommand {
2727
try {
2828
const APIClient = await this.getAPIClient()
2929
await APIClient.updateNoteContent(noteId, content)
30-
} catch (e) {
30+
} catch (error) {
3131
this.log('Update note content failed')
32-
this.error(e as Error)
32+
this.error(error as Error)
3333
}
3434
}
3535
}

src/commands/team-notes/create.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CommentPermissionType, CreateNoteOptions, NotePermissionRole} from '@hackmd/api/dist/type'
22
import {Flags, ux} from '@oclif/core'
3-
import fs from 'fs'
3+
import fs from 'node:fs'
44

55
import HackMDCommand from '../../command'
66
import {commentPermission, editor, noteContent, notePermission, noteTitle, teamPath} from '../../flags'
@@ -17,7 +17,7 @@ ID Title User Path T
1717
raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q null `,
1818

1919
'Or you can pipe content via Unix pipeline:',
20-
'cat README.md | hackmd-cli notes create --teamPath=CLI-test'
20+
'cat README.md | hackmd-cli notes create --teamPath=CLI-test',
2121
]
2222

2323
static flags = {
@@ -36,13 +36,13 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
3636
const {flags} = await this.parse(Create)
3737
const pipeString = safeStdinRead()
3838

39-
const {teamPath} = flags
39+
const {teamPath, title, content, readPermission, writePermission, commentPermission} = flags
4040
const options: CreateNoteOptions = {
41-
title: flags.title,
42-
content: pipeString || flags.content,
43-
readPermission: flags.readPermission as NotePermissionRole,
44-
writePermission: flags.writePermission as NotePermissionRole,
45-
commentPermission: flags.commentPermission as CommentPermissionType
41+
title: title,
42+
content: pipeString || content,
43+
readPermission: readPermission as NotePermissionRole,
44+
writePermission: writePermission as NotePermissionRole,
45+
commentPermission: commentPermission as CommentPermissionType,
4646
}
4747

4848
if (!teamPath) {
@@ -55,8 +55,8 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
5555
await openEditor(mdFile)
5656

5757
options.content = fs.readFileSync(mdFile).toString()
58-
} catch (e) {
59-
this.error(e as Error)
58+
} catch (error) {
59+
this.error(error as Error)
6060
}
6161
}
6262

@@ -70,18 +70,18 @@ raUuSTetT5uQbqQfLnz9lA A new note gvfz2UB5THiKABQJQnLs6Q n
7070
},
7171
title: {},
7272
userPath: {
73-
header: 'User path'
73+
header: 'User path',
7474
},
7575
teamPath: {
76-
header: 'Team path'
77-
}
76+
header: 'Team path',
77+
},
7878
}, {
7979
printLine: this.log.bind(this),
80-
...flags
80+
...flags,
8181
})
82-
} catch (e) {
82+
} catch (error) {
8383
this.log('Create team note failed')
84-
this.error(e as Error)
84+
this.error(error as Error)
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)