-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
dprint the codebase #54820
dprint the codebase #54820
Conversation
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @amcasey, @mjbvz, @minestarks for you. Feel free to loop in other consumers/maintainers if necessary |
I think only the first is necessary to merge the PR.
Not a blocker for the PR, but 120 sounds good to me.
Not a blocker. I have no preference.
This seems fine.
I don’t feel particularly strongly about this.
Let’s ignore nodes where this is important. |
These are my opinions on the open questions, where different from Andrew's (they are mostly the same):
I'd prefer to merge this PR with 1000 to minimise churn, and then I want to see how much churn there is for 120 vs 160 vs 200. 120 would be nice if it doesn't change things dramatically.
I prefer operators at the beginning of the line, but I think "maintain" is the right thing for getting this merged.
I hope we don't have many of these! It doesn't seem to fit the style of the code as far as I know.
I rarely edit json and markdown in this repo, so I'd skip those personally. *Technically, chaotic evil. But I don't have time to make a programming language syntax alignment chart. |
Tests are failing because this reformats some stuff that is reflected in baselines and stuff. Will fix later. |
Interesting open question: how does dprint-on-save interact with auto-save? I love autosave and would choose that over dprint-on-save if forced to choose. |
My understanding is that vscode will only do the format if you actually hit save. Maybe there's an option to change it but I'm not so sure. I haven't tested explicitly; I can't say I've ever accidentally had an unformatted file, though. |
So on the whole, I'm fine with leaving things at 1000/maintain/etc to defer those kinds of choices until later; anything is better than the nothing we have now. I totally expected that result. I'll drop JSON formatting out and add the prettier plugin to touch yaml;
I'll have to find these; it's unfortunately a big diff but I can probably grep and find them.
Some examples in this vein: return {
- get pos() { return pos; },
- get error() { return error; },
- get state() { return captureMapping(/*hasSource*/ true, /*hasName*/ true); },
+ get pos() {
+ return pos;
+ },
+ get error() {
+ return error;
+ },
+ get state() {
+ return captureMapping(/*hasSource*/ true, /*hasName*/ true);
+ }, switch (field) {
- case "major": return new Version(this.major + 1, 0, 0);
- case "minor": return new Version(this.major, this.minor + 1, 0);
- case "patch": return new Version(this.major, this.minor, this.patch + 1);
- default: return Debug.assertNever(field);
+ case "major":
+ return new Version(this.major + 1, 0, 0);
+ case "minor":
+ return new Version(this.major, this.minor + 1, 0);
+ case "patch":
+ return new Version(this.major, this.minor, this.patch + 1);
+ default:
+ return Debug.assertNever(field);
} Personally, I'd rather have then the "new" way anyhow. It's just a change. |
Not a blocker but auto import almost always results in the error. Will using dprint formatter auto fix it without having to run lint fix
Personally I prefer the existing style |
There's currently some differences that make it so we can't use dprint to order the named bindings, unfortunately. But, if auto-import is putting things in the wrong place and the settings are set properly in settings.json, then that's a bug in TS that we should address if we can get a repro going. |
Quick view of the most recent push per above: https://github.com/microsoft/TypeScript/compare/b81a0b383e031cd24e30acc5a2e5aec75f348cfc..8119de88f9645b30d54532ba8e3dfc66682bdce2 |
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
|
Exciting! I've been helping my friend paint after work and won't finish until Friday probably so I will take a look at everything over the weekend and try to prioritize fixing/improving things then. |
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.
Leaving a bunch of random comments.
@dsherret Is there a way to ask dprint to download the plugins in dprint.json and provide their cached locations? I'm looking into dprinting the outputs of the dts bundler, but I didn't want to add the |
@jakebailey the |
187d4ca
to
8392073
Compare
I went through all of the outstanding comments, manually improving ones where it seemed to help, resolving ones that were reported or are done; are there any remaining concerns here? I assume not? |
[git-generate] set -x npm ci npx eslint . --fix
[git-generate] set -x npm ci npx dprint fmt npx hereby clean npx hereby dts npx hereby runtests -t 'Public APIs|goToTypeDefinition_' &> /dev/null || npx hereby baseline-accept
Alright, this is going in; I have disabled caching in the formatting CI task for now, pending a fix for that upstream. Locally, it won't be a problem as nobody would be copying the cache between systems. |
Be aware that elements of this stack are generated (like my modules PR); I'm going to be (intermittently) force pushing to keep it up to date as effectively any change to
main
causes a conflict, so apologies on that front.This PR adds a dprint config to our repo. dprint (which is what
deno fmt
is running) is "yet another" code formatter in the same vein as prettier and others, with the main benefits of:checker.ts
, even on save, without being annoying.if
,else
,catch
, etc).This also enables us to remove effectively all eslint-based style checks, which is both a performance and ergonomics improvement. With all of the redundant style-related lint rules gone, linting the repo is now 7% faster!
The best way to view this PR is to look at the individual commits. This diff is large and makes GitHub mad, so consider viewing it github.dev or cloning it locally to play around. You'll want to install the dprint VS Code extension, which is automatically recommended per
.vscode/extensions.json
, and updatesettings.json
to enable it.Outstanding TODOs:
dprint check
prints a diff; a list of files or a silent mode would work a lot better here. But then again, people should just rundprint
religiously, or better yet, on save. It's fast.-
for bullets, but we seem to have*
)import { join } from "path"
) are currently forced to be multiline. This is of my own doing, as the contribution I made to dprint to allow forcing multi-line imports (like we want, for good merges) was incomplete and lacks that special case.gofmt
..git-blame-ignore-revs
the squash commit. I do not want to use a regular merge like last time.d.ts
files.For the opinionated choices, I have a separate PR on my fork that shows my own preference; you can check out the individual commits there: jakebailey#18
@dsherret ❤️
Fixes #18340 (in a way)