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 weird lint output #1226

Merged
merged 1 commit into from
Dec 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/react-dev-utils/formatWebpackMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ function isLikelyASyntaxError(message) {
function formatMessage(message) {
var lines = message.split('\n');

// line #0 is filename
// line #1 is the main error message
if (!lines[0] || !lines[1]) {
return message;
}

// Remove webpack-specific loader notation from filename.
// Before:
// ./~/css-loader!./~/postcss-loader!./src/App.css
Expand All @@ -39,6 +33,12 @@ function formatMessage(message) {
lines[0] = lines[0].substr(lines[0].lastIndexOf('!') + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line would crash if lines had no elements.
I think it should be if (lines[0] && ...

Copy link
Contributor Author

@n3tr n3tr Dec 10, 2016

Choose a reason for hiding this comment

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

I don't think it would crash since lines come from message.split('\n'); and it should has at least one element of empty string.

We're also checking if (lines[0].lastIndexOf('!') !== -1) (line 38) and it would be false if lines[0] is an empty string.

}

// line #0 is filename
// line #1 is the main error message
if (!lines[0] || !lines[1]) {
return lines.join('\n');
}

// Cleans up verbose "module not found" messages for files and packages.
if (lines[1].indexOf('Module not found: ') === 0) {
lines = [
Expand Down