-
Notifications
You must be signed in to change notification settings - Fork 73
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
chore: format code with prettier #18
Conversation
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.
99% ok but there is some stuff that makes the code kinda ugly, also few unrelated comments.
/^package .+/, | ||
/^syntax .+/, | ||
]; | ||
const ignores = [/^import .+/, /^option .+/, /^package .+/, /^syntax .+/]; |
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.
Stuff like this reduces readability a lot.
|
||
/** | ||
* Creates the user, with the provided password. | ||
*/ | ||
public create(password: string): Promise<this> { | ||
return this.client.userAdd({ name: this.name, password }) | ||
.then(() => this); | ||
return this.client.userAdd({ name: this.name, password }).then(() => this); |
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.
So, I actually meant to comment on this for a while now, but why resolve this
? This seems to be a pretty niche use case as you usually have the variable already in the scope when using this.
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.
It's for cases like this:
return client.user('connor')
.create('password123')
.then(user => user.addRole('root'));
rather than requiring
const user = client.user('connor');
return user.create()
.then(() => user.addRole());
Mostly style preference, but as there isn't anything useful I'd otherwise want to return from user.create()
, I may as well return this
😄
src/backoff/exponential.ts
Outdated
this.counter - Math.round(Math.random() * this.options.random); | ||
return Math.min( | ||
this.options.max, | ||
this.options.initial * Math.pow(2, Math.max(count, 0)), |
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.
Use **
src/lock.ts
Outdated
@@ -94,6 +102,10 @@ export class Lock { | |||
return this.acquire() | |||
.then(fn) | |||
.then(value => this.release().then(() => value)) | |||
.catch(err => this.release().then(() => { throw err; })); | |||
.catch(err => |
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.
this violates your curlies rule 😛
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.
Btw can we finally drop it with TS?
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.
Prettier trumps all 😛
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.
Meaning?
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.
I prefer to follow prettier's styling over any of my own personal preferences. Having a single unambiguous style is more important than my collection of individual preferences.
src/rpc.ts
Outdated
@@ -20,7 +26,9 @@ export interface IRequestStream<T> { | |||
end(): void; | |||
} | |||
|
|||
export interface IDuplexStream<T, R> extends IRequestStream<T>, IResponseStream<R> {} | |||
export interface IDuplexStream<T, R> extends IRequestStream<T>, IResponseStream< | |||
R |
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.
This is really ugly.
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.
yea, I agree. I can change prettier's wrapping to 100 columns instead of 80 which would reduce these scenarios
UNAVAILABLE: 14, | ||
DATA_LOSS: 15, | ||
UNAUTHENTICATED: 16 | ||
OK: 0; |
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.
Q: Why do you not use the auto increment feature?
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.
Also technically these use the wrong capitalisation.
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.
This is an object map of strings to numbers, not a true TypeScript enum (where numbers map to the enum key names and key names map to numbers).
Caps is not pretty, but it's what GRPC has
No description provided.