Skip to content

Commit

Permalink
fix: output report generation (#355)
Browse files Browse the repository at this point in the history
* fix: output report generation

* test: fix

---------

Co-authored-by: Ricardo Gobbo de Souza <[email protected]>
  • Loading branch information
grantcox and ricardogobbosouza authored May 22, 2024
1 parent 32ffaed commit d5d4ac1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion test/output-report.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path';

import { existsSync } from 'fs-extra';
import { existsSync, readFileSync } from 'fs-extra';

import pack from './utils/pack';

Expand Down Expand Up @@ -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') },
]);
});
});

0 comments on commit d5d4ac1

Please sign in to comment.