diff --git a/package-lock.json b/package-lock.json index cfc959e..3bcbc25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10950,9 +10950,9 @@ } }, "node_modules/shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, "node_modules/side-channel": { @@ -20261,9 +20261,9 @@ "dev": true }, "shell-quote": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", - "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", "dev": true }, "side-channel": { diff --git a/src/ESLintError.js b/src/ESLintError.js index 74fa4a8..37dfb9f 100644 --- a/src/ESLintError.js +++ b/src/ESLintError.js @@ -3,7 +3,7 @@ class ESLintError extends Error { * @param {string=} messages */ constructor(messages) { - super(messages); + super(`[eslint] ${messages}`); this.name = 'ESLintError'; this.stack = ''; } diff --git a/src/linter.js b/src/linter.js index 119d2c3..1ed9b1a 100644 --- a/src/linter.js +++ b/src/linter.js @@ -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 []; }) ); diff --git a/test/formatter-custom.test.js b/test/formatter-custom.test.js index 8d19af9..cbd6fa0 100644 --- a/test/formatter-custom.test.js +++ b/test/formatter-custom.test.js @@ -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(); @@ -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(); diff --git a/test/formatter-write.test.js b/test/formatter-write.test.js index 41582da..e3a6019 100644 --- a/test/formatter-write.test.js +++ b/test/formatter-write.test.js @@ -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(); }); }); @@ -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(); }); });