Skip to content

Commit a82ca60

Browse files
committed
Order lint warnings by most recently edited file (facebook#2378)
1 parent e6ddfb0 commit a82ca60

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/react-dev-utils/WebpackDevServerUtils.js

+23
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ function createCompiler(webpack, config, appName, urls, useYarn) {
139139

140140
let isFirstCompile = true;
141141

142+
compiler.plugin('after-compile', (compilation, callback) => {
143+
// Order compilation warnings by most recently modified
144+
compilation.warnings = [
145+
...compilation.warnings,
146+
].sort((warning1, warning2) => {
147+
if (!warning1._lastModifiedDate) {
148+
warning1._lastModifiedDate = fs.statSync(
149+
warning1.module.resource
150+
).mtime;
151+
}
152+
153+
if (!warning2._lastModifiedDate) {
154+
warning2._lastModifiedDate = fs.statSync(
155+
warning2.module.resource
156+
).mtime;
157+
}
158+
159+
return warning1._lastModifiedDate < warning2._lastModifiedDate ? 1 : -1;
160+
});
161+
162+
callback();
163+
});
164+
142165
// "done" event fires when Webpack has finished recompiling the bundle.
143166
// Whether or not you have warnings or errors, you will get this event.
144167
compiler.plugin('done', stats => {

0 commit comments

Comments
 (0)