Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove postcss-reporter package #4858

Merged
merged 3 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/formatters/__tests__/verboseFormatter.test.js
Expand Up @@ -4,7 +4,7 @@ const prepareFormatterOutput = require('./prepareFormatterOutput');
const stripIndent = require('common-tags').stripIndent;
const verboseFormatter = require('../verboseFormatter');

describe('stringFormatter', () => {
describe('verboseFormatter', () => {
it('outputs no warnings', () => {
const results = [
{
Expand Down
7 changes: 3 additions & 4 deletions lib/formatters/stringFormatter.js
Expand Up @@ -6,7 +6,6 @@ const path = require('path');
const stringWidth = require('string-width');
const symbols = require('log-symbols');
const table = require('table');
const utils = require('postcss-reporter/lib/util');

const MARGIN_WIDTHS = 9;

Expand Down Expand Up @@ -134,14 +133,14 @@ function formatter(messages, source) {
}

const cleanedMessages = orderedMessages.map((message) => {
const location = utils.getLocation(message);
const { line, column } = message;
const severity = /** @type {keyof import('log-symbols')} */ (message.severity);
/**
* @type {[string, string, string, string, string]}
*/
const row = [
location.line ? location.line.toString() : '',
location.column ? location.column.toString() : '',
line ? line.toString() : '',
column ? column.toString() : '',
Comment on lines +142 to +143
Copy link
Member Author

@ybiquitous ybiquitous Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[note] The message variable is a StylelintWarning, so checking null seems needless:

export type StylelintWarning = {
line: number;
column: number;

Suggested change
line ? line.toString() : '',
column ? column.toString() : '',
line.toString(),
column.toString(),

But, if changing it, the following test fails:

 FAIL  lib/formatters/__tests__/verboseFormatter.test.js
  stringFormatter
    ✓ outputs no warnings (3 ms)
    ✓ outputs one warnings (of severity 'error') (6 ms)
    ✓ outputs 0 stdout column (1 ms)
    ✓ outputs less than 80 stdout column (1 ms)
    ✓ outputs two of the same warnings of 'error' and one of 'warning' across two files (3 ms)
    ✕ outputs lineless syntax error
    ✓ outputs one ignored file

  ● stringFormatter › outputs lineless syntax error

    TypeError: Cannot read property 'toString' of undefined

      140 | 		 */
      141 | 		const row = [
    > 142 | 			line.toString(),
          | 			     ^
      143 | 			column.toString(),
      144 | 			symbols[severity]
      145 | 				? chalk[/** @type {'blue' | 'red' | 'yellow'} */ (levelColors[severity])](symbols[severity])

In this case, the failed test case seems wrong (should have lines and columns?), but I'm not confident whether I should fix it: 😓

warnings: [
{
rule: 'SyntaxError',
severity: 'error',
text: 'Unexpected foo',
},
],

symbols[severity]
? chalk[/** @type {'blue' | 'red' | 'yellow'} */ (levelColors[severity])](symbols[severity])
: severity,
Expand Down
31 changes: 0 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -139,7 +139,6 @@
"postcss-html": "^0.36.0",
"postcss-less": "^3.1.4",
"postcss-media-query-parser": "^0.2.3",
"postcss-reporter": "^6.0.1",
"postcss-resolve-nested-selector": "^0.1.1",
"postcss-safe-parser": "^4.0.2",
"postcss-sass": "^0.4.4",
Expand Down
4 changes: 0 additions & 4 deletions types/postcss/index.d.ts
Expand Up @@ -33,10 +33,6 @@ declare module 'postcss-syntax' {
export = result;
}

declare module 'postcss-reporter/lib/util' {
export function getLocation(message: Object): { line: number; column: number; file?: string };
}

declare module 'postcss/lib/result' {
import { Result } from 'postcss';

Expand Down