Skip to content

Commit

Permalink
Chore: use local function to append "s" instead of a package (#11293)
Browse files Browse the repository at this point in the history
This matches the way other formatters handle pluralization, which
seems simple enough to not require an additional package.
  • Loading branch information
Krinkle authored and btmills committed Feb 1, 2019
1 parent b5143bf commit 91c8884
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions lib/formatters/table.js
Expand Up @@ -9,13 +9,22 @@
//------------------------------------------------------------------------------

const chalk = require("chalk"),
table = require("table").table,
pluralize = require("pluralize");
table = require("table").table;

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

/**
* Given a word and a count, append an "s" if count is not one.
* @param {string} word A word.
* @param {number} count Quantity.
* @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`);
}

/**
* Draws text table.
* @param {Array<Object>} messages Error messages relating to a specific file.
Expand Down Expand Up @@ -129,10 +138,10 @@ module.exports = function(report) {

result += `\n${table([
[
chalk.red(pluralize("Error", errorCount, true))
chalk.red(pluralize(`${errorCount} Error`, errorCount))
],
[
chalk.yellow(pluralize("Warning", warningCount, true))
chalk.yellow(pluralize(`${warningCount} Warning`, warningCount))
]
], {
columns: {
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -64,7 +64,6 @@
"natural-compare": "^1.4.0",
"optionator": "^0.8.2",
"path-is-inside": "^1.0.2",
"pluralize": "^7.0.0",
"progress": "^2.0.0",
"regexpp": "^2.0.1",
"semver": "^5.5.1",
Expand Down

0 comments on commit 91c8884

Please sign in to comment.