eslint-junit
A eslint reporter that creates compatible junit xml files
Installation
yarn add --dev eslint-junit
Usage
Simply run:
eslint -f ./node_modules/eslint-junit/index.js
Configuration
eslint-junit
offers four configurations based on environment variables or a eslint-junit
key defined in package.json
. All configuration values should be strings.
Variable Name | Description | Default |
---|---|---|
ESLINT_SUITE_NAME |
name attribute of <testsuites> |
"eslint tests" |
ESLINT_JUNIT_OUTPUT |
File path to save the output. | "./junit.xml" |
ESLINT_JUNIT_CLASSNAME |
Template string for the classname attribute of <testcase> . |
"{ruleId}" |
ESLINT_JUNIT_TITLE |
Template string for the name attribute of <testcase> . |
"{line} : {source}" |
Example:
ESLINT_SUITE_NAME="Eslint Style Tests" ESLINT_JUNIT_OUTPUT="./artifacts/eslint-junit.xml" eslint
You can also define a eslint-junit
key in your package.json
. All are string values.
{
...
"eslint-junit": {
"suiteName": "eslint tests",
"output": "./eslint-junit.xml",
"classNameTemplate": "{ruleId}",
"titleTemplate": "{line} : {source}"
}
}
For the following case:
{ a = '1';}
The default output:
Assignment to function parameter 'a'.
Changing the classNameTemplate
and titleTemplate
:
ESLINT_JUNIT_CLASSNAME="{ruleId}" ESLINT_JUNIT_TITLE="{source}" eslint
Assignment to function parameter 'pathToResolve'.