Skip to content

Commit

Permalink
Order lint warnings by most recently edited file (facebook#2378)
Browse files Browse the repository at this point in the history
  • Loading branch information
kombucha committed May 29, 2017
1 parent e6ddfb0 commit a82ca60
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/react-dev-utils/WebpackDevServerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,29 @@ function createCompiler(webpack, config, appName, urls, useYarn) {

let isFirstCompile = true;

compiler.plugin('after-compile', (compilation, callback) => {
// Order compilation warnings by most recently modified
compilation.warnings = [
...compilation.warnings,
].sort((warning1, warning2) => {
if (!warning1._lastModifiedDate) {
warning1._lastModifiedDate = fs.statSync(
warning1.module.resource
).mtime;
}

if (!warning2._lastModifiedDate) {
warning2._lastModifiedDate = fs.statSync(
warning2.module.resource
).mtime;
}

return warning1._lastModifiedDate < warning2._lastModifiedDate ? 1 : -1;
});

callback();
});

// "done" event fires when Webpack has finished recompiling the bundle.
// Whether or not you have warnings or errors, you will get this event.
compiler.plugin('done', stats => {
Expand Down

0 comments on commit a82ca60

Please sign in to comment.