@rehearsal/reporter
Advanced tools
Comparing version 2.0.2-beta to 2.1.0
@@ -1,2 +0,2 @@ | ||
class JSONFormatter { | ||
export class JSONFormatter { | ||
static getReport(report) { | ||
@@ -7,3 +7,2 @@ return JSON.stringify(report, null, 2); | ||
JSONFormatter.extension = '.json'; | ||
export { JSONFormatter }; | ||
//# sourceMappingURL=json-formatter.js.map |
@@ -1,2 +0,2 @@ | ||
class MarkdownFormatter { | ||
export class MarkdownFormatter { | ||
static getReport(report) { | ||
@@ -9,3 +9,2 @@ const fileNames = [...new Set(report.items.map((item) => item.analysisTarget))]; | ||
text += `Typescript Version: ${block.tsVersion}\n`; | ||
text += `Base path: ${block.basePath}\n`; | ||
text += `timestamp: ${block.timestamp}\n`; | ||
@@ -30,3 +29,2 @@ text += `\n`; | ||
MarkdownFormatter.extension = '.md'; | ||
export { MarkdownFormatter }; | ||
//# sourceMappingURL=md-formatter.js.map |
@@ -1,2 +0,2 @@ | ||
class SarifFormatter { | ||
export class SarifFormatter { | ||
constructor(report) { | ||
@@ -145,3 +145,3 @@ this.rules = []; | ||
driver: { | ||
name: `${report.summary[0].commandName}`, | ||
name: `rehearsal report`, | ||
informationUri: 'https://github.com/rehearsal-js/rehearsal-js', | ||
@@ -157,3 +157,3 @@ rules: [], | ||
//So printing out the first timestamp and first ts version. | ||
text: `This is the result of ${report.summary[0].commandName} on your product against TypeScript ${report.summary[0].tsVersion} at ${report.summary[0].timestamp}`, | ||
text: `This is the result of running Rehearsal on your product against TypeScript ${report.summary[0].tsVersion} at ${report.summary[0].timestamp}`, | ||
}, | ||
@@ -165,3 +165,2 @@ }, | ||
SarifFormatter.extension = '.sarif'; | ||
export { SarifFormatter }; | ||
//# sourceMappingURL=sarif-formatter.js.map |
import { isAbsolute, resolve } from 'node:path'; | ||
import { SarifFormatter } from './sarif-formatter.js'; | ||
class SonarqubeFormatter { | ||
export class SonarqubeFormatter { | ||
// SonarQube Formatter will convert to SARIF first and then convert to SonarQube format | ||
@@ -69,3 +69,2 @@ // We have to assume the default Report shape | ||
SonarqubeFormatter.extension = '.sonarqube.json'; | ||
export { SonarqubeFormatter }; | ||
//# sourceMappingURL=sonarqube-formatter.js.map |
export * from './formatters/index.js'; | ||
export { Reporter } from './reporter.js'; | ||
export type { Location, Report, ReportItem, ReportSummary, ReportFormatter } from './types.js'; | ||
export { ReportItemType } from './types.js'; | ||
export type { Location, Report, ReportItem, ReportSummary, ReportFormatter, Formatters, } from './types.js'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './formatters/index.js'; | ||
export { Reporter } from './reporter.js'; | ||
export { ReportItemType } from './types.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -5,4 +5,3 @@ import type { Report, ReportItem, Location, LintErrorLike, Run, Formatters } from './types.js'; | ||
projectName: string; | ||
basePath: string; | ||
commandName: string; | ||
projectRootDir: string; | ||
tsVersion: string; | ||
@@ -30,8 +29,12 @@ stemName?: string; | ||
/** | ||
* Appends am information about provided diagnostic and related node to the report | ||
* Appends a information about provided TS diagnostic and related node to the report | ||
*/ | ||
addTSItemToRun(diagnostic: DiagnosticWithLocation, node?: Node, triggeringLocation?: Location, hint?: string, helpUrl?: string, hintAdded?: boolean): void; | ||
/** | ||
* Appends a information about provided Glint diagnostic and related node to the report | ||
*/ | ||
addGlintItemToRun(diagnostic: DiagnosticWithLocation, node?: Node, triggeringLocation?: Location, hint?: string, helpUrl?: string, hintAdded?: boolean): void; | ||
addLintItemToRun(fileName: string, lintError: LintErrorLike): void; | ||
incrementRunFixedItemCount(): void; | ||
saveCurrentRunToReport(runBasePath: string, runEntrypoint?: string, timestamp?: string): void; | ||
saveCurrentRunToReport(timestamp?: string): void; | ||
/** | ||
@@ -38,0 +41,0 @@ * Prints the reports using provided formatter |
@@ -11,6 +11,6 @@ import { join, isAbsolute, relative } from 'node:path'; | ||
constructor(meta) { | ||
const { projectName, basePath, commandName, tsVersion, previousFixedCount } = meta; | ||
const { projectName, projectRootDir, tsVersion, previousFixedCount } = meta; | ||
// do not include extension in the stemName | ||
this.stemName = meta.stemName || 'rehearsal-report'; | ||
this.basePath = basePath; | ||
this.basePath = projectRootDir; | ||
this.report = { | ||
@@ -22,3 +22,3 @@ summary: [], | ||
this.uniqueFiles = []; | ||
// runSummary !== summary | ||
// runSummary !== summary, | ||
// summary is a list of all runs | ||
@@ -31,5 +31,2 @@ // runSummary is a summary of the current run | ||
timestamp: '', | ||
basePath: '', | ||
entrypoint: '', | ||
commandName, | ||
}, | ||
@@ -53,3 +50,3 @@ fixedItemCount: 0, | ||
/** | ||
* Appends am information about provided diagnostic and related node to the report | ||
* Appends a information about provided TS diagnostic and related node to the report | ||
*/ | ||
@@ -71,2 +68,20 @@ addTSItemToRun(diagnostic, node, triggeringLocation, hint = '', helpUrl = '', hintAdded = true) { | ||
} | ||
/** | ||
* Appends a information about provided Glint diagnostic and related node to the report | ||
*/ | ||
addGlintItemToRun(diagnostic, node, triggeringLocation, hint = '', helpUrl = '', hintAdded = true) { | ||
this.currentRun.items.push({ | ||
analysisTarget: this.normalizeFilePath(this.basePath, diagnostic.file.fileName), | ||
type: 2, | ||
ruleId: `Glint${diagnostic.code}`, | ||
category: DiagnosticCategory[diagnostic.category], | ||
message: flattenDiagnosticMessageText(diagnostic.messageText, '. ').replace(this.basePath, '.'), | ||
hint: hint, | ||
hintAdded, | ||
nodeKind: node ? SyntaxKind[node.kind] : undefined, | ||
nodeText: node?.getText(), | ||
helpUrl, | ||
nodeLocation: triggeringLocation || undefined, | ||
}); | ||
} | ||
addLintItemToRun(fileName, lintError) { | ||
@@ -98,6 +113,4 @@ this.currentRun.items.push({ | ||
} | ||
saveCurrentRunToReport(runBasePath, runEntrypoint, timestamp) { | ||
saveCurrentRunToReport(timestamp) { | ||
this.currentRun.runSummary.timestamp = timestamp || this.getTimestamp(); | ||
this.currentRun.runSummary.basePath = runBasePath; | ||
this.currentRun.runSummary.entrypoint = runEntrypoint || ''; | ||
this.report.summary = [...this.report.summary, { ...this.currentRun.runSummary }]; | ||
@@ -179,4 +192,2 @@ this.report.fixedItemCount += this.currentRun.fixedItemCount; | ||
this.currentRun.runSummary.timestamp = ''; | ||
this.currentRun.runSummary.basePath = ''; | ||
this.currentRun.runSummary.entrypoint = ''; | ||
this.currentRun.fixedItemCount = 0; | ||
@@ -183,0 +194,0 @@ this.currentRun.items = []; |
export type Formatters = 'json' | 'sonarqube' | 'md' | 'sarif'; | ||
export type ReportSummary = Record<string, unknown> & { | ||
projectName: string; | ||
basePath: string; | ||
entrypoint: string; | ||
tsVersion: string; | ||
timestamp: string; | ||
commandName: string; | ||
}; | ||
@@ -18,3 +15,4 @@ export interface Location { | ||
ts = 0, | ||
lint = 1 | ||
lint = 1, | ||
glint = 2 | ||
} | ||
@@ -21,0 +19,0 @@ export type ReportItem = { |
@@ -5,3 +5,4 @@ export var ReportItemType; | ||
ReportItemType[ReportItemType["lint"] = 1] = "lint"; | ||
})(ReportItemType = ReportItemType || (ReportItemType = {})); | ||
ReportItemType[ReportItemType["glint"] = 2] = "glint"; | ||
})(ReportItemType || (ReportItemType = {})); | ||
// ts doesnt allow for static properties on interfaces yet | ||
@@ -8,0 +9,0 @@ export class FormatterBase { |
{ | ||
"name": "@rehearsal/reporter", | ||
"version": "2.0.2-beta", | ||
"version": "2.1.0", | ||
"description": "Rehearsal Reporter", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"@types/sarif": "^2.1.4", | ||
"@vitest/coverage-c8": "^0.30.1", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"fs-extra": "^11.1.1", | ||
@@ -40,5 +40,5 @@ "vitest": "^0.30.0", | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
"typescript": "^5.1" | ||
}, | ||
"packageManager": "pnpm@8.2.0", | ||
"packageManager": "pnpm@8.6.7", | ||
"engines": { | ||
@@ -56,3 +56,2 @@ "node": ">=14.16.0" | ||
"test": "vitest --run --config ./vitest.config.ts --coverage", | ||
"test:slow": "vitest --run", | ||
"test:watch": "vitest --coverage --watch", | ||
@@ -59,0 +58,0 @@ "version": "pnpm version" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
89834
648
1