Permalink
Browse files

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.
  • Loading branch information...
Krinkle authored and btmills committed Feb 1, 2019
1 parent b5143bf commit 91c8884971f5e57f5f7490d8daf92c4a9a489836
Showing with 13 additions and 5 deletions.
  1. +13 −4 lib/formatters/table.js
  2. +0 −1 package.json
@@ -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.
@@ -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: {
@@ -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",

0 comments on commit 91c8884

Please sign in to comment.