Skip to content

Commit 8087990

Browse files
authored
fix unexpected error (#38)
If the text is empty don't do lint to avoid causing unexpected error. fix: #36
1 parent 02c8674 commit 8087990

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/server/createDiagnostics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import cache, { LintCache } from './cache'
99
const logger = log4js.getLogger()
1010

1111
function doLint(uri: string, sql: string): Diagnostic[] {
12+
if (!sql) {
13+
return []
14+
}
1215
const result: LintResult[] = JSON.parse(lint({ configPath: process.cwd(), formatType: 'json', text: sql }))
1316
const lintDiagnostics = result.map(v => v.diagnostics).flat()
1417
const lintCache: LintCache[] = []

packages/sqlint/src/cli/lint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function lint (
5959
const { path, formatType, configPath, outputFile, text } = params
6060
const files = path ? getFileList(path) : []
6161
if (files.length === 0 && !text) {
62-
throw new Error(`No files matching '${path}' were found.`)
62+
throw new Error(`No files matching. path: ${path}`)
6363
}
6464
const config = loadConfig(configPath || process.cwd())
6565

0 commit comments

Comments
 (0)