-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add more sensitive plugins tests #157
Conversation
Or use it to process source ast like transform but for ast. By the way it's better than stylelint with transform :) |
Removing is a bad idea for many reason. For example they are useful to process files with stylelint and ensure rules are processed in the original context (eg: postcss-bem-linter needs to be executed on file). |
Stylelint with current realisation is unuseful. It won't process root file and will incorrectly process imported with imports. And new realisation will break performance with null plugins too. |
So how people might use some plugins on imported files now? Like postcss-bem-linter? |
Perfs is something, but this is a development tool, so we don't need to have the fastest thing possible. We need to think to DX. |
@MoOx I can suggest to process source files after parse before parseStyles(). |
And linters will process original files. |
How importing a file make it "non originial"?! |
How prefixes can make it "non original"? |
I am not following you. The original idea of the "plugins" option is to be able to run a plugin on a file when importing it (so when no plugins have run on it yet - so content (ast) as not been modified yet (so it's the "original" source)). |
@MoOx I can follow this idea. But in your case one plugin will be applyed: postcss-import. btw stylelint will be applied multiple times on the same code (if it imported). |
The way code was was supposed to run to provided "plugins" on imported ast beforing adding them in the main ast. |
.@import 'module1';
lint-warning1 {} @import 'module2';
lint-warning2 {} lint-warning3 {} First step lint-warning3 {} Second step lint-warning3 {}
lint-warning2 {} Third step lint-warning3 {}
lint-warning2 {}
lint-warning1 {} Lint result:
Do you think it's correct? |
Can you explain me this a little more? |
Imported ast is processed by plugins again and again depends on how it deep. And linters with this way can be very dirty. |
It's recursion. |
The order of applying plugins is not important. |
Yes! I want this. I'm talking about current way when we have a lot of duplicated messages. |
Duplicated messages (so processing of plugins, that's what your are talking about?) should not happen. |
I'll do that. But this won't let to use imported variables. BTW with current way we are not able too, caz they definitions are removed before adding to ast. |
Using imported variables is working atm. This is a requirement. |
Lot's of plugins like postcss-custom-properties, postcss-custom-media etc, rely on that. |
But in this case linters we have not original ast and will warn duplicated messages. |
Oh I said something stupid. Those plugins rely on the fact that import will inline (so they use references themselves). |
So yeah you are right, if someone us a plugin for variable or something like that in "plugins" option, they won't be available for the rest of the ast, sure. |
Root ast still is not processed with plugins. We you want this I'll try to add them in parseStyles. |
Root ast should not be processed by plugins in "plugins" option. |
In this case for example lint plugins should be added twice. |
One for the main ast BEFORE postcss-import and one in "plugins" option, sure. |
Okay :) Is it okay now? |
Let's recap: you just fixed/improved the plugins option (that's is supposed to execute plugins on imported ast before they are inline)? |
@MoOx Not exactly. This imported files contain not processed imports. |
For now we just apply plugins on just parsed ast. |
Sorry it's so long, it's just to avoid confusion for users. If I am confused, I can't imagine users. So if some "plugins" make some changes to the ast, it won't be refected in the inlined files? |
All imports and media will be detected after these plugins, so some of them can be removed and won't be imported. |
In previous bahaviour it firstly inline all imports in this file and then apply plugins. |
And plugins processed the same ast parts multiple times. |
Previous behavior was: read file, create ast, apply "plugins", insert modified ast in the main ast. |
Nope |
For now |
If the behavior is now "read file, create ast, apply "plugins", insert imported ast, insert modified ast in the parent ast", I am ok with it, since that the one which make sense. |
There are some problems with plugins.
dev
branch).I think the best decision is remove
plugins
option.