eslint-formatter-azure-devops
Advanced tools
Comparing version 1.1.1 to 1.2.0
43
index.js
@@ -20,12 +20,25 @@ /*eslint-env node*/ | ||
module.exports = (results, resultsMeta) => { | ||
function shouldLogTaskComplete() { | ||
return Boolean(process.env.ESLINT_AZDO_LOG_TASK_COMPLETE); | ||
} | ||
function formatResults(results, resultsMeta) { | ||
let hasError = false; | ||
let hasWarning = false; | ||
const formattedResults = results | ||
.filter((result) => result.messages.length > 0) | ||
.map((result) => | ||
result.messages.map((message) => | ||
logIssue({ | ||
type: | ||
message.fatal || message.severity === ERROR_SEVERITY | ||
? 'error' | ||
: 'warning', | ||
result.messages.map((message) => { | ||
const type = | ||
message.fatal || message.severity === ERROR_SEVERITY | ||
? 'error' | ||
: 'warning'; | ||
if (type === 'error') { | ||
hasError = true; | ||
} else { | ||
hasWarning = true; | ||
} | ||
return logIssue({ | ||
type, | ||
sourcepath: result.filePath, | ||
@@ -36,4 +49,4 @@ linenumber: message.line, | ||
message: message.message, | ||
}) | ||
) | ||
}); | ||
}) | ||
) | ||
@@ -50,2 +63,3 @@ .reduce((allMessages, messages) => { | ||
if (maxWarnings < foundWarnings) { | ||
hasError = true; | ||
formattedResults.push( | ||
@@ -60,3 +74,12 @@ logIssue({ | ||
if (formatResults.shouldLogTaskComplete() && (hasError || hasWarning)) { | ||
const result = hasError ? 'Failed' : 'SucceededWithIssues'; | ||
formattedResults.push(`##vso[task.complete result=${result};]`); | ||
} | ||
return formattedResults.join('\n'); | ||
}; | ||
} | ||
formatResults.shouldLogTaskComplete = shouldLogTaskComplete; | ||
module.exports = formatResults; |
{ | ||
"name": "eslint-formatter-azure-devops", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "An ESLint formatter for Azure DevOps and Azure DevOps Server", | ||
@@ -16,3 +16,5 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "ava" | ||
"test": "ava", | ||
"lint": "eslint .", | ||
"fix": "prettier ./ --write && eslint . --fix" | ||
}, | ||
@@ -32,4 +34,6 @@ "files": [ | ||
"ava": "^5.1.0", | ||
"prettier": "^2.7.1" | ||
"eslint": "^8.53.0", | ||
"eslint-plugin-ava": "^14.0.0", | ||
"prettier": "^3.0.0" | ||
} | ||
} |
@@ -8,4 +8,8 @@ # eslint-formatter-vso [![GitHub Actions](https://github.com/EngageSoftware/eslint-formatter-azure-devops/actions/workflows/node.js.yml/badge.svg)](https://github.com/EngageSoftware/eslint-formatter-azure-devops/actions) [![npm](https://img.shields.io/npm/v/eslint-formatter-azure-devops.svg)](https://www.npmjs.com/package/eslint-formatter-azure-devops) [![npm](https://img.shields.io/npm/l/eslint-formatter-azure-devops.svg)](/license) | ||
### Log Partially Complete | ||
If you would like for the status of the task to be marked as _partially succeeded_ if there are any warnings, set the environment variable `ESLINT_AZDO_LOG_TASK_COMPLETE` before running ESLint (as of version 1.2.0). | ||
## License | ||
MIT © [Engage Software](https://engagesoftware.com) |
5271
69
15
4