Skip to content

maxonfjvipon/xslint

Repository files navigation

Xslint

CLI application for checking the quality of XSL.

DevOps By Rultor.com

npm grunt PDD status Hits-of-Code License

Installation

To install xslint you need to install npm first. Then run:

npm install -g @maxonfjvipon/xslint@0.0.6
xslint --version

Build

To build xslint from source, clone this repository:

git clone git@github.com:maxonfjvipon/xslint.git
cd xslint

Next, run these commands to install xslint system-wide:

npm install
npm install -g .

Verify that xslint is installed correctly:

$ xslint --version
0.0.0

Usage

You can check all files in current directory:

xslint

To check specified files - provide them as arguments:

xslint path/to/your/file1.xsl path/to/your/file2.xsl

You can suppress some checks by using --suppress option:

xslint --suppress=template-match-are-you-confusing-variable-and-node

You can skip several checks at once if they contain a certain substring:

xslint --suppress=template-match

If you want to suppress many checks, use --suppress as many times as you need:

xslint --suppress=monolithic-design --suppress=short-names

Checks

The full list of checks with descriptions and examples is available at maxonfjvipon.github.io/xslint.

xslint runs in two stages. Validators first establish that the input is valid; linters then run over the stylesheets that pass, catching stylistic, semantic, and logical problems. A stylesheet that does not parse is reported once and skipped, so one broken file never hides the feedback on the rest.

Validators:

  • XML well-formedness — a stylesheet that is not well-formed XML is reported and excluded from linting.
  • XPath syntax — every bare XPath expression (in select, test, use, value, group-by, group-adjacent, and the XSLT 3.0 key, initial-value, xpath, context-item, with-params, namespace-context) is parsed; the ones the processor cannot parse are reported.

Linters:

  • Per-file checks evaluate one stylesheet at a time (most checks).
  • Cross-file checks reason across all the stylesheets you lint together. For example, a named template defined in one file but invoked from another (via xsl:import/xsl:include) is not reported as unused. Lint the whole project at once so these checks can see every caller.
  • Formatting checks read each XPath expression as a stream of tokens and flag stylistic noise — currently redundant whitespace (a doubled space, or a space leading or trailing the expression). Only expressions that already parse are checked, so a malformed one is reported once by the validator and never nagged about its spacing.

How to Contribute

Fork repository, make changes, then send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please make sure all your tests pass:

npm test

New linter rules live in src/resources/checks/xpath (per-file) or src/resources/checks/corpus (cross-file), each with a matching test pack in test/resources. The validators in src/resources/checks/validation and the formatting checks in src/resources/checks/format are fixed in code; their YAML only tunes severity and message. Regenerate the documentation site with npx grunt docs.

You will need npm and node installed

About

XSL Linter

Resources

License

Stars

5 stars

Watchers

3 watching

Forks

Packages

 
 
 

Contributors