Skip to content

Commit

Permalink
Remove postcss-reporter package (#4858)
Browse files Browse the repository at this point in the history
* Remove `postcss-reporter` package

This change removes the `postcss-reporter` package and reduces the dependencies.
As you see the changed `package-lock.json`, this package depends on:

- `chalk`
- `lodash`
- `log-symbols`
- `postcss`

See also #2454 (comment)

We've used only the tiny utility function `getLocation()` in the package.
This function just returns an object with the `line` and `column` property in our project,
so I think we can replace it with a simple code.

https://github.com/postcss/postcss-reporter/blob/f01a601ea2cd41d626e561969d66a765b3afcb2d/lib/util.js#L4-L13

* Fix test name: `stringFormatter` -> `verboseFormatter`
  • Loading branch information
ybiquitous committed Jul 17, 2020
1 parent 5a94294 commit cecacb9
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 41 deletions.
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() : '',
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

0 comments on commit cecacb9

Please sign in to comment.