This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
10 changed files
with
445 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @fileoverview Compact reporter | ||
* @author Nicholas C. Zakas | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Helper Functions | ||
//------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Returns the severity of warning or error | ||
* @param {Object} message message object to examine | ||
* @returns {string} severity level | ||
* @private | ||
*/ | ||
function getMessageType(message) { | ||
if (message.fatal || message.severity === 2) { | ||
return "Error"; | ||
} | ||
return "Warning"; | ||
|
||
} | ||
|
||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(results) { | ||
|
||
let output = "", | ||
total = 0; | ||
|
||
results.forEach(result => { | ||
|
||
const messages = result.messages; | ||
|
||
total += messages.length; | ||
|
||
messages.forEach(message => { | ||
|
||
output += `${result.filePath}: `; | ||
output += `line ${message.line || 0}`; | ||
output += `, col ${message.column || 0}`; | ||
output += `, ${getMessageType(message)}`; | ||
output += ` - ${message.message}`; | ||
output += message.ruleId ? ` (${message.ruleId})` : ""; | ||
output += "\n"; | ||
|
||
}); | ||
|
||
}); | ||
|
||
if (total > 0) { | ||
output += `\n${total} problem${total !== 1 ? "s" : ""}`; | ||
} | ||
|
||
return output; | ||
}; |
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,13 @@ | ||
/** | ||
* @fileoverview JSON reporter | ||
* @author Burak Yigit Kaya aka BYK | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(results) { | ||
return JSON.stringify(results); | ||
}; |
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,112 @@ | ||
/* | ||
Copyright JS Foundation and other contributors, https://js.foundation | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
/* | ||
* This code is taken from the eslint repo | ||
* (https://github.com/eslint/eslint) | ||
* and modified to meet our needs. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const chalk = require('chalk'), | ||
stripAnsi = require('strip-ansi'), | ||
table = require('text-table'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Helpers | ||
//------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Given a word and a count, append an s if count is not one. | ||
* @param {string} word A word in its singular form. | ||
* @param {int} count A number controlling whether word should be pluralized. | ||
* @returns {string} The original word with an s on the end if count is not one. | ||
*/ | ||
function pluralize(word, count) { | ||
return (count === 1 ? word : `${word}s`); | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(results) { | ||
|
||
let output = '\n', | ||
errorCount = 0, | ||
warningCount = 0, | ||
summaryColor = 'yellow'; | ||
|
||
results.forEach(result => { | ||
const messages = result.messages; | ||
|
||
if (messages.length === 0) { | ||
return; | ||
} | ||
|
||
errorCount += result.errorCount; | ||
warningCount += result.warningCount; | ||
|
||
output += `${chalk.underline(result.filePath)}\n`; | ||
|
||
output += `${table( | ||
messages.map(message => { | ||
let messageType; | ||
if (message.fatal || message.severity === 2) { | ||
messageType = chalk.red('error'); | ||
summaryColor = 'red'; | ||
} else { | ||
messageType = chalk.yellow('warning'); | ||
} | ||
return [ | ||
'', | ||
message.line || 0, | ||
message.column || 0, | ||
messageType, | ||
message.message.replace(/\.$/, ''), | ||
chalk.dim(message.ruleId || '') | ||
]; | ||
}), | ||
{ | ||
align: ['', 'r', 'l'], | ||
stringLength(str) { | ||
return stripAnsi(str).length; | ||
} | ||
} | ||
).split('\n').map(el => el.replace(/(\d+)\s+(\d+)/, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join('\n')}\n\n`; | ||
}); | ||
|
||
const total = errorCount + warningCount; | ||
|
||
if (total > 0) { | ||
output += chalk[summaryColor].bold([ | ||
'\u2716 ', total, pluralize(' problem', total), | ||
' (', errorCount, pluralize(' error', errorCount), ', ', | ||
warningCount, pluralize(' warning', warningCount), ')\n' | ||
].join('')); | ||
} | ||
|
||
return total > 0 ? output : ''; | ||
}; |
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,58 @@ | ||
/** | ||
* @fileoverview unix-style formatter. | ||
* @author oshi-shinobu | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Helper Functions | ||
//------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Returns a canonical error level string based upon the error message passed in. | ||
* @param {Object} message Individual error message provided by eslint | ||
* @returns {string} Error level string | ||
*/ | ||
function getMessageType(message) { | ||
if (message.fatal || message.severity === 2) { | ||
return "Error"; | ||
} | ||
return "Warning"; | ||
|
||
} | ||
|
||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = function(results) { | ||
|
||
let output = "", | ||
total = 0; | ||
|
||
results.forEach(result => { | ||
|
||
const messages = result.messages; | ||
|
||
total += messages.length; | ||
|
||
messages.forEach(message => { | ||
|
||
output += `${result.filePath}:`; | ||
output += `${message.line || 0}:`; | ||
output += `${message.column || 0}:`; | ||
output += ` ${message.message} `; | ||
output += `[${getMessageType(message)}${message.ruleId ? `/${message.ruleId}` : ""}]`; | ||
output += "\n"; | ||
|
||
}); | ||
|
||
}); | ||
|
||
if (total > 0) { | ||
output += `\n${total} problem${total !== 1 ? "s" : ""}`; | ||
} | ||
|
||
return output; | ||
}; |
Oops, something went wrong.