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

chore: format code with prettier #18

Merged
merged 3 commits into from
Jul 11, 2017
Merged

chore: format code with prettier #18

merged 3 commits into from
Jul 11, 2017

Conversation

connor4312
Copy link
Member

No description provided.

Copy link

@SimonSchick SimonSchick left a 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 .+/];

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);

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.

Copy link
Member Author

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 😄

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)),

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 =>

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 😛

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier trumps all 😛

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning?

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really ugly.

Copy link
Member Author

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;

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?

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.

Copy link
Member Author

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

@connor4312 connor4312 merged commit 189a8ce into master Jul 11, 2017
@connor4312 connor4312 deleted the prettier branch July 11, 2017 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants