ut-tsql-lexer
v1.5.4
Published
Transact SQL lexer and linter
Downloads
81
Readme
Transact SQL lexer and linter
API
try {
let parsed = require('ut-tsql-lexer').parse('select * FROM someTable');
parsed.lint.forEach(({
startLine,
startColumn,
endLine,
endColumn,
code,
message,
text
}) => {
// process lint warnings
});
parsed.tokens.forEach(line => {
line.forEach(({
type, // whitespace, newline, comment, literal, system, globaltemp,
// temp, variable, keyword, word, paren, operator
text,
location
}) => {
// process tokens of each line of source code
});
});
} catch ({message, location}) {
// process parse errors
}
Lint rules
upppercase-keywords
: Keywords must be in uppercaseno-doublequotes
: Must use [...] instead of "..."indent-size
: Indentation must be multiple of 4no-trailing-whitespace
: Trailing whitespace not allowedsingle-whitespace
: Non indentation should be with single spacenewline-required
: Newline required at end of filewhitespace-around
: Operator should be surrounded with single spacewhitespace-after
: Operator should be followed by single spaceindent-step
: Indentation step must not exceed 4indent-same
: Lines starting with non-keyword must have same indentationindent-increase
: Lines starting with non-keyword after lines starting with keyword must increase indentationindent-after-begin
: Line after BEGIN must increase indentation with 4