Skip to content

Commit

Permalink
Merge pull request #645 from protofire/i624-fix-json-formatter-return…
Browse files Browse the repository at this point in the history
…-value

fix: return empty array instead of nothing when formatter is json
  • Loading branch information
dbale-altoros authored Mar 3, 2025
2 parents 6848335 + 0eeebac commit bb9509b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions e2e/formatters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ describe('e2e', function () {
expect(stdout.trim()).to.be.empty
expect(stderr).to.include('No files to lint! check glob arguments')
})
it('should return nothing when file exists and there is no error/warning', () => {
it('should return empty array when file exists and there is no error/warning', () => {
const { code, stdout } = shell.exec(
`${NODE}solhint ${PATH}contracts/Foo3.sol -f ${formatterType}${SUFFIX}`
)
expect(code).to.equal(EXIT_CODES.OK)
expect(stdout.trim()).to.be.empty
expect(stdout.trim()).to.equal('[]')
})
it('should make the output report with json formatter for Foo2', () => {
const { code, stdout } = shell.exec(
Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ module.exports = function (results) {

if (finalMessage) allMessages.push(finalMessage)

return allMessages.length > 0 ? JSON.stringify(allMessages) : ''
return JSON.stringify(allMessages)
}

0 comments on commit bb9509b

Please sign in to comment.