Skip to content

Commit e06b049

Browse files
committed
chore(vscode): make eslint stricter
1 parent 5d7431a commit e06b049

8 files changed

Lines changed: 50 additions & 46 deletions

File tree

vscode/extension/eslint.config.mjs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
1-
import typescriptEslint from '@typescript-eslint/eslint-plugin'
2-
import tsParser from '@typescript-eslint/parser'
1+
import eslint from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
33

4-
export default [
4+
export default tseslint.config(
5+
eslint.configs.recommended,
6+
tseslint.configs.strict,
7+
tseslint.configs.stylistic,
8+
tseslint.configs.recommendedTypeChecked,
59
{
6-
files: ['**/*.ts'],
7-
},
8-
{
9-
plugins: {
10-
'@typescript-eslint': typescriptEslint,
11-
},
12-
1310
languageOptions: {
14-
parser: tsParser,
15-
ecmaVersion: 2022,
16-
sourceType: 'module',
11+
parserOptions: {
12+
projectService: true,
13+
tsconfigRootDir: import.meta.dirname,
14+
},
1715
},
18-
16+
},
17+
{
1918
rules: {
20-
'@typescript-eslint/naming-convention': [
21-
'warn',
22-
{
23-
selector: 'import',
24-
format: ['camelCase', 'PascalCase'],
25-
},
26-
],
27-
28-
curly: 'error',
29-
eqeqeq: 'error',
30-
'no-throw-literal': 'error',
31-
semi: ['error', 'never'],
32-
'no-shadow': 'error',
19+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
20+
'@typescript-eslint/no-unsafe-assignment': 'off',
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'@typescript-eslint/no-non-null-assertion': 'off',
23+
'@typescript-eslint/restrict-template-expressions': 'off',
24+
'@typescript-eslint/no-unsafe-argument': 'off',
25+
'@typescript-eslint/no-unsafe-member-access': 'off',
3326
},
3427
},
35-
]
28+
)

vscode/extension/src/auth/auth.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class AuthenticationProviderTobikoCloud
8282
return err('Failed to get tcloud auth status')
8383
}
8484
const status = result.stdout
85-
const statusToJson = JSON.parse(status)
85+
const statusToJson: any = JSON.parse(status)
8686
const statusResponse = statusResponseSchema.parse(statusToJson)
8787
return ok(statusResponse)
8888
}
@@ -188,7 +188,7 @@ export class AuthenticationProviderTobikoCloud
188188
}
189189

190190
try {
191-
const resultToJson = JSON.parse(result.stdout)
191+
const resultToJson: any = JSON.parse(result.stdout)
192192
const urlCode = loginUrlResponseSchema.parse(resultToJson)
193193
const url = urlCode.url
194194

@@ -197,7 +197,12 @@ export class AuthenticationProviderTobikoCloud
197197
}
198198

199199
const ac = new AbortController()
200-
const timeout = setTimeout(() => ac.abort(), 1000 * 60 * 5)
200+
const timeout = setTimeout(
201+
() => {
202+
ac.abort()
203+
},
204+
1000 * 60 * 5,
205+
)
201206
const backgroundServerForLogin = execAsync(
202207
tcloudBinPath,
203208
['auth', 'vscode', 'start-server', urlCode.verifier_code],
@@ -279,11 +284,16 @@ export class AuthenticationProviderTobikoCloud
279284
}
280285

281286
try {
282-
const resultToJson = JSON.parse(result.stdout)
287+
const resultToJson: any = JSON.parse(result.stdout)
283288
const deviceCodeResponse = deviceCodeResponseSchema.parse(resultToJson)
284289

285290
const ac = new AbortController()
286-
const timeout = setTimeout(() => ac.abort(), 1000 * 60 * 5)
291+
const timeout = setTimeout(
292+
() => {
293+
ac.abort()
294+
},
295+
1000 * 60 * 5,
296+
)
287297
const waiting = execAsync(
288298
tcloudBinPath,
289299
['auth', 'vscode', 'poll_device', deviceCodeResponse.device_code],

vscode/extension/src/commands/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const format =
1212
const out = await internalFormat()
1313
if (isErr(out)) {
1414
if (out.error.type === 'not_signed_in') {
15-
handleNotSginedInError(authProvider)
15+
await handleNotSginedInError(authProvider)
1616
return
1717
} else {
1818
vscode.window.showErrorMessage(

vscode/extension/src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function activate(context: vscode.ExtensionContext) {
5858
lspClient = new LSPClient()
5959
const result = await lspClient.start()
6060
if (isErr(result)) {
61-
handleNotSginedInError(authProvider)
61+
await handleNotSginedInError(authProvider)
6262
}
6363
context.subscriptions.push(lspClient)
6464

@@ -67,7 +67,7 @@ export async function activate(context: vscode.ExtensionContext) {
6767
traceVerbose('Restarting LSP client')
6868
const restartResult = await lspClient.restart()
6969
if (isErr(restartResult)) {
70-
handleNotSginedInError(authProvider)
70+
await handleNotSginedInError(authProvider)
7171
}
7272
}
7373
}

vscode/extension/src/lsp/lsp.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class LSPClient implements Disposable {
2727

2828
const sqlmesh = await sqlmesh_lsp_exec()
2929
if (isErr(sqlmesh)) {
30-
traceError(`Failed to get sqlmesh_lsp_exec: ${sqlmesh.error}`)
30+
traceError(`Failed to get sqlmesh_lsp_exec, ${sqlmesh.error.type}`)
3131
return sqlmesh
3232
}
3333
const workspaceFolders = getWorkspaceFolders()
@@ -41,9 +41,9 @@ export class LSPClient implements Disposable {
4141
})
4242
}
4343

44-
let folder = workspaceFolders[0]
44+
const folder = workspaceFolders[0]
4545
const workspacePath = workspaceFolders[0].uri.fsPath
46-
let serverOptions: ServerOptions = {
46+
const serverOptions: ServerOptions = {
4747
run: {
4848
command: sqlmesh.value.bin,
4949
transport: TransportKind.stdio,
@@ -61,7 +61,7 @@ export class LSPClient implements Disposable {
6161
args: sqlmesh.value.args,
6262
},
6363
}
64-
let clientOptions: LanguageClientOptions = {
64+
const clientOptions: LanguageClientOptions = {
6565
documentSelector: [{ scheme: 'file', pattern: `**/*.sql` }],
6666
workspaceFolder: folder,
6767
diagnosticCollectionName: 'sqlmesh',

vscode/extension/src/utilities/common/vscodeapi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ export function registerCommand(
3535
export const { onDidChangeConfiguration } = workspace
3636

3737
export function isVirtualWorkspace(): boolean {
38-
const isVirtual =
39-
workspace.workspaceFolders &&
40-
workspace.workspaceFolders.every(f => f.uri.scheme !== 'file')
38+
const isVirtual = workspace.workspaceFolders?.every(
39+
f => f.uri.scheme !== 'file',
40+
)
4141
return !!isVirtual
4242
}
4343

vscode/extension/src/utilities/exec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ export function execAsync(
5858
options.signal.addEventListener('abort', onAbort, { once: true })
5959

6060
// Clean‑up the event listener when the promise settles
61-
const cleanup = () =>
61+
const cleanup = () => {
6262
options.signal!.removeEventListener('abort', onAbort)
63+
}
6364
child.once('exit', cleanup)
6465
child.once('error', cleanup)
6566
}

vscode/extension/src/utilities/sqlmesh/sqlmesh.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { execAsync } from '../exec'
1111
import z from 'zod'
1212
import { ProgressLocation, window } from 'vscode'
1313

14-
export type sqlmesh_exec = {
14+
export interface sqlmesh_exec {
1515
workspacePath: string
1616
bin: string
1717
env: Record<string, string | undefined>
@@ -75,7 +75,7 @@ export const isSqlmeshEnterpriseInstalled = async (): Promise<
7575
const parsed = isSqlmeshInstalledSchema.safeParse(JSON.parse(called.stdout))
7676
if (!parsed.success) {
7777
return err(
78-
`Failed to parse sqlmesh enterprise installation status: ${parsed.error}`,
78+
`Failed to parse sqlmesh enterprise installation status: ${parsed.error.message}`,
7979
)
8080
}
8181
return ok(parsed.data.is_installed)

0 commit comments

Comments
 (0)