[](http://badge.fury.io/js/prettier-plugin-xquery) [](https://github.com/DrRataplan/prett
npm install prettier-plugin-xqueryprettier-plugin-xquery is a prettier plugin for XQuery. prettier is an
opinionated code formatter that supports multiple languages and integrates with most editors. The
idea is to eliminate discussions of style in code review and allow developers to get back to
thinking about code design instead.
To run prettier with the XQuery plugin, you're going to neednode.
If you're using the npm CLI, then add the plugin by:
``bash`
npm install --save-dev prettier prettier-plugin-xquery
Or if you're using yarn, then add the plugin by:
`bash`
yarn add --dev prettier prettier-plugin-xquery
The prettier executable is now installed and ready for use:
`bash`
npx prettier --plugin=prettier-plugin-xquery --write '*/.xq*'
Add a .prettierrc.js to save the configuration
`js
import prettierPluginXQuery from 'prettier-plugin-xquery';
/**
* @type {import('prettier').Config}
*/
const config = {
useTabs: true,
printWidth: 120,
plugins: [prettierPluginXQuery],
};
export default config;
`
| --print-width | 80 | Same as in Prettier (see prettier docs).
| tabWidth | --tab-width | 2 | Same as in Prettier (see prettier docs).
| singleQuote | --single-quote | false | Same as in Prettier (see prettier docs).
| useTabs | --use-tabs | false | Same as in Prettier (see prettier docs).Any of these can be added to your existing prettier configuration
file. For example:
`json
{
"tabWidth": 4,
"plugins": ["prettier-plugin-xquery"]
}
`Or, they can be passed to
prettier as arguments:`bash
prettier --plugin=prettier-plugin-xquery --tab-width 4 --write '*/.xq*'
`Ignoring
A
prettier-ignore comment marks code as ignored for formatting. Like this:`xquery
module namespace el = "http://www.elliat.nl";declare function el:reverse (
$a as xs:integer,
$b as xs:integer,
$c as xs:integer,
$d as xs:integer
) {
($d, $c, $b, $a)
};
(: prettier-ignore :)
declare function el:swap (
$a as xs:integer, $b as xs:integer,
$c as xs:integer, $b as xs:integer
) {
($b, $a, $d, $c)
};
``Bug reports and pull requests are welcome on GitHub at
https://github.com/drrataplan/prettier-plugin-xquery.
This plugin is under development, the following features are planned:
* Extensible parsers, for the different dialects of XQuery, like XQuery Update Facility, the ExistDB
update syntax or the customizations in MarkLogic
* Support for XQuery 4.0
* General stability. Refer to list of known test failures for a report
of current known failing tests.
The package is available as open source under the terms of the MIT
License.
This project uses the rex parser generator to parse XQuery.