From d5d4ac1841d7de030d449ba267056d44da16f30e Mon Sep 17 00:00:00 2001 From: Grant Cox Date: Wed, 22 May 2024 14:47:58 +0200 Subject: [PATCH] fix: output report generation (#355) * fix: output report generation * test: fix --------- Co-authored-by: Ricardo Gobbo de Souza --- src/linter.js | 12 ++++++------ test/output-report.test.js | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/linter.js b/src/linter.js index 296b47b..6c8c1b0 100644 --- a/src/linter.js +++ b/src/linter.js @@ -152,12 +152,12 @@ function linter(key, options, compilation) { return; } - const content = outputReport.formatter; - (await loadFormatter(stylelint, outputReport.formatter))( - results, - returnValue, - ); - formatter(results, returnValue); + const content = outputReport.formatter + ? (await loadFormatter(stylelint, outputReport.formatter))( + results, + returnValue, + ) + : formatter(results, returnValue); let { filePath } = outputReport; if (!isAbsolute(filePath)) { diff --git a/test/output-report.test.js b/test/output-report.test.js index b885bb7..3531df5 100644 --- a/test/output-report.test.js +++ b/test/output-report.test.js @@ -1,6 +1,6 @@ import { join } from 'path'; -import { existsSync } from 'fs-extra'; +import { existsSync, readFileSync } from 'fs-extra'; import pack from './utils/pack'; @@ -28,5 +28,8 @@ describe('output report', () => { expect(stats.hasWarnings()).toBe(false); expect(stats.hasErrors()).toBe(true); expect(existsSync(filePath)).toBe(true); + expect(JSON.parse(readFileSync(filePath, 'utf8'))).toMatchObject([ + { source: expect.stringContaining('test.scss') }, + ]); }); });