Skip to content

Commit b76bc00

Browse files
Krinklebtmills
authored andcommitted
Chore: use local function to append "s" instead of a package (#11293)
This matches the way other formatters handle pluralization, which seems simple enough to not require an additional package.
1 parent f4bf701 commit b76bc00

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
//------------------------------------------------------------------------------
1010

1111
const chalk = require("chalk"),
12-
table = require("table").table,
13-
pluralize = require("pluralize");
12+
table = require("table").table;
1413

1514
//------------------------------------------------------------------------------
1615
// Helpers
1716
//------------------------------------------------------------------------------
1817

18+
/**
19+
* Given a word and a count, append an "s" if count is not one.
20+
* @param {string} word A word.
21+
* @param {number} count Quantity.
22+
* @returns {string} The original word with an s on the end if count is not one.
23+
*/
24+
function pluralize(word, count) {
25+
return (count === 1 ? word : `${word}s`);
26+
}
27+
1928
/**
2029
* Draws text table.
2130
* @param {Array<Object>} messages Error messages relating to a specific file.
@@ -129,10 +138,10 @@ module.exports = function(report) {
129138

130139
result += `\n${table([
131140
[
132-
chalk.red(pluralize("Error", errorCount, true))
141+
chalk.red(pluralize(`${errorCount} Error`, errorCount))
133142
],
134143
[
135-
chalk.yellow(pluralize("Warning", warningCount, true))
144+
chalk.yellow(pluralize(`${warningCount} Warning`, warningCount))
136145
]
137146
], {
138147
columns: {

0 commit comments

Comments
 (0)