XQuery Quality Checker
npm install @quodatum/xqlint

![GitHub]()

!GitHub Workflow Status

XQLint parses XQuery files and returns errors and warnings based on static code analysis. It provides the following features:
* Lint: errors and warnings based on static code analysis.
* Format: standardised indentation of source.
* AST: Abstract syntax tree as XML.
* xqdoc: json object with information similar to the xqdoc XML format
* Completion: suggestions for line completion given a source and location.
* Highlight console source listing using https://www.npmjs.com/package/colors
* Context analysis for a position in source
The goal of this project is to support XQuery development tools, particularly for BaseX (9.7+).
This project is in an Alpha state - errors and changes expected.
This project began as a fork of the marvelous wcandillon/xqlint.
but many features have been added and some, such as JSONiq support, removed.
Earlier versions quodatum/xqlint have been used as a drop-in replacement for wcandillon/xqlint in the following projects:
* the Ace editor
* XML tools DotJoshJohnson's VS code extension
Due to changes in the range object this is no longer as simple.
XQlint is published on npm
Install Node.js and NPM for your system (Mac, Windows or Linux). Then install the command line tool using:
``bash`
$ npm install @quodatum/xqlint -g`Command line usage
Lint
Analyse code for potential errors. In file or directory$3
`
xqlint lint -pbasex-9 .
xqlint lint . --processor basex-10
--processor name
### Options
* or -pname processor libraries to load--style-check no
* or -s yes/no. reports on trailing whitespace, tab use
`bash`
$ xqlint lint
windows..
`
xqlint --no-color lint C:\Users\andy\git\proj\XML-CMS\data_server\eapp\ >report.txt
xqlint lint --style-check yes cases\history.xqm
`
`bash`
$ xqlint format
` Returns the arc cosine of the argument, the result being in the range zero to\n +π radians. This function is If Otherwise the result is the arc cosine of The treatment of the If In other cases the result is an Returns the arc cosine of the argument, the result being in the range zero to\n + π radians.bash`
$ xqlint xqdoc
{
"ns" : "http://www.w3.org/2005/xpath-functions/math",
"description" : " This module contains all the functions part of the\n W3C XPath and XQuery Functions and Operators 3.0\n section \"4.7 Trigonometric and exponential functions\".\n",
"sees" : [ "
"authors" : [ "
"version" : null,
"encoding" : "utf-8",
"namespaces" : [ {
"uri" : "http://www.w3.org/2005/xpath-functions/math",
"prefix" : "math"
} ],
"variables": [],
"functions": [
{
"isDocumented" : true,
"arity" : 1,
"name" : "acos",
"qname" : "math:acos",
"signature" : "($arg as xs:double?) as xs:double? external",
"description" : " \n", $arg is the empty sequence, the function returns the empty sequence.$θ,\n treated as an angle in radians, as defined in the acos function applied to 64-bit binary floating point\n values.invalidOperation exception is defined in $arg is NaN, or if its absolute value is greater than one,\n then the result is NaN.xs:double value representing an angle\n θ in radians in the range 0 <= $θ <=\n +π.
"summary" : "
"annotation_str" : "",
"annotations" : [ ],
"updating" : false,
"parameters" : [ {
"name" : "arg",
"type" : "xs:double",
"occurrence" : "?",
"description" : ""
} ],
"returns" : {
"type" : "xs:double?",
"description" : ""
},
"errors" : [ ]
},
$3
`bash
$ xqlint ast
....
`
`bash`
$ xqlint highlight
The output is for terminal display
If you'd like to hack on xqlint itself:
`bash`
git clone https://github.com/Quodatum/xqlint
cd xqlint
npm install
sudo npm install grunt@1.5.3 -g
grunt
`bash
grunt vows
// just one test, hardcoded in grunt.js`
grunt vows:test
npm run-script rex parsers
Command generates:
* lib/lexers/XQueryTokenizer.ebnf -> XQueryTokenizer.js
* lib/parsers/XQueryParser.ebnf -> XQueryParser.js
```
npm pack
npm publish