-
-
Notifications
You must be signed in to change notification settings - Fork 678
chore(ES6): changed 'var' into 'const' where convenient #325
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| "use strict"; | ||
|
|
||
| var makeLoaderName = require("./loader-generator").makeLoaderName; | ||
| const makeLoaderName = require("./loader-generator").makeLoaderName; | ||
|
|
||
| describe("makeLoaderName", () => { | ||
| it("should kebab-case loader name and append '-loader'", () => { | ||
| var loaderName = makeLoaderName("This is a test"); | ||
| const loaderName = makeLoaderName("This is a test"); | ||
| expect(loaderName).toEqual("this-is-a-test-loader"); | ||
| }); | ||
|
|
||
| it("should not modify a properly formatted loader name", () => { | ||
| var loaderName = makeLoaderName("properly-named-loader"); | ||
| const loaderName = makeLoaderName("properly-named-loader"); | ||
| expect(loaderName).toEqual("properly-named-loader"); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,15 +70,15 @@ describe("utils", () => { | |
| describe("findRootNodesByName", () => { | ||
| it("should find plugins: [] nodes", () => { | ||
| const ast = j(` | ||
| var a = { plugins: [], foo: { plugins: [] } } | ||
| const a = { plugins: [], foo: { plugins: [] } } | ||
| `); | ||
| const res = utils.findRootNodesByName(j, ast, "plugins"); | ||
| expect(res.size()).toEqual(2); | ||
| }); | ||
|
|
||
| it("should not find plugins: [] nodes", () => { | ||
| const ast = j(` | ||
| var a = { plugs: [] } | ||
| const a = { plugs: [] } | ||
| `); | ||
| const res = utils.findRootNodesByName(j, ast, "plugins"); | ||
| expect(res.size()).toEqual(0); | ||
|
|
@@ -132,12 +132,12 @@ var a = { plugs: [] } | |
| describe("findVariableToPlugin", () => { | ||
| it("should find the variable name of a plugin", () => { | ||
| const ast = j(` | ||
| var packageName = require('package-name'); | ||
| var someOtherVar = somethingElse; | ||
| var otherPackage = require('other-package'); | ||
| const packageName = require('package-name'); | ||
| const someOtherconst = somethingElse; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const otherPackage = require('other-package'); | ||
| `); | ||
| const foundVar = utils.findVariableToPlugin(j, ast, "other-package"); | ||
| expect(foundVar).toEqual("otherPackage"); | ||
| const found = utils.findVariableToPlugin(j, ast, "other-package"); | ||
| expect(found).toEqual("otherPackage"); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -166,7 +166,7 @@ var a = { plugs: [] } | |
| describe("findObjWithOneOfKeys", () => { | ||
| it("should find keys", () => { | ||
| const ast = j(` | ||
| var ab = { | ||
| const ab = { | ||
| a: 1, | ||
| b: 2 | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| var path = require("path"); | ||
| const path = require("path"); | ||
|
|
||
| /** | ||
| * Takes in a file path in the `./templates` directory. Copies that | ||
|
|
@@ -8,13 +8,13 @@ var path = require("path"); | |
| * @param {string} templateDir Absolute path to template directory | ||
| * @returns {Function} A curried function that takes a file path and copies it | ||
| */ | ||
| var generatorCopy = ( | ||
| const generatorCopy = ( | ||
| generator, | ||
| templateDir | ||
| ) => /** @param {string} filePath */ filePath => { | ||
| var sourceParts = templateDir.split(path.delimiter); | ||
| const sourceParts = templateDir.split(path.delimiter); | ||
| sourceParts.push.apply(sourceParts, filePath.split("/")); | ||
| var targetParts = path.dirname(filePath).split("/"); | ||
| const targetParts = path.dirname(filePath).split("/"); | ||
| targetParts.push(path.basename(filePath, ".tpl")); | ||
|
|
||
| generator.fs.copy( | ||
|
|
@@ -34,14 +34,14 @@ var generatorCopy = ( | |
| * the template files. | ||
| * @returns {Function} A curried function that takes a file path and copies it | ||
| */ | ||
| var generatorCopyTpl = ( | ||
| const generatorCopyTpl = ( | ||
| 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("/")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mutable object, but okay..
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't get reassigned, so
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| var targetParts = path.dirname(filePath).split("/"); | ||
| const targetParts = path.dirname(filePath).split("/"); | ||
| targetParts.push(path.basename(filePath, ".tpl").slice(1)); | ||
|
|
||
| generator.fs.copyTpl( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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!