Skip to content
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

Examples or description of the behavior #3

Closed
oyeanuj opened this issue Feb 17, 2018 · 4 comments
Closed

Examples or description of the behavior #3

oyeanuj opened this issue Feb 17, 2018 · 4 comments
Labels

Comments

@oyeanuj
Copy link

oyeanuj commented Feb 17, 2018

Hi @pmkary, I came here via your themes. I was curious if you have any before/after examples or description of how Righteous behaves, so that one knows what to expect by installing this?

@pouyakary
Copy link
Owner

Hi again @oyeanuj. Hope you're doing great. Thanks a lot for your interest on Righteous. Righteous is designed to handle my custom coding style. This is just a random example. You can read a bit about this coding style here

Before you run it on any serious code please be warned that righteous is designed for my own specific projects and DEFINITELY EXPERIMENTAL AND NOT READY FOR ANY KIND OF REAL WORLD PROJECTS.

TypeScript / JavaScript it will look like this:
screen shot 1396-11-29 at 2 33 39 am

CSS will look like this:

But formatters scan the code and then rewrite it with from the AST level so in TypeScript / JavaScript only whitespace and indentations are being formatted. In CSS almost everything get's formatted, the lines are sorted and formatted in table views, extra lines are removed and similar stuff.

@oyeanuj
Copy link
Author

oyeanuj commented Mar 25, 2018

@pmkary Thank you for the detailed response, it definitely looks clean and readable! Since it isn't ready for real-world use yet, I will try to use it some test project. Looking forward to it being ready for real world use :)

PS. How much flexibility do you foresee providing? Would it be like Eslint/Prettier that there would be some opt-in/opt-out rules for formatting?

@pouyakary
Copy link
Owner

@oyeanuj

You're welcome! Righteous is not a good thing to be used for any projects. It is stable on TypeScript / JavaScript because it uses TypeScript's internal formatting engine so it is stable. The only place it breaks apart is identifying my comments.

Also when it comes to CSS the whole thing happens by rewriting the code from the tree. The problem is I develop them as I progress in my other projects so there are so many CSS stuff that I haven't used and so I haven't wrote the formatter for them (just recently I found it cann't format @font-face). This problem happens as formatter replaces the unsupported part by writing empty strings (which is a bug by the way) and that's why it's not suitable for any kind of programming. For me it's no problem because just as I find a problem I fix it in the main branch and then I resume my job, but if you want to format your code with Righteous I think you should take that into consideration and apply the same approach.

To your question. In typescript spaces are formatted but the rest of the stuff are still optional by many means. In CSS however almost everything is formatted expect for the property values. Because in CSS there are no grammars for them and I have to develop another parser for them which is really time consuming so I have left them manul

@oyeanuj
Copy link
Author

oyeanuj commented Mar 25, 2018

Got it, that makes sense! Thanks for the context!

@oyeanuj oyeanuj closed this as completed Mar 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants