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

fix: plugin warnings not showing warning.loc #3824

Merged
merged 4 commits into from Oct 21, 2020
Merged
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions cli/run/batchWarnings.ts
Expand Up @@ -196,6 +196,9 @@ const deferredHandlers: {
}
stderr(bold(loc));
}
else if (warning.loc) {
info(yellow(`${rollup.relativeId(warning.loc.file)}:${warning.loc.line}:${warning.loc.column}`)+' error '+message);
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm. not happy about this being the only non-title being formatted in yellow, couldn't we stick with the formatting used in the previous case? Also why do you want to repeat the error message that has just been written in the title? Moreover, file is optional in .loc, and this only makes sense if file is actually present otherwise you would not know what the location means.

Also this repeats the way that locations are formatted from the previous section, but in a slightly inconsistent way with regard to spacing. Here would be one suggestion to replace everything starting from line 192 with less duplication:

const id = warning.id || warning.loc?.file;
if (id) {
  let loc = relativeId(id);
  if (warning.loc) {
    loc += `: (${warning.loc.line}:${warning.loc.column})`;
  }
  stderr(bold(loc));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lukas, I changed the code as you suggested.
I won't be able to add tests.

if (warning.frame) info(warning.frame);
}
}
Expand Down