Comments (8)
I use this stub for development to show stylelint errors:
webpack.transformer.js
const _ = require("lodash");
function isWebpackError (e) {
return _.isEmpty(e.originalStack) && _.isNil(e.file) && _.has(e, "webpackError");
}
function transform(error) {
if (isWebpackError(error)) {
return Object.assign({}, error, {
name: "Webpack error",
type: "webpack-error"
});
}
return error;
}
module.exports = transform;
webpack.formatter.js
function concat(...args) {
args = Array.from(args).filter(e => e !== null);
const baseArray = Array.isArray(args[0]) ? args[0] : [args[0]];
return Array.prototype.concat.apply(baseArray, args.slice(1));
}
function displayError(error) {
return [error.webpackError, ""];
}
function format(errors) {
const lintErrors = errors.filter(e => e.type === "webpack-error");
if (lintErrors.length > 0) {
const flatten = (accum, curr) => accum.concat(curr);
return concat(
lintErrors
.map(error => displayError(error))
.reduce(flatten, [])
);
}
return [];
}
module.exports = format;
webpack.config.js
// ...
const webpackErrorTransformer = require("./transformers/webpack.transformer");
const webpackErrorFormatter = require("./formatters/webpack.formatter");
// ...
plugins: [
new FriendlyErrorsWebpackPlugin({
additionalTransformers: [webpackErrorTransformer],
additionalFormatters: [webpackErrorFormatter]
}),
// ...
I didn't find any reasons to dedicate this solution to stylelint, beacause this way any other webpack error could be shown. Basically, there's no stack at all and webpackError
frield contains error message.
from friendly-errors-webpack-plugin.
@geowarin Thank you. I'll make a pull request in a spare time.
from friendly-errors-webpack-plugin.
Hello!
Thanks for the report.
We currently support 3 types of errors:
- Babel syntax errors (priority = 1000)
- Modules not found (priority = 900)
- Eslint errors (priority = 0)
The other errors are given 0 priority and all the errors with the same priority should be displayed at the same time.
What output did you expect and how can we fix it ?
from friendly-errors-webpack-plugin.
@geowarin Thanks for your quick reply.
It would be great to support Stylelint Syntax errors as they provide more detailed information
and a majority of people are using it. Would that be possible? Not sure how i could help though :-)
from friendly-errors-webpack-plugin.
Stylelint could be a fine addition!
If you feel like contributing, take a look at the eslint transformer (which identifies an eslint error) and the eslint formatter (which displays it on the screen).
You could also contribute a test!
from friendly-errors-webpack-plugin.
+1 to @iceekey solution, this fixes my issue where stylelint plugin is not showing error logs for webpack dev server.
from friendly-errors-webpack-plugin.
@iceekey Nice thank you!
It looks like the default formatter should handle stylint!
Could you make a pull request including your changes?
from friendly-errors-webpack-plugin.
So does it support stylelint error now?
from friendly-errors-webpack-plugin.
Related Issues (20)
- Blank error when only webpackError property populated
- module is undefined
- show time even if warning appears
- Missing Error Filtering Feature
- Stylelint output does not show the name of the file where warnings occur
- Cannot read property 'request' of undefined at transform HOT 2
- Cannot read property 'some' of undefined
- Missing error report for failed compilation
- Can this plugin work with ForkTsChecker plugin when clearConsole is true? HOT 7
- Is 2.x ready for release? HOT 2
- compilationSuccessInfo.message not show HOT 1
- Peer Dependency issue with Webpack v5.x HOT 4
- Type 'FriendlyErrorsWebpackPlugin' is not assignable to type 'WebpackPluginInstance'.
- Forget update the Readme on NPM HOT 1
- Cannot read property 'startsWith' of undefined HOT 2
- should not output warning when the count of warnings is 0 HOT 4
- Support for displaying compilationSuccessInfo only on initial compilation HOT 1
- Does not work with Node.js v12 HOT 2
- recommending a different eslint-loader formatter in the docs
- Compilation is always succesful when it should not be HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from friendly-errors-webpack-plugin.