MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / lint

Function lint

wasm/main.go:100–120  ·  view source on GitHub ↗
(_ js.Value, args []js.Value)

Source from the content-addressed store, hash-verified

98}
99
100func 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
122func validate(_ js.Value, args []js.Value) any {
123 if len(args) == 0 {

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
NewMixedIndentationRuleFunction · 0.92
jsonErrorFunction · 0.85
getDialectFunction · 0.85
LintStringMethod · 0.80
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected