Update everything to ES6 and adopt a code style#120
Conversation
…x.js, js/version.js, js/__loader.js, switch airbnb eslint config
|
Goodbye commit history :) |
|
Also added guidelines for contributing, plus a list of exceptions to Airbnb's style guide. |
|
How do we update runtime with npm. |
|
This is done and ready for review/merge, the only thing I'm not really confident about is the |
|
This is awesome, I'll do some tests too, to make sure everything works. |
|
|
||
| function readHostname(reader) { | ||
| var labels = []; | ||
| const readHostname = (reader) => { |
There was a problem hiding this comment.
I think regular function declarations are fine, stack trace will be nicer
| if (!dev.writeGuestFeatures(features, driverFeatures, deviceFeatures)) { | ||
| debug('[virtio] driver is unable to start'); | ||
| return; | ||
| return debug('[virtio] driver is unable to start'); |
There was a problem hiding this comment.
nitpick, it shouldn't return debug() return value
|
Ok, I've update the code to only use arrow functions for property functions and callbacks and function declarations for everything else, I've run the code through a beautifier, removed the newlines in |
| const { MACAddress, Interface } = runtime.net; | ||
|
|
||
| const virtioHeader = (() => { | ||
| const virtioHeader = (function () { // eslint-disable-line wrap-iife |
There was a problem hiding this comment.
nitpick, arrow function if ok in this case?
|
Converted IIFE functions to arrow functions, and fixed the minor style issues. Sorry, most of these little things are because of the beautifier I ran it through. |
| socket._transmit = recvACKFIN; | ||
| socket.close(); | ||
| t.equal(socket._state, tcpSocketState.STATE_TIME_WAIT); | ||
| socket._transmit = recvACKFIN; socket.close(); t.equal(socket._state, tcpSocketState.STATE_TIME_WAIT); |
|
@facekapow left couple of places where there are a few statements on the single line. |
|
@iefserge Well, that's the last time I use a beautifier 😄 |
|
LGTM |
|
wow. Amazing. |
|
Great, then I'll just do a quick once-over on the code and merge. |
|
Everything looks ok, I tried to run the JS tests, but those are definitely broken (more specifically, |
|
bye-bye history of changes :) |
|
@facekapow yeah, I've been looking into tests issue, should be fine, going to fix it afterwards. |
This PR is a big one, it changes pretty much all of the JavaScript files, since it updates everything to ES6, plus adopts airbnb/javascript as a code style (with a few tweaks, like using require instead of ES6 modules).
Done so far:
js/*.jsjs/componentjs/component/dns-clientjs/corejs/core/*.jsjs/core/debugjs/core/keyboardjs/core/netjs/core/pcijs/core/ps2js/core/randomjs/core/stdiojs/core/ttyjs/driverjs/driver/ps2js/driver/virtiojs/driver/virtio/vringjs/driver/virtio/*.jsjs/modulesjs/servicejs/service/dhcp-clientjs/service/dns-resolverjs/service/shelljs/testjs/test/unitjs/test/unit/buffersjs/test/unit/libjs/test/unit/netjs/test/unit/platformjs/test/unit/randomjs/test/unit/scriptjs/test/unit/timersjs/test/unit/virtiojs/utils