Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2bccd3

Browse files
authored
Do not throw an error when it's failed to parse (#177)
It can be failed even if the sql text on the editor is correct because lint check can beapllied to a partial part depending on the cursor position.Instead of throwing an error, returns empty result.
1 parentb5bc1f5 commite2bccd3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎packages/sqlint/src/rules/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import{parse,NodeRange,AST,Node,BaseNode}from'@joe-re/sql-parser'
2+
importlog4jsfrom'log4js'
23
import{Fixer,FixDescription,createFixer}from'../fixer'
34
import{reservedWordCase}from'./reservedWordCase'
45
import{spaceSurroundingOperators}from'./spaceSurroundingOperators'
@@ -9,6 +10,8 @@ import { whereClauseNewLine } from './whereClauseNewLine'
910
import{alignWhereClauseToTheFirst}from'./alignWhereClauseToTheFirst'
1011
import{requireAsToRenameColumn}from'./requireAsToRenameColumn'
1112

13+
constlogger=log4js.getLogger()
14+
1215
exporttypeDiagnostic={
1316
message:string
1417
location:NodeRange
@@ -75,8 +78,14 @@ export function execute(sql: string, config: Config): Diagnostic[] {
7578
registerRule(whereClauseNewLine,config,sql)
7679
registerRule(alignWhereClauseToTheFirst,config,sql)
7780
registerRule(requireAsToRenameColumn,config,sql)
78-
constast=parse(sql)
79-
returnwalk(ast)
81+
82+
try{
83+
constast=parse(sql)
84+
returnwalk(ast)
85+
}catch(e){
86+
logger.debug(e)
87+
return[]
88+
}
8089
}
8190

8291
functionregisterRule<NextendsNode,RC>(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp