From 319da1a936df5c08a80363280f09d9e39d7a02f2 Mon Sep 17 00:00:00 2001 From: Denis Seleznev Date: Mon, 23 Mar 2020 22:27:09 +0300 Subject: [PATCH 1/3] Fix typos --- lib/utils.js | 2 +- lib/yaspeller.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 10337a8..8103ded 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -46,7 +46,7 @@ module.exports = { } } } else { - throw new Error(file + ': is not utf-8.'); + throw new Error(file + ': is not UTF-8.'); } } else if (throwIfFileNotExists) { throw new Error(file + ': is not exists.'); diff --git a/lib/yaspeller.js b/lib/yaspeller.js index af407a4..2439901 100644 --- a/lib/yaspeller.js +++ b/lib/yaspeller.js @@ -206,7 +206,7 @@ function checkFile(file, callback, settings) { ); }, settings); } else { - callback(true, Error(file + ': is not utf-8')); + callback(true, Error(file + ': is not UTF-8')); } } else { callback(true, Error(file + ': is not file')); From c3cad7cd152a94425ade5318063219389c72c736 Mon Sep 17 00:00:00 2001 From: Denis Seleznev Date: Mon, 23 Mar 2020 22:27:24 +0300 Subject: [PATCH 2/3] Print a typo warning at the end if there are typos --- lib/report.js | 24 +++++++++++++++--------- lib/report/console.js | 10 +++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/report.js b/lib/report.js index 06c8368..9a00196 100644 --- a/lib/report.js +++ b/lib/report.js @@ -5,9 +5,10 @@ const program = require('commander'); const pth = require('path'); const stats = { + errors: 0, + hasTypos: false, + ok: 0, total: 0, - errors: 0, - ok: 0 }; const reports = []; const reportNames = {}; @@ -35,25 +36,30 @@ module.exports = { name.onstart && name.onstart(); }); }, - oneach(err, data, dictionary) { - var isError = err || (!err && data.data && data.data.length); + oneach(hasError, data, dictionary) { + const hasTypos = Boolean(data && data.data && data.data.length); + stats.total++; - if (isError) { + if (hasError || hasTypos) { stats.errors++; - buffer.push([err, data]); + if (hasTypos) { + stats.hasTypos = true; + } + + buffer.push([hasError, data]); } else { stats.ok++; if (!program.onlyErrors) { - buffer.push([err, data]); + buffer.push([hasError, data]); } } - if ((program.onlyErrors && isError) || !program.onlyErrors) { + if (!program.onlyErrors || hasError || hasTypos) { reports.forEach(function(name) { - name.oneach && name.oneach(err, data, dictionary); + name.oneach && name.oneach(hasError, data, dictionary); }); } }, diff --git a/lib/report/console.js b/lib/report/console.js index 07b64eb..be22ef1 100644 --- a/lib/report/console.js +++ b/lib/report/console.js @@ -83,7 +83,7 @@ module.exports = { }, onend(data, stats, configPath) { if (!program.onlyErrors && stats.total) { - if (stats.errors) { + if (stats.hasTypos) { let path = configPath + ' ('; if (configPath.search(/package\.json/) !== -1) { path += '"yaspeller"→'; @@ -91,11 +91,15 @@ module.exports = { path += '"dictionary" property)'; console.log(chalk.yellow(`Fix typo or add word to dictionary at ${path} if you are sure about spelling. Docs: ${packageJson.homepage}#configuration`)); - } else { + } + + if (!stats.errors) { console.log(chalk.green('No errors.')); } - console.log(chalk.magenta('Checking finished: ' + utils.uptime())); + if (program.debug) { + console.log(chalk.magenta('Checking finished: ' + utils.uptime())); + } } } }; From 68b772796720947d12a1d6c3003ed5ccc02233a3 Mon Sep 17 00:00:00 2001 From: Denis Seleznev Date: Mon, 23 Mar 2020 22:27:38 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4107407..2f08fb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v6.0.3 +- Fix: print a typo warning at the end if there are typos #121. +- Updated deps in package.json. + ## v6.0.2 - Updated deps in package.json.