Lisk-sdk: Convert codebase from ES5 to ES6

Created on 19 Jan 2018  路  5Comments  路  Source: LiskHQ/lisk-sdk

Given 6.12.3 as the currently targeted version of node, we should be able to use const and let everywhere.

Happy to submit a PR if we agree this is a solid way to modernize the codebase.

Most helpful comment

Closing this issue as we have a plan for it already. We're delaying it until very near the 1.0.0 release to avoid major merge conflicts. (Same goes for Prettier.)

This issue is about applying our ESLint config: https://github.com/LiskHQ/lisk/issues/1207
Soon-to-be-released v0.2.0 of that config is here: https://github.com/LiskHQ/eslint-config-lisk-base/tree/0.2.0
Once that's in place we can automatically apply many ES6 features (arrow functions, const etc) using eslint --fix.

We also have this parent issue covering standardization of various sorts: https://github.com/LiskHQ/lisk/issues/672
At the end of the list is "ES6+, babel etc" (yet to have an issue of its own), which will incorporate further changes that need to be made beyond the issues that can be fixed using ESLint. Exactly how far we want to take it in advance of 1.0.0 will depend also on deadlines.

All 5 comments

Probably best is to do the entire ES6 conversion under one task, titled and documented accordingly.

There will also be arrow functions, classes, possibly generators and iterators, etc, as per the ES6 features: https://github.com/lukehoban/es6features

In the meantime, it will be presumed that any new code is already being written in PR-d as ES6.

Yes! Let鈥檚 add the issues and get it done 馃檪

Closing this issue as we have a plan for it already. We're delaying it until very near the 1.0.0 release to avoid major merge conflicts. (Same goes for Prettier.)

This issue is about applying our ESLint config: https://github.com/LiskHQ/lisk/issues/1207
Soon-to-be-released v0.2.0 of that config is here: https://github.com/LiskHQ/eslint-config-lisk-base/tree/0.2.0
Once that's in place we can automatically apply many ES6 features (arrow functions, const etc) using eslint --fix.

We also have this parent issue covering standardization of various sorts: https://github.com/LiskHQ/lisk/issues/672
At the end of the list is "ES6+, babel etc" (yet to have an issue of its own), which will incorporate further changes that need to be made beyond the issues that can be fixed using ESLint. Exactly how far we want to take it in advance of 1.0.0 will depend also on deadlines.

@willclarktech

Once that's in place we can automatically apply many ES6 features (arrow functions, const etc) using eslint --fix.

You can't fix arrow functions with eslint --fix, because eslint doesn't know the expected this context, which changes when you replace a callback with an arrow function.

@vitaly-t I certainly didn't mean to suggest ESLint could convert every function to an arrow function automatically! Our ESLint config extends AirBnB's, which includes this rule: https://eslint.org/docs/rules/prefer-arrow-callback.html

That rule allows ESLint run with --fix to convert certain functions to arrow functions automatically, but any which use this will have to be addressed on a per case basis. This can be done as part of the follow-up issue, or (depending on time constraints on the 1.0.0 release) at a later date if necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ManuGowda picture ManuGowda  路  3Comments

slaweet picture slaweet  路  3Comments

diego-G picture diego-G  路  3Comments

ScrewchMcMuffin picture ScrewchMcMuffin  路  3Comments

willclarktech picture willclarktech  路  4Comments