-
Notifications
You must be signed in to change notification settings - Fork 5
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
Make processString honor exclude field in config #5
base: master
Are you sure you want to change the base?
Make processString honor exclude field in config #5
Conversation
Should I close this and make another pull request to dev branch instead? |
Are we talking about this package? |
We are not talking about atom-csscomb, but that package has the same problem. This pull request is for core, a component of npm's csscomb and a dependency of atom-beautify. Another pull request would have to be sent to atom-beautify, to make it call processString with the options.filename parameter. |
I'll try to explain this again, because maybe my previous posts were confusing. The atom packages atom-csscomb and atom-beautify are ignoring the exclude field in .csscomb.json Those 2 atom packages call processString without the filename parameter. processString is only using the filename parameter to print an error message. This pull request makes processString use that paremeter to check if the file being processed is in the exclude list. After this, other 2 pull requests would have to be sent to atom-beautify and atom-csscomb, to make them use the filename paremeter. This is a potential solution, and I would like to know if you want to do it, do something else, or just accept that atom packages should ignore the exclude field. |
Hi @killerjk! Sorry for a late response. |
I've been testing Another problem is packages that depend on files being modified only through the editor may break. For example, local-history will save revisions of the files before they get modified by csscomb. It's not a huge problem, you can always run csscomb again after you restore a revision, but other packages may stop working completely. It's difficult to predict, and it's a valid concern that a piece of software may need to receive a processed string, while still representing a file. Another thing that makes me worried is the interaction with atom-beautify. It has the option to call csscomb on save, and this is already a problem, sometimes leaving you with an empty file. It's explained here. I don't know what would happen if csscomb modified the file bypassing everything. He says things like "atom and the package have a very special relationship", "everything is async" and "it has to workaround atom in some cases", which makes me thing it can be a can of worms. I suppose he would have a better answer than me, but even if it worked, you still have other packages constantly reloading when using If It would be nice if you could: Ways to cleanly design an API that does this? You probably have a better answer than me. You could for example stop calling Other way would be making a Yet another way would be adding a boolean or something to |
@killerjk, thank you very much for taking time to explain it all. var shouldProcess = csscomb.shouldProcess(filename);
if (shouldProcess) {
csscomb.processString(...);
} The method which is now "private": https://github.com/csscomb/core/blob/dev/src/core.js#L371 |
That could work, yes. The potential problem is any other person that tries to call csscomb from other program, like a package, will have to know it must be implemented that way, or a part of csscomb's configuration will be ignored without warning. It took me a while to know what was going on, I actually thought it was my fault when writing the wildcards. So we may see more broken packages in the future. I suppose it would be reasonable to ask plugin's authors to implement more code if they want to have more control. The question is, should csscomb keep the exclude check as something internal, so it always happens regardless of how you call it, or should the author of the external program be tasked with the re-implementation of what would be a custom My opinion is that it sounds like the proper solution. Sure, you could add the check to By the way, I was wrong about pigments, it also reloads with |
@killerjk, okay. So I'll move the check to public methods and add documentation for plugin writers mentioning that if they use |
That sounds great. Thanks! |
Atom's atom-beautify is using the method processString to call csscomb. This is a problem, because processString is not checking the exclude field in the config. That means that packages like atom-beautify, that have the option to call csscomb on save, or init scripts to call csscomb every time you write ";", are beautifying files that are in the exclude list. It has some nasty effects, like reordering mixins and functions, potentially breaking them or other problems.
I thought I would submit a pull request instead of opening a new issue, just in case this simple change is accepted.
I don't know if shouldProcessFile was not being called here by design, or if the parameter filename should be renamed to path. Tell me if there is anything that should be changed.
If it's accepted and the npm package is updated, I'll submit another patch to atom so it can use the new feature, since it's not using filename at the moment.