-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems on parsing root mixins with parameters with Stylelint #25
Comments
Debugged this and found out that the Stringifier is trying to stringify the |
@diagramatics , thank you. I will check it asap |
I've been doing more debugging about how the code works and how |
I'm a little confused as to why postcss-less cares about the params at all. On Sat, Mar 26, 2016 at 12:44 PM, Steven Sinatra notifications@github.com
|
@diagramatics, do you use version 0.5.0? I've tried it - works well: const root = parse('.foo(@bar) {color: @bar;}', {mixinsAsAtRules: true, innerMixinsAsRules: true}); |
@webschik Yeah it does. I've checked already and the issue only happens when you add Stylelint into the plugin list. |
@diagramatics, please, provide a full example of your code. |
Right, sorry for not providing this way earlier. const fs = require('fs');
const postcss = require('postcss');
const syntax = require('postcss-less');
const reporter = require("postcss-reporter")
const stylelint = require("stylelint")
const postcssParserOptions = {
syntax: syntax,
mixinsAsAtRules: true,
innerMixinsAsRules: true,
from: './test.less'
};
const css = fs.readFileSync('./test.less', 'utf-8');
postcss([
stylelint({
}),
reporter({ clearMessages: true }),
]).process(css, postcssParserOptions).then(function (result) {
}).catch(err => console.error(err.stack)); |
@diagramatics, thank you. I've fixed it in 0.6.0. |
@shellscape, @patsissons added the parsing of parameters for possibility to process them too (for example validate params in linter). |
Awesome, thank you for all the effort you've put in this! |
I can't believe I didn't run into this earlier in testing. I'll add a new test this morning to stylelint to capture this issue. |
I've tried this again in the same configuration. Seems like the output is still causing compatibility issues with Stylelint.
I've debugged this and I've also noticed that the root source output Stylelint is parsing has this:
Is the lack of parentheses on the parameters ( |
@diagramatics, thank you! I with @patsissons will think how to resolve this issue from our side. |
i think the main issue is that we really need to scale back the parsing when we're interacting with stylelint. when postcss is processing the stylelint plugin it doesn't use syntax extensions so we have to make sure the nodes that are created from less specific syntax are simplified to a rule with no further children. So that means we would want the above example to be parsed to something like:
By avoiding further child nodes (i.e. params, or other blocks) we allow the default postcss stringifier to just emit the raw less syntax. |
@patsissons, we should decide to use only PostCSS API and nodes with skipping of some LESS specific nodes, or extend PostCSS API and provide custom nodes for LESS syntax. Please, look at discussion here. I like the second variant, but as I see it can brake 3rd-party libraries, as Stylelint, that have strict addiction on PostCSS API and PostCSS node types as AtRule. |
elaborating on my opinion on the PR comment @webschik linked to there... if the goal of postcss-less is not to provide a LESS syntax for PostCSS to the rest of the PostCSS community, but rather to provide a means to allow Stylelint to operate on LESS files, then the project should be renamed and the description changed accordingly - something like Since you've chosen the name postcss-less (which follows postcss-scss), and the description of the project is that it's a syntax for PostCSS, you're going to have a lot of people in the PostCSS community (all of the maintainers of Lesshint as well) looking to this as an actual and proper LESS syntax for PostCSS - something that the project is already departing from. A proper syntax will follow the LESS spec and allow far more than Stylelint compatibility. Food for thought. |
I was about to suggest the same thing. We need a stylelint focused fork of postcss-less going forward. It just makes more sense because I would like to support the full less syntax here but that means either waiting for stylelint to properly handle things or adding in compatibility hacks as we have been doing. |
@shellscape, @patsissons, thank you, guys! |
@diagramatics, after discussion with @patsissons we decided that |
Right, I see. Do let me know if the effort has already begun as we are focused on having a LESS parser for Stylelint at the moment so we can help out. Thanks for all the help! |
I managed to scope this problem out to a compatibility issue with Stylelint. This is the code:
This works with Stylelint. However if I use parameters:
This immediately returns an error:
I've tested this on both
gulp-postcss
and PostCSS's Node API and both returns the same thing when Stylelint is added to the mix.mixinsAsAtRules
andinnerMixinsAsRules
is already set to true.Also if you change the mixin from a root mixin to be scoped inside another block, the error goes away.
The text was updated successfully, but these errors were encountered: