Skip to content
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

chore(ES6): changed 'var' into 'const' where convenient #325

Merged
merged 2 commits into from
Mar 10, 2018
Merged

chore(ES6): changed 'var' into 'const' where convenient #325

merged 2 commits into from
Mar 10, 2018

Conversation

ematipico
Copy link
Contributor

What kind of change does this PR introduce?
Refactor, removed last references to var

Did you add tests for your changes?
No, but I updated one snapshot

If relevant, did you update the documentation?
No

Summary
Slowly moving to ES6

Does this PR introduce a breaking change?
No

generator,
templateDir,
templateData
) => /** @param {string} filePath */ filePath => {
var sourceParts = templateDir.split(path.delimiter);
const sourceParts = templateDir.split(path.delimiter);
sourceParts.push.apply(sourceParts, filePath.split("/"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutable object, but okay..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't get reassigned, so const is ok. Otherwise eslint would have failed :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .push method is mutating it, ( even though the push method is immutable ) but that's another thing :D

Copy link
Member

@sendilkumarn sendilkumarn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment otherwise LGTM 👍

var yeoman = require("yeoman-environment");
var LoaderGenerator = require("../generators/loader-generator").LoaderGenerator;
const yeoman = require("yeoman-environment");
const LoaderGenerator = require("../generators/loader-generator").LoaderGenerator;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this const { LoaderGenerator } = require("../generators/loader-generator") ?

var yeoman = require("yeoman-environment");
var PluginGenerator = require("../generators/plugin-generator").PluginGenerator;
const yeoman = require("yeoman-environment");
const PluginGenerator = require("../generators/plugin-generator").PluginGenerator;
Copy link
Member

@dhruvdutt dhruvdutt Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change to const { PluginGenerator } here as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ES6 destructing now? Cool!

var someOtherVar = somethingElse;
var otherPackage = require('other-package');
const packageName = require('package-name');
const someOtherconst = somethingElse;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someOtherconst => someOtherConst

@webpack-bot
Copy link

@ev1stensberg Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@dhruvdutt Please review the new changes.

@webpack-bot
Copy link

@ev1stensberg The tests look fine, but there are code style issue in your Pull Request. Please review the following:

> [email protected] travis:lint /home/travis/build/webpack/webpack-cli
> npm run lint && npm run bundlesize


> [email protected] lint /home/travis/build/webpack/webpack-cli
> eslint "**/*.js"


> [email protected] bundlesize /home/travis/build/webpack/webpack-cli
> bundlesize

 WARN  github token not found

    You are missing out on some cool features.
    Read more here: https://github.com/siddharthkp/bundlesize#2-build-status
   

 PASS  ./lib/migrate/index.js: 846B < maxSize 1KB (gzip) 

 PASS  ./lib/migrate/index.test.js: 540B < maxSize 1KB (gzip) 

 FAIL  ./lib/init/index.js: 1.52KB > maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/__testfixtures__/context-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/__testfixtures__/context-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/__testfixtures__/context-2.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/__testfixtures__/context-3.input.js: 61B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/__testfixtures__/context-4.input.js: 107B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/context.js: 589B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/context/context.test.js: 212B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/__testfixtures__/devServer-0.input.js: 95B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/__testfixtures__/devServer-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/__testfixtures__/devServer-2.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/__testfixtures__/devServer-3.input.js: 145B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/__testfixtures__/devServer-4.input.js: 118B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/devServer.js: 826B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devServer/devServer.test.js: 235B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/__testfixtures__/devtool-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/__testfixtures__/devtool-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/__testfixtures__/devtool-2.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/__testfixtures__/devtool-3.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/__testfixtures__/devtool-4.input.js: 105B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/devtool.js: 621B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/devtool/devtool.test.js: 215B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/entry/__testfixtures__/entry-0.input.js: 40B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/entry/__testfixtures__/entry-1.input.js: 83B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/entry/entry.js: 862B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/entry/entry.test.js: 330B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/externals/__testfixtures__/externals-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/externals/__testfixtures__/externals-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/externals/__testfixtures__/externals-2.input.js: 141B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/externals/externals.js: 971B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/externals/externals.test.js: 475B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/mode/__testfixtures__/mode-1.input.js: 41B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/mode/__testfixtures__/mode-2.input.js: 62B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/mode/mode.js: 587B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/mode/mode.test.js: 154B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/module/__testfixtures__/module-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/module/__testfixtures__/module-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/module/__testfixtures__/module-2.input.js: 352B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/module/module.js: 809B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/module/module.test.js: 618B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/node/__testfixtures__/node-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/node/node.js: 567B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/node/node.test.js: 183B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/__testfixtures__/other-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/__testfixtures__/other-1.input.js: 171B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/amd.js: 807B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/bail.js: 604B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/cache.js: 838B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/merge.js: 613B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/other.test.js: 386B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/parallelism.js: 606B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/profile.js: 839B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/recordsInputPath.js: 878B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/recordsOutputPath.js: 880B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/other/recordsPath.js: 861B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/output/__testfixtures__/output-0.input.js: 60B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/output/__testfixtures__/output-1.input.js: 224B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/output/output.js: 810B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/output/output.test.js: 300B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/performance/__testfixtures__/performance-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/performance/__testfixtures__/performance-1.input.js: 170B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/performance/performance.js: 835B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/performance/performance.test.js: 264B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/plugins/__testfixtures__/plugins-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/plugins/__testfixtures__/plugins-1.input.js: 113B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/plugins/plugins.js: 678B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/plugins/plugins.test.js: 224B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolve/__testfixtures__/resolve-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolve/__testfixtures__/resolve-1.input.js: 405B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolve/resolve.js: 814B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolve/resolve.test.js: 429B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolveLoader/__testfixtures__/resolveLoader-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolveLoader/__testfixtures__/resolveLoader-1.input.js: 133B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolveLoader/resolveLoader.js: 844B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/resolveLoader/resolveLoader.test.js: 201B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/stats/__testfixtures__/stats-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/stats/__testfixtures__/stats-1.input.js: 157B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/stats/stats.js: 809B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/stats/stats.test.js: 403B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/target/__testfixtures__/target-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/target/__testfixtures__/target-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/target/__testfixtures__/target-2.input.js: 108B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/target/target.js: 589B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/target/target.test.js: 148B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/top-scope/__testfixtures__/top-scope-0.input.js: 40B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/top-scope/__testfixtures__/top-scope-1.input.js: 71B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/top-scope/top-scope.js: 427B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/top-scope/top-scope.test.js: 165B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/__testfixtures__/watch-0.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/__testfixtures__/watch-1.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/__testfixtures__/watch-2.input.js: 94B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/__testfixtures__/watch-3.input.js: 154B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/__testfixtures__/watch-4.input.js: 59B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/watch.js: 821B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/watch.test.js: 153B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/watchOptions.js: 873B < maxSize 1.5KB (gzip) 

 PASS  ./lib/init/transformations/watch/watchOptions.test.js: 214B < maxSize 1.5KB (gzip) 

 PASS  ./lib/utils/ast-utils.js: 4.72KB < maxSize 5KB (gzip) 

 PASS  ./lib/utils/ast-utils.test.js: 2.09KB < maxSize 5KB (gzip) 

 PASS  ./lib/utils/copy-utils.js: 552B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/defineTest.js: 1.34KB < maxSize 5KB (gzip) 

 PASS  ./lib/utils/hashtable.js: 374B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/is-local-path.js: 420B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/is-local-path.test.js: 283B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/modify-config-helper.js: 971B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/npm-exists.js: 360B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/npm-exists.test.js: 222B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/npm-packages-exists.js: 782B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/npm-packages-exists.test.js: 423B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/package-manager.js: 821B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/package-manager.test.js: 816B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/prop-types.js: 273B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/resolve-packages.js: 991B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/resolve-packages.test.js: 783B < maxSize 5KB (gzip) 

 PASS  ./lib/utils/run-prettier.js: 577B < maxSize 5KB (gzip) 

See complete report here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants