-
-
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
feat: add prettier support #231
Conversation
2587a5a
to
c367bd6
Compare
I think standard is going to be eslint driven for the foreseeable future, perhaps this would be more appropriate as a fork than adding a lot of prettier-specific options under the hood. @standard/team thoughts? |
I see there's a lot of previous discussion around this in issues linked in #230. I'm not familiar with this and don't have availability to dive in so I'm going to remove myself as a reviewer. Best of luck 🖖 |
Thanks for sharing your thoughts! @ungoldman In my opinion, using For example in There is already a way to do it : prettier-standard but it doesn't support well TypeScript and I would rather that it would work out-of-the box with Note: It is facultative, feel free to don't use Concerning the way to support it with {
"singleQuote": true,
"jsxSingleQuote": true,
"semi": false,
"trailingComma": "none"
} I already use it in |
@divlo This is something I've been interested in exploring for some time. I mentioned a bit about it here: standard/standard#1356 Thank you for taking the time to PR this. I haven't had a chance to dig in too deeply, but my first impression is that this PR seems straightforward enough and doesn't add too much code. I'll take a closer look at merging this when it's time to release the next major version of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Looking forward to having this merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good! 👍
Hello! I see there are comments that this PR may be included in the next release, however, I haven't found a roadmap for this. I've spent the last day or so exploring all the different combinations of configs and packages and haven't found a clear way forward for using semistandard and prettier (am currently hung up with the missing space before function parens conflict), and I'd rather not bring in more complexity with eslint (and friends), if I don't have to. I'm happy to help with docs and other supporting materials if it will help. Basically +1 for this! 🎉 |
Hey! 👋 @bnjmnrsh What this PR indents to do, is that when you will do While we're waiting for the next major release of {
"singleQuote": true,
"jsxSingleQuote": true,
"semi": true,
"trailingComma": "none"
} You need to install It should work perfectly, if not, feel free to share with us your errors.
Standard should be as easy as running one command, so I don't think, it is great to add too much documentation, as it should work without configuration out of the box, the only thing in the docs that need to be added, is the
Great! 😄 |
Does this still support a stdin/stdout api necessary for many editor formatting plugins? |
The |
I maintain one of the sublime standard formatter plugins https://github.com/bcomnes/sublime-standard-format It makes use of the stdin api in order to format buffers prior to saving files. I'm not familiar with vscodes formatting api. |
@divlo thanks for the quick response 🚒 ! While your To get around this, I've seen folks use an on-save plugin, and there is the standard-prettier-vscode plugin which I didn't get results from -- at nine stars, its a bit untested. And failing the above, you're in the realm of trying to couple something like eslint-config-semistandard with prettier-eslint, which has its own vscode plugin. If there's a way through that solution, I've not found it or found evidence from anyone else who has. At any rate, by this point, you've thrown a ridiculous amount of tooling at something that you seemed soo tantalizingly close to a few hours ago! ... 🌈 🍯 The missing piece seems to be this PR ✨ |
Right I don't know either, feel free to open a PR against this branch so I can integrate it with this PR to implement Also I guess the missing piece for this PR is some automated tests! 😄 |
Indeed! @bnjmnrsh |
In addition to the lack of stdio api, my main hangup here is what advantage does this provide over installing standard and prettier, and configuring a lifecycle script that runs It seems like the primary location formatter tools are used are in the editor, and the snag people get hung up on is using prettier with standard (e.g. producing a format with prettier that standard doesn't like, and trying to reconcile that only to have prettier break it again because people want format on save). They install prettier and format on save and then get annoyed when standard doesn't like the result. Part of this is inflexibility is due to editor plugins only working one way, but more fundamentally its a competing ruleset problem. We've tried to maintain separate formatting rules from the eslint rules ages ago, and it didn't work well. One problem we ran into was how do we guarantee that prettier (or whatever separate formatter rule we are using) doesn't format into something that standard --fix can't fix, or worse fixes in an unintended way and introduce a bug. It seems like two better options exist:
|
As said
Not only, but yes, you're right, it is mostly used in the editor. Actually, personnaly, I also use a lot, the command line.
I completely understand that, but in fact it is not what TL;DR: Linters usually contain not only code quality rules, but also stylistic rules. Most stylistic rules are unnecessary when using Prettier, but worse – they might conflict with Prettier! Use Prettier for code formatting concerns, and linters for code-quality concerns, as outlined in Prettier vs. Linters.
It is not enough, because
Currently, what this PR will provide to And for the actual users, they don't need to run Thanks for sharing your opinions! @bnjmnrsh |
@bcomnes, I can see where you are coming from with these two points. Mind you that a lot of this has been discussed quite extensively (#1356, #811, #996, among others), and I can see that you have been a part of many of them. So, I hope you'll all pardon some observations from a newcomer. In researching this over the last few days, I was dismayed to realize that there has been an impasse on this integration, from the looks of things, dating back to the early paleolithic era of 2017. From what I can gather, it appears that major sticking points are a subset of rules, that for whatever reason, the Preitter team doesn't wish to make an exception for (I mean, where would it end?!). And over in the Standard camp, it would appear they also don't want to bring their rule set into alignment, either fully or behind a feature flag. Meanwhile, I'd hate to see the sum of human-hours that have gone into the literally dozens of plugins, config attempts, feature requests, and midnight-searching-of-the-soul of those in userland like myself, looking for what surely-must-be-a-feature-that-I've-just-not-done-the-right-google-search--for. I mean, 'all' I want is to type my code, have it lint with the little red wiggles when I mess up, and for it to be pretty on save?! 😅 On @bcomnes specific points:
Adding to @divlo's comments about the pervasive use of Prettier across a project, I can see why the idea of incorporating more of Prettier's rules into Standard is compelling, but if it were easy, it surely would likely have been done by now. Also, it means trying to track the output against Prettier as that protect grows and develops, which seems to be an ambitious commitment. IMHO formatting is Prettier's Jam, so leverage that, why try to be all things? This way lies madness. I also see what you're saying with your second point.
I absolutely agree with this. If you don't install prettier as a dependency, I personally would expect it would throw a warning and fail—no prettier, no However...
Isn't this what is happening already, very poorly? Barring some compromise on the part of one of the two camps - what we have here, ladies and gentlemen, is known as a good old fashion _ "impasse"_, and a compromise is surely called for (I think that's the needle this PR tries to thread). I know I've glossed over a lot of complexity, but hopefully not mischaracterized anything, or anyone's position. In the meantime, if the past is prologue, as there isn't any particular indication as to when this PR or underlying issue might be addressed, I propose some supplementary documentation that outlines the successful approaches to achieving these same results until this PR is merged. Again, I'd be happy to contribute to such an effort, once I'd figured it out! 😀 |
I'm all for making standard and prettier work well together out of the box. And while the discussions continue going on, just wanted to share the solution I've been happily using for the last 2+ years. (which I really hope you don't mind me sharing here @feross (and co), fan of all the work you do 🙏). I run prettier on save to format the code, and run healthier to lint the code. Healthier checks all standard's rules that don't conflict with prettier. And it comes with vscode, sublime and vim plugins. Been working well for me, maybe it can work for you too, at least until some more native solution (as discussed in this PR) comes along. In fact, this has been working so well.. that I would even suggest exploring an alternative solution to combining prettier and standard. Leave formatting entirely to prettier (including it's editor plugins, config files and all that jazz) and add a flag to standard that removes styling rules. This way the answer to anyone asking how to use both is to use |
With great respect to the work that @divlo has already done on this PR, @KidkArolis suggestion has a lot of merits to consider, while minimizing possible downstream effects. It retains the benefit of this PR by not changing the base output of A decoupled approach also means that should someone prefer another formatter, then there would be little if anything standard would have to do to support it. Downstream, I imagine that this approach may also require less effort to accommodate across the ecosystem, editor plugins, ts-standard, semistandard, etc. |
01a592d
to
c66a8b7
Compare
c66a8b7
to
74a2227
Compare
@divlo This needs a rebase now |
This PR has no recent activity, and probably won't be merged for a long time and as I don't want/have time to do the job for this PR, I decided to close it. Feel free to open another PR yourself based on this one if you want this to be implemented. |
What is the purpose of this pull request? (put an "X" next to item)
What changes did you make? (Give an overview)
--format
format
forengine.lintFiles
prettier
andprettierConfig
fornew Linter()
See #230 for more information.
Which issue (if any) does this pull request address?
close #230
Is there anything you'd like reviewers to focus on?
BREAKING CHANGE: need to require prettier in
options.js
fornew Linter()