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') }, + ]); }); });