-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add prettier code formatting #377
Conversation
* Prettier will always double quote a string containing an apostrophe.
Accept all changes and re-run prettier.
* Merge branch 'master' into feature/prettier
bin/iotaJsonTester.js
Outdated
parameters: ['host', 'port', 'apiKey', 'deviceId'], | ||
description: '\tConfigure the client to emulate the selected device, connecting to the given host.', | ||
description: | ||
'\tConfigure the client to emulate the selected device, connecting to the given host.', |
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 have a kind of deja vu looking to this... :)
We were discussing about line length in telefonicaid/perseo-fe#314 (comment) and we ended with "printWidth": 120
(https://github.com/telefonicaid/perseo-fe/blob/master/.prettierrc.json#L6). I think this setting should be common to this an other similar opened PRs.
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 didn't realize in the IOTA Sigfox onboarding PR... the 100 at https://github.com/telefonicaid/sigfox-iotagent/blob/master/.prettierrc.json#L6 probably should be 120 but it's fine given that the PR there is already 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.
Fixed f90c273 - I think I must have missed that one in the config, the others should be 120.
package-lock.json
Outdated
@@ -0,0 +1,4820 @@ | |||
{ |
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.
IOTA repositories intentionally doesn't include package-lock.json. We can open a discussion thread about the convenience of having pacakges-lock.json included in the repository or not :) but by the moment I'll suggest to leave it out this PR, please.
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.
Package lock removed. Fixed 6f5a131
test/unit/startup-test.js
Outdated
rejectUnauthorized: true, | ||
username: null | ||
}).should.equal(true); | ||
mqtt.connect |
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.
Not sure if I like this... too "sparse", don't you think?
On the contrary
mqtt.connect.calledOnceWithExactly({
looks nice.
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.
Fixed 7657825
lib/bindings/MQTTBinding.js
Outdated
'/' + apiKey + '/' + deviceId + '/' + constants.CONFIGURATION_SUFIX + '/' + | ||
constants.CONFIGURATION_VALUES_SUFIX, | ||
JSON.stringify(configurations), options, callback); | ||
'/' + |
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.
Topic/URL composition is better in just one line. Could this change be avoided?
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.
Fixed 7657825 - Note the line is over 120 chars unless split once anyway.
this.code = 400; | ||
}, | ||
UnsupportedType: function(expectedType) { | ||
this.name = 'UNSUPPORTED_TYPE'; | ||
this.message = 'The request content didn\'t have the expected type [' + expectedType + ' ]'; |
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 should be morer compact. Maybe using [%s] it could be done.
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.
Fixed 7657825
parameters: ['attributes'], | ||
description: '\tSend a collection of attributes to the MQTT broker, using JSON format. The "attributes"\n' + |
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 line is 117 chars long. I wonder why prettier has changed it if printWidth is 120...
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.
Presumably prettier picks up on the \n
and breaks at that point
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.
A bit weird... but ok.
NTC
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. Thanks!
Passing the ball to @dcalvoalonso for additional LGTM before merging
LGTM! Thanks @jason-fox ! |
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
Adds prettier and husky. All JavaScript files are autoformated on commit using the Git Hooks hook.
running
npm run prettier
will format all files with standardized whitespace.