Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ben-lau/eslint-webpack-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Jun 22, 2022
2 parents f7d3221 + e56d117 commit 4ab48f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ESLintError.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ESLintError extends Error {
* @param {string=} messages
*/
constructor(messages) {
super(messages);
super(`[eslint] ${messages}`);
this.name = 'ESLintError';
this.stack = '';
}
Expand Down
3 changes: 2 additions & 1 deletion src/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ function linter(key, options, compilation) {
}
rawResults.push(
lintFiles(files).catch((e) => {
compilation.errors.push(e);
// @ts-ignore
compilation.errors.push(new ESLintError(e.message));
return [];
})
);
Expand Down
8 changes: 6 additions & 2 deletions test/formatter-custom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ describe('formatter eslint', () => {
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
expect(stats.compilation.errors[0].message).toBeTruthy();
const message = JSON.parse(stats.compilation.errors[0].message);
const message = JSON.parse(
stats.compilation.errors[0].message.replace('[eslint] ', '')
);
expect(message.formatter).toEqual('mock');
expect(message.results).toBeTruthy();
done();
Expand All @@ -26,7 +28,9 @@ describe('formatter eslint', () => {
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
expect(stats.compilation.errors[0].message).toBeTruthy();
const message = JSON.parse(stats.compilation.errors[0].message);
const message = JSON.parse(
stats.compilation.errors[0].message.replace('[eslint] ', '')
);
expect(message.formatter).toEqual('mock');
expect(message.results).toBeTruthy();
done();
Expand Down
4 changes: 2 additions & 2 deletions test/formatter-write.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('formatter write', () => {
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
expect(stats.compilation.errors[0].message).toBe(contents);
expect(stats.compilation.errors[0].message).toBe(`[eslint] ${contents}`);
done();
});
});
Expand All @@ -49,7 +49,7 @@ describe('formatter write', () => {
expect(err).toBeNull();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
expect(stats.compilation.errors[0].message).toBe(contents);
expect(stats.compilation.errors[0].message).toBe(`[eslint] ${contents}`);
done();
});
});
Expand Down

0 comments on commit 4ab48f8

Please sign in to comment.