From e02427f44b0b97579e4617774e08bf4c6fa74e6b Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 15 Oct 2020 11:44:52 +0300 Subject: [PATCH] Update eslintFormatter for eslint-webpack-plugin --- packages/react-dev-utils/eslintFormatter.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/react-dev-utils/eslintFormatter.js b/packages/react-dev-utils/eslintFormatter.js index cdef9c70b43..47b111f7568 100644 --- a/packages/react-dev-utils/eslintFormatter.js +++ b/packages/react-dev-utils/eslintFormatter.js @@ -7,10 +7,13 @@ 'use strict'; +const path = require('path'); const chalk = require('chalk'); const stripAnsi = require('strip-ansi'); const table = require('text-table'); +const cwd = process.cwd(); + function isError(message) { if (message.fatal || message.severity === 2) { return true; @@ -18,6 +21,10 @@ function isError(message) { return false; } +function getRelativePath(filePath) { + return path.relative(cwd, filePath); +} + function formatter(results) { let output = '\n'; let hasErrors = false; @@ -73,6 +80,10 @@ function formatter(results) { }, }); + // print the filename and relative path + output += `${getRelativePath(result.filePath)}\n`; + + // print the errors output += `${outputTable}\n\n`; });