From 200822086343953c96aa7b131ba0f530814a56e8 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 ------------------- ...isableOptionsReportStringFormatter.test.js | 52 ----------------- .../disableOptionsReportStringFormatter.js | 47 ---------------- 3 files changed, 155 deletions(-) delete mode 100644 lib/formatters/__tests__/disableOptionsReportStringFormatter.test.js 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/__tests__/disableOptionsReportStringFormatter.test.js b/lib/formatters/__tests__/disableOptionsReportStringFormatter.test.js deleted file mode 100644 index a55249e46c..0000000000 --- a/lib/formatters/__tests__/disableOptionsReportStringFormatter.test.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const disableOptionsReportStringFormatterTest = require('../disableOptionsReportStringFormatter'); -const stripAnsi = require('strip-ansi'); - -describe('disableOptionsReportStringFormatter', () => { - it('formatter stringified', () => { - const actual = stripAnsi( - disableOptionsReportStringFormatterTest( - [ - { - source: 'foo', - ranges: [ - { start: 1, end: 3, rule: 'baz' }, - { start: 7, rule: 'all' }, - ], - }, - { - source: 'bar', - ranges: [ - { start: 19, end: 33, rule: 'all' }, - { start: 99, end: 102, rule: 'baz' }, - ], - }, - { - sourc: 'baz', - ranges: [], - }, - ], - 'wrong disable', - ), - ); - - const expected = ` -foo -wrong disable: baz, start line: 1, end line: 3 -wrong disable: all, start line: 7 - -bar -wrong disable: all, start line: 19, end line: 33 -wrong disable: baz, start line: 99, end line: 102 -`; - - expect(actual).toBe(expected); - }); - - it('empty report', () => { - const actual = stripAnsi(disableOptionsReportStringFormatterTest()); - - expect(actual).toBe(''); - }); -}); 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; -};