From e6530b53944155654f99f5385d758d5726b7143b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 15 Jan 2019 12:59:54 -0800 Subject: [PATCH] Chore: use local function to append "s" instead of a package This matches the way other formatters handle pluralization, which seems simple enough to not require an additional package. --- lib/formatters/table.js | 17 +++++++++++++---- package.json | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/formatters/table.js b/lib/formatters/table.js index ebc3314e7ad..a74cce0d516 100644 --- a/lib/formatters/table.js +++ b/lib/formatters/table.js @@ -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} 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: { diff --git a/package.json b/package.json index 373c51776b4..0ab92b6c3fc 100644 --- a/package.json +++ b/package.json @@ -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",