generator
generator copied to clipboard
Add --es6 option to enable ES6 compliant syntax
This PR
- adds a new --es6 flag to enable ES6 (ES2015) syntax
- replaces
const
withvar
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
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 it's better to validate your code with eslint(airbnb-es6). there is some issue with app.js and www.js file.
@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.
Any chance this can go up soon?
Any update on this?
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.
@dougwilson - is there a chance to land this or are there reasons that hold it back?
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.
What's the reason for this not to be merged?
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.
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!
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
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.
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.
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.
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
).
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 - 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.
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.
There also seems to be a stray error: unknown option '--es6'
printed during the tests if it is possible to hide that.
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 - fixed linting problems. Console output is gone.
When will this PR get merged with master?
Ok, I am locking this as apparently people are going to keep asking the same question endlessly.