(_ js.Value, args []js.Value)
| 98 | } |
| 99 | |
| 100 | func lint(_ js.Value, args []js.Value) any { |
| 101 | if len(args) == 0 { |
| 102 | return jsonError("no SQL provided") |
| 103 | } |
| 104 | sql := args[0].String() |
| 105 | // dialect is accepted for API consistency |
| 106 | _ = getDialect(args) |
| 107 | |
| 108 | l := linter.New( |
| 109 | whitespace.NewTrailingWhitespaceRule(), |
| 110 | whitespace.NewMixedIndentationRule(), |
| 111 | keywords.NewKeywordCaseRule(keywords.CaseUpper), |
| 112 | ) |
| 113 | result := l.LintString(sql, "<playground>") |
| 114 | |
| 115 | b, err := json.MarshalIndent(result, "", " ") |
| 116 | if err != nil { |
| 117 | return jsonError(err.Error()) |
| 118 | } |
| 119 | return string(b) |
| 120 | } |
| 121 | |
| 122 | func validate(_ js.Value, args []js.Value) any { |
| 123 | if len(args) == 0 { |
nothing calls this directly
no test coverage detected