generator icon indicating copy to clipboard operation
generator copied to clipboard

Add --es6 option to enable ES6 compliant syntax

Open danielkhan opened this issue 6 years ago • 24 comments

This PR

  • adds a new --es6 flag to enable ES6 (ES2015) syntax
  • replaces const with var if --es6 is set
  • adds string templates if --es6 is set
  • prefers arrow functions for callbacks if --es6 is set
  • makes sure that this feature is only available for Node.js >= 6.0.0
  • adds tests for --es6

Reference Link https://github.com/expressjs/generator/issues/167

danielkhan avatar Jun 17 '18 15:06 danielkhan

Is there a chance to land this one? I'll be creating an online course in August and ideally I'd like to use the new feature there.

danielkhan avatar Aug 04 '18 06:08 danielkhan

@danielkhan it's better to validate your code with eslint(airbnb-es6). there is some issue with app.js and www.js file.

alieslamifard avatar Aug 19 '18 07:08 alieslamifard

@alieslamifard are you referring to the result? Right now, the resulting code is not fully airbnb compatible as the non-es6 code wasn't as well. To not fix too much within one PR, this wasn't done deliberately.

danielkhan avatar Sep 06 '18 06:09 danielkhan

Any chance this can go up soon?

koushikmln avatar Dec 05 '18 12:12 koushikmln

Any update on this?

surajrana52 avatar Feb 06 '19 15:02 surajrana52

I'm also in need of this feature. I think it's ugly in 2019 to still see vars, when we're used to const, let, imports etc. It just tells more about your code. I would love to generate es6 nodejs projects with a flag.

robvaneck avatar Feb 09 '19 15:02 robvaneck

@dougwilson - is there a chance to land this or are there reasons that hold it back?

danielkhan avatar Feb 28 '19 14:02 danielkhan

Current node.js LTS version (10.15) seems to support ES2018 fully. Feels like express generator is stuck far behind.

Highly necessary to at least adapt ES2015 as default at that point, and avoid bad practices.

omerl13 avatar Mar 17 '19 22:03 omerl13

What's the reason for this not to be merged?

carlosveloso avatar Apr 10 '19 15:04 carlosveloso

This module is kept in version sync with Express. To add new features (like this), it is considered semver minor change. In order to land semver minor changes, there would also need to be a corresponding Express semver minor release. This PR arrived Jun 17, 2018 and Express 4.16.0 was released Oct 5, 2017. There has not been a new Express semver minor release to land this in. Express 4.17 will be coming out soon, at which time pending semver minor PRs in the generator such as this will be merged and a 4.17 generator released.

dougwilson avatar Apr 10 '19 16:04 dougwilson

This module is kept in version sync with Express. To add new features (like this), it is considered semver minor change. In order to land semver minor changes, there would also need to be a corresponding Express semver minor release. This PR arrived Jun 17, 2018 and Express 4.16.0 was released Oct 5, 2017. There has not been a new Express semver minor release to land this in. Express 4.17 will be coming out soon, at which time pending semver minor PRs in the generator such as this will be merged and a 4.17 generator released.

great, thanks for clarifying this!

carlosveloso avatar Apr 10 '19 16:04 carlosveloso

This module is kept in version sync with Express. To add new features (like this), it is considered semver minor change. In order to land semver minor changes, there would also need to be a corresponding Express semver minor release. This PR arrived Jun 17, 2018 and Express 4.16.0 was released Oct 5, 2017. There has not been a new Express semver minor release to land this in. Express 4.17 will be coming out soon, at which time pending semver minor PRs in the generator such as this will be merged and a 4.17 generator released.

Seems wrong to get stuck on old conventions & not using new supported features for 2 years, just to keep the version sync. What does Express v4.17 have to do with express generator not using ES6? I think it is best to keep this package up to date as a good template for Express projects instead of waiting for slow version bump

omerl13 avatar Apr 10 '19 17:04 omerl13

I don't like it, either. If you would like to have a conversation about it, please open a new issue instead of burying it in this pull request. I'm not the one who set it up and I did try to change it, but it caused users a lot of confusion because the version numbers were in sync for so long. If you would like to see it changed, open a new issue and provide an outline of the ideas for how to move away from version sync, and how we can connect with the published books and user out reach to provide notification about the changes that would need, etc.

dougwilson avatar Apr 10 '19 17:04 dougwilson

This module is kept in version sync with Express. To add new features (like this), it is considered semver minor change. In order to land semver minor changes, there would also need to be a corresponding Express semver minor release. This PR arrived Jun 17, 2018 and Express 4.16.0 was released Oct 5, 2017. There has not been a new Express semver minor release to land this in. Express 4.17 will be coming out soon, at which time pending semver minor PRs in the generator such as this will be merged and a 4.17 generator released.

Express 4.17.1 was released May 26th, why wasn't this PR merged for that release? Furthermore, this repo has now fallen out of sync with Express is at semver 4.17.1 while this repo is still at semver 4.16.1.

yardenshoham avatar Oct 04 '19 09:10 yardenshoham

Yes, I have not gotten around to getting all the 4.17 stuff sorted out in the generator yet. Having PRs like thus one with merge conflicts also slows this down, as I want to get all these things into said 4.17 release so they do not wait again for who knows how long. Not having merge conflicts that I have to resolve is always a big help, though, if someone would like to resolve them on this PR.

dougwilson avatar Oct 04 '19 13:10 dougwilson

Yes, I have not gotten around to getting all the 4.17 stuff sorted out in the generator yet. Having PRs like thus one with merge conflicts also slows this down, as I want to get all these things into said 4.17 release so they do not wait again for who knows how long. Not having merge conflicts that I have to resolve is always a big help, though, if someone would like to resolve them on this PR.

How would one be able to resolve the conflicts? I'm new to this and can't find the conflicts (only that they're in test/cmd.js).

yardenshoham avatar Oct 04 '19 14:10 yardenshoham

Likely only OP or myself can. I will do it when I get around to it, of course. This is just one of the many things on my todo list and I'm not even in my own country right now to do any work anyway.

dougwilson avatar Oct 04 '19 14:10 dougwilson

@dougwilson - I think it's hard to prevent conflicts when PRs are sitting for such a long time. I just resolved the conflict. Let me know if I can help.

danielkhan avatar Oct 04 '19 15:10 danielkhan

Thank you. Looks like just need to run "npm run lint" to fix the linting errors and it should be good to go, as that is the only thing failing on CI.

dougwilson avatar Oct 04 '19 16:10 dougwilson

There also seems to be a stray error: unknown option '--es6' printed during the tests if it is possible to hide that.

dougwilson avatar Oct 04 '19 16:10 dougwilson

P.S. I wanted to add that I am just listing out the things I would look into / modify when landing the PR. You are not required to do anything, as I will do it when landing. Just wanted to state that because I have had people rage close their PR when I was just trying to list the things I would do since they wanted it to land faster. I would prefer that did not happen here and if you feel like not making further changes I will do them no problem.

dougwilson avatar Oct 04 '19 16:10 dougwilson

@dougwilson - fixed linting problems. Console output is gone.

danielkhan avatar Oct 04 '19 18:10 danielkhan

When will this PR get merged with master?

backendsuraj avatar Oct 05 '19 13:10 backendsuraj

Ok, I am locking this as apparently people are going to keep asking the same question endlessly.

dougwilson avatar Oct 05 '19 13:10 dougwilson