|
2 | 2 |
|
3 | 3 | /* global emit */
|
4 | 4 |
|
5 |
| -import escapeHTML from 'escape-html'; |
6 | 5 | import fs from 'fs';
|
7 | 6 | import path from 'path';
|
8 | 7 | import { getRuleUri } from 'tslint-rule-documentation';
|
@@ -171,6 +170,11 @@ async function getProgram(Linter, configurationPath) {
|
171 | 170 | return program;
|
172 | 171 | }
|
173 | 172 |
|
| 173 | +function getSeverity(failure) { |
| 174 | + const severity = failure.ruleSeverity.toLowerCase(); |
| 175 | + return ['info', 'warning', 'error'].includes(severity) ? severity : 'warning'; |
| 176 | +} |
| 177 | + |
174 | 178 | /**
|
175 | 179 | * Lint the provided TypeScript content
|
176 | 180 | * @param content {string} The content of the TypeScript file
|
@@ -240,13 +244,16 @@ async function lint(content, filePath, options) {
|
240 | 244 | const startPosition = failure.getStartPosition().getLineAndCharacter();
|
241 | 245 | const endPosition = failure.getEndPosition().getLineAndCharacter();
|
242 | 246 | return {
|
243 |
| - type: failure.ruleSeverity || 'warning', |
244 |
| - html: `${escapeHTML(failure.getFailure())} (<a href="${ruleUri.uri}">${failure.getRuleName()}</a>)`, |
245 |
| - filePath: path.normalize(failure.getFileName()), |
246 |
| - range: [ |
247 |
| - [startPosition.line, startPosition.character], |
248 |
| - [endPosition.line, endPosition.character], |
249 |
| - ], |
| 247 | + severity: getSeverity(failure), |
| 248 | + excerpt: `${failure.getFailure()} (${failure.getRuleName()})`, |
| 249 | + url: ruleUri.uri, |
| 250 | + location: { |
| 251 | + file: path.normalize(failure.getFileName()), |
| 252 | + position: [ |
| 253 | + [startPosition.line, startPosition.character], |
| 254 | + [endPosition.line, endPosition.character], |
| 255 | + ], |
| 256 | + }, |
250 | 257 | };
|
251 | 258 | });
|
252 | 259 | }
|
|
0 commit comments