Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
"babel-loader-8": "npm:[email protected]",
"css-loader": "^2.1.1",
"eslint": "^5.16.0",
"eslint-7": "npm:eslint@^7.14.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-node": "^9.0.1",
"eslint-webpack-plugin": "^2.4.0",
"expect": "^24.8.0",
"jest": "^24.8.0",
"memory-fs": "^0.4.1",
Expand Down
4 changes: 2 additions & 2 deletions src/friendly-errors-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class FriendlyErrorsWebpackPlugin {
const nbErrors = topErrors.length;

const subtitle = severity === 'error' ?
`Failed to compile with ${nbErrors} ${severity}s` :
`Compiled with ${nbErrors} ${severity}s`;
`Failed to compile with ${nbErrors} ${severity}${nbErrors === 1 ? '' : 's'}` :
`Compiled with ${nbErrors} ${severity}${nbErrors === 1 ? '' : 's'}`;
output.title(severity, severity.toUpperCase(), subtitle);

if (this.onErrors) {
Expand Down
2 changes: 0 additions & 2 deletions src/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ class Debugger {
this.capture();
fun.call();
return this.capturedMessages;
} catch (e) {
Copy link
Author

Choose a reason for hiding this comment

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

I installed eslint@7, some packages related to eslint rule may be also updated, so I get
error Unnecessary catch clause no-useless-catch

throw e;
} finally {
this.endCapture();
}
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/esLintError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

function isEslintError (e) {
return e.originalStack
.some(stackframe => stackframe.fileName && stackframe.fileName.indexOf('eslint-loader') > 0);
.some(stackframe => stackframe.fileName && stackframe.fileName.indexOf('eslint-loader') > 0) ||
e.name === 'ESLintError';
}

function transform(error) {
Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/eslint-webpack-plugin-warnings/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"root": true,
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
// http://eslint.org/docs/rules/
"no-unused-expressions": "warn",
"no-unused-labels": "warn",
"no-unused-vars": ["warn", { "vars": "local", "args": "none" }]
}
}
4 changes: 4 additions & 0 deletions test/fixtures/eslint-webpack-plugin-warnings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require('./module');

const unused = 'I am unused';
const unused2 = 'I am unused too';
1 change: 1 addition & 0 deletions test/fixtures/eslint-webpack-plugin-warnings/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const unused = 'I am unused';
26 changes: 26 additions & 0 deletions test/fixtures/eslint-webpack-plugin-warnings/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const FriendlyErrorsWebpackPlugin = require('../../../index');
const ESLintPlugin = require('eslint-webpack-plugin');

module.exports = {
mode: 'development',
entry: __dirname + "/index.js",
output: {
path: __dirname + "/dist",
filename: "bundle.js"
},
plugins: [
new FriendlyErrorsWebpackPlugin(),
new ESLintPlugin({
eslintPath: require.resolve('eslint-7')
})
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: require.resolve('babel-loader-7'),
}
]
},
};
34 changes: 28 additions & 6 deletions test/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,34 @@ Use /* eslint-disable */ to ignore all warnings in a file.`
)
});

it('integration : should display eslint-webpack-plugin warnings', async() => {

const logs = await executeAndGetLogs('./fixtures/eslint-webpack-plugin-warnings/webpack.config.js');

expect(logs.join('\n')).toEqual(
`WARNING Compiled with 1 warning

${filename('fixtures/eslint-webpack-plugin-warnings/index.js')}
3:7 warning 'unused' is assigned a value but never used no-unused-vars
4:7 warning 'unused2' is assigned a value but never used no-unused-vars

${filename('fixtures/eslint-webpack-plugin-warnings/module.js')}
1:7 warning 'unused' is assigned a value but never used no-unused-vars

✖ 3 problems (0 errors, 3 warnings)

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.`
)
});

it('integration : babel syntax error with babel-loader 7 (babel 6)', async() => {

const logs = await executeAndGetLogs('./fixtures/babel-syntax-babel-6/webpack.config');

expect(logs).toEqual([
'ERROR Failed to compile with 1 errors',
'ERROR Failed to compile with 1 error',
'',
'error in ./test/fixtures/babel-syntax-babel-6/index.js',
'',
Expand All @@ -118,7 +140,7 @@ it('integration : babel syntax error with babel-loader 8 (babel 7)', async() =>
const logs = await executeAndGetLogs('./fixtures/babel-syntax-babel-7/webpack.config');

expect(logs).toEqual([
'ERROR Failed to compile with 1 errors',
'ERROR Failed to compile with 1 error',
'',
'error in ./test/fixtures/babel-syntax-babel-7/index.js',
'',
Expand All @@ -139,7 +161,7 @@ it('integration : mini CSS extract plugin babel error', async() => {
const logs = await executeAndGetLogs('./fixtures/mini-css-extract-babel-syntax/webpack.config');
const clean_logs = logs.toString().replace(/\"/g, ""); //<- double quotes issue with slash
expect(clean_logs).toEqual(
`ERROR Failed to compile with 1 errors,,error in ./test/fixtures/mini-css-extract-babel-syntax/index.scss,,.test {
`ERROR Failed to compile with 1 error,,error in ./test/fixtures/mini-css-extract-babel-syntax/index.scss,,.test {
^
Expected digit.
Expand Down Expand Up @@ -186,7 +208,7 @@ it('integration : postcss-loader : warnings', async() => {

const logs = await executeAndGetLogs('./fixtures/postcss-warnings/webpack.config');
expect(logs).toEqual([
'WARNING Compiled with 1 warnings',
'WARNING Compiled with 1 warning',
'',
'warning in ./test/fixtures/postcss-warnings/index.css',
'',
Expand All @@ -202,7 +224,7 @@ it('integration : postcss-loader : warnings (multi-compiler version)', async() =

const logs = await executeAndGetLogs('./fixtures/multi-postcss-warnings/webpack.config');
expect(logs).toEqual([
'WARNING Compiled with 1 warnings',
'WARNING Compiled with 1 warning',
'',
'warning in ./test/fixtures/multi-postcss-warnings/index.css',
'',
Expand All @@ -211,7 +233,7 @@ Warning

(3:2) grid-gap only works if grid-template(-areas) is being used`,
'',
'WARNING Compiled with 1 warnings',
'WARNING Compiled with 1 warning',
'',
'warning in ./test/fixtures/multi-postcss-warnings/index2.css',
'',
Expand Down
Loading