Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9420026
commit 2a89b2d
Showing
8 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const githubFormatter = require('../githubFormatter'); | ||
|
||
test('githubFormatter', () => { | ||
const results = [ | ||
{ | ||
source: 'path/to/file.css', | ||
warnings: [ | ||
{ | ||
line: 1, | ||
column: 2, | ||
endLine: 1, | ||
endColumn: 5, | ||
rule: 'foo', | ||
severity: 'error', | ||
text: 'Unexpected "foo" (foo)', | ||
}, | ||
], | ||
}, | ||
{ | ||
source: 'a.css', | ||
warnings: [ | ||
{ | ||
line: 10, | ||
column: 20, | ||
rule: 'bar', | ||
severity: 'warning', | ||
text: 'Unexpected "bar" (bar)', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
expect(githubFormatter(results)) | ||
.toBe(`::error file=path/to/file.css,line=1,col=2,endLine=1,endColumn=5,title=Stylelint problem::Unexpected "foo" (foo) | ||
::warning file=a.css,line=10,col=20,title=Stylelint problem::Unexpected "bar" (bar)`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
/** | ||
* @see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions | ||
* | ||
* @type {import('stylelint').Formatter} | ||
*/ | ||
module.exports = function githubFormatter(results) { | ||
const title = 'Stylelint problem'; | ||
|
||
return results | ||
.flatMap(({ source, warnings }) => | ||
warnings.map(({ line, column, endLine, endColumn, text, severity }) => { | ||
return endLine === undefined | ||
? `::${severity} file=${source},line=${line},col=${column},title=${title}::${text}` | ||
: `::${severity} file=${source},line=${line},col=${column},endLine=${endLine},endColumn=${endColumn},title=${title}::${text}`; | ||
}), | ||
) | ||
.join('\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters