From e02e477e153141a5cfda558b0535292cd6b8e294 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 4 Feb 2021 13:26:27 -0800 Subject: [PATCH] Remove unused disable-reporting code This was outmoded by #4973 --- lib/cli.js | 56 ------------------- .../disableOptionsReportStringFormatter.js | 47 ---------------- 2 files changed, 103 deletions(-) delete mode 100644 lib/formatters/disableOptionsReportStringFormatter.js diff --git a/lib/cli.js b/lib/cli.js index dc87a9f53e..958162c603 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -2,7 +2,6 @@ const chalk = require('chalk'); const checkInvalidCLIOptions = require('./utils/checkInvalidCLIOptions'); -const disableOptionsReportStringFormatter = require('./formatters/disableOptionsReportStringFormatter'); const EOL = require('os').EOL; const getFormatterOptionsText = require('./utils/getFormatterOptionsText'); const getModulePath = require('./utils/getModulePath'); @@ -495,61 +494,6 @@ module.exports = (argv) => { return standalone(options) .then((linted) => { - const reports = []; - - const report = disableOptionsReportStringFormatter( - linted.reportedDisables || [], - 'forbidden disable', - ); - - if (report) reports.push(report); - - if (reportNeedlessDisables) { - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - const report = disableOptionsReportStringFormatter( - linted.needlessDisables || [], - 'needless disable', - ); - - if (report) { - reports.push(report); - } - } - - if (reportInvalidScopeDisables) { - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - const report = disableOptionsReportStringFormatter( - linted.invalidScopeDisables || [], - 'disable with invalid scope', - ); - - if (report) { - reports.push(report); - } - } - - if (reportDescriptionlessDisables) { - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - const report = disableOptionsReportStringFormatter( - linted.descriptionlessDisables || [], - 'descriptionless disable', - ); - - if (report) { - reports.push(report); - } - } - - if (reports.length > 0) { - // TODO: Issue #4985 - // eslint-disable-next-line no-shadow - reports.forEach((report) => process.stdout.write(report)); - process.exitCode = EXIT_CODE_ERROR; - } - if (!linted.output) { return; } diff --git a/lib/formatters/disableOptionsReportStringFormatter.js b/lib/formatters/disableOptionsReportStringFormatter.js deleted file mode 100644 index 3c1fcebe6d..0000000000 --- a/lib/formatters/disableOptionsReportStringFormatter.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -const chalk = require('chalk'); -const path = require('path'); - -/** - * @param {string} fromValue - * @return {string} - */ -function logFrom(fromValue) { - if (fromValue.startsWith('<')) return fromValue; - - return path.relative(process.cwd(), fromValue).split(path.sep).join('/'); -} - -/** - * @param {import('stylelint').StylelintDisableOptionsReport} report - * @param {string} message - * @returns {string} - */ -module.exports = function (report, message) { - if (!report) return ''; - - let output = ''; - - report.forEach((sourceReport) => { - if (!sourceReport.ranges || sourceReport.ranges.length === 0) { - return; - } - - output += '\n'; - // eslint-disable-next-line prefer-template - output += chalk.underline(logFrom(sourceReport.source || '')) + '\n'; - - sourceReport.ranges.forEach((range) => { - output += `${message}: ${range.rule}, start line: ${range.start}`; - - if (range.end !== undefined) { - output += `, end line: ${range.end}`; - } - - output += '\n'; - }); - }); - - return output; -};