From ed1db90c6871399079a5fb55957f6b54cde5daff Mon Sep 17 00:00:00 2001 From: Julien Marchand Date: Wed, 20 Feb 2019 05:39:25 -0800 Subject: [PATCH] Honor stdin-filepath when outputting error messages. (#5878) --- CHANGELOG.unreleased.md | 2 ++ src/cli/util.js | 2 +- .../__tests__/__snapshots__/stdin-filepath.js.snap | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 938516c56..2131c474c 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -42,6 +42,8 @@ Examples: --> +- CLI: Honor stdin-filepath when outputting error messages. + - Markdown: Do not align table contents if it exceeds the print width and `--prose-wrap never` is set ([#5701] by [@chenshuai2144]) The aligned table is less readable than the compact one diff --git a/src/cli/util.js b/src/cli/util.js index bec6b2de7..7fb645381 100644 --- a/src/cli/util.js +++ b/src/cli/util.js @@ -383,7 +383,7 @@ function formatStdin(context) { writeOutput(context, format(context, input, options), options); } catch (error) { - handleError(context, "stdin", error); + handleError(context, relativeFilepath || "stdin", error); } }); } diff --git a/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap b/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap index eded2d6a4..a109655c8 100644 --- a/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap +++ b/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap @@ -16,7 +16,7 @@ exports[`output file as-is if stdin-filepath matched patterns in ignore-path (st exports[`output file as-is if stdin-filepath matched patterns in ignore-path (write) 1`] = `Array []`; exports[`throw error if stdin content incompatible with stdin-filepath (stderr) 1`] = ` -"[error] stdin: SyntaxError: Unexpected token (1:1) +"[error] abc.js: SyntaxError: Unexpected token (1:1) [error] > 1 | .name { display: none; } [error] | ^ "