From 43b2171ce4a50fdfd3d214a84edb6eddd3bc15bf Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Fri, 20 May 2016 10:48:59 -0700 Subject: [PATCH] Consistent function spacing. This patch applies spaces after anonymous function expressions. This is consistent with how we lint function declarations. Change-Id: I9b330673daa632e8d22f0a506e41c9643bb821c7 --- generators/app/index.js | 22 +++++------ generators/app/lib/component/editorconfig.js | 2 +- generators/app/lib/component/eslint.js | 4 +- generators/app/lib/component/license.js | 2 +- generators/app/lib/component/pkg.js | 2 +- spec/app/index.js | 36 +++++++++--------- spec/app/lib/component/eslint.js | 40 ++++++++++---------- spec/app/lib/component/license.js | 28 +++++++------- spec/app/lib/component/pkg.js | 26 ++++++------- 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/generators/app/index.js b/generators/app/index.js index 7dc8c37..1c63736 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var yeoman = require('yeoman-generator'); @@ -14,14 +14,14 @@ module.exports = yeoman.Base.extend({ - constructor: function() { + constructor: function () { yeoman.Base.apply(this, arguments); // Add support for a `--non-interactive` flag this.option('non-interactive'); }, - initializing: function() { + initializing: function () { var done = this.async(); // Set our own defaults. @@ -37,12 +37,12 @@ .then(license.init) // Licensing .then(eslint.init) // Linting .then(gitignore.init) // Gitignore - .then(function() { + .then(function () { done(); }); }, - prompting: function() { + prompting: function () { var done = this.async(); // Prompt components. @@ -53,12 +53,12 @@ .then(license.prompt) // Licensing .then(eslint.prompt) // Linting .then(gitignore.prompt) // Gitignore - .then(function() { + .then(function () { done(); }); }, - configuring: function() { + configuring: function () { var done = this.async(); // Configure components. @@ -69,19 +69,19 @@ .then(license.configure) // Licensing .then(eslint.configure) // Linting .then(gitignore.configure) // Gitignore - .then(function() { + .then(function () { done(); }); }, - writing: function() { + writing: function () { var self = this; var config = self.config.getAll(); var included = projectBuilder.getIncludedFiles(); var excluded = projectBuilder.getExcludedFiles(); // Write out all files included in the project builder. - included.forEach(function(fileRef) { + included.forEach(function (fileRef) { if (fileRef.hasOwnProperty('content')) { var content = typeof fileRef.content === 'function' ? "" + fileRef.content() @@ -97,7 +97,7 @@ }); // Delete all files explicitly excluded in the project builder. - excluded.forEach(function(path) { + excluded.forEach(function (path) { self.fs.delete(self.destinationPath(path)); }); } diff --git a/generators/app/lib/component/editorconfig.js b/generators/app/lib/component/editorconfig.js index db36ea7..74fd85e 100644 --- a/generators/app/lib/component/editorconfig.js +++ b/generators/app/lib/component/editorconfig.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var projectBuilder = require('../project_builder'); diff --git a/generators/app/lib/component/eslint.js b/generators/app/lib/component/eslint.js index 801b4f1..594352c 100644 --- a/generators/app/lib/component/eslint.js +++ b/generators/app/lib/component/eslint.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var projectBuilder = require('../project_builder'); @@ -33,7 +33,7 @@ if (fs.exists(ignoreFile)) { excludedPaths = fs.read(ignoreFile) .split('\n') - .filter(function(item) { + .filter(function (item) { // Remove empty lines. return item.length > 0; }); diff --git a/generators/app/lib/component/license.js b/generators/app/lib/component/license.js index 359289d..ad1a7a5 100644 --- a/generators/app/lib/component/license.js +++ b/generators/app/lib/component/license.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var projectBuilder = require('../project_builder'); diff --git a/generators/app/lib/component/pkg.js b/generators/app/lib/component/pkg.js index fb56f75..54cf396 100644 --- a/generators/app/lib/component/pkg.js +++ b/generators/app/lib/component/pkg.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var pkgBuilder = require('../pkg_builder'); diff --git a/spec/app/index.js b/spec/app/index.js index d8cc616..0dc100e 100644 --- a/spec/app/index.js +++ b/spec/app/index.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var path = require('path'); var assert = require('yeoman-assert'); @@ -8,16 +8,16 @@ var modules = ['gerrit', 'license', 'editorconfig']; var projectBuilder = require('../../generators/app/lib/project_builder'); - describe('generator-openstack:app', function() { + describe('generator-openstack:app', function () { - beforeEach(function() { + beforeEach(function () { projectBuilder.clear(); }); it('should call all module lifecycle prompts', - function(done) { + function (done) { var spies = []; - modules.forEach(function(name) { + modules.forEach(function (name) { var module = require('../../generators/app/lib/component/' + name); spies.push(spyOn(module, 'init').and.callThrough()); spies.push(spyOn(module, 'prompt').and.callThrough()); @@ -25,8 +25,8 @@ }); helpers.run(generator) - .on('end', function() { - spies.forEach(function(spy) { + .on('end', function () { + spies.forEach(function (spy) { expect(spy.calls.any()).toBeTruthy(); }); @@ -34,44 +34,44 @@ }); }); - describe('writing()', function() { + describe('writing()', function () { it('should create all files created in the project builder', - function(done) { + function (done) { helpers.run(generator) - .on('end', function() { + .on('end', function () { assert.file(['.gitreview']); // We'll just use a file we know about. done(); }); }); it('should write any files provided to the content builder', - function(done) { - projectBuilder.writeFile('test.json', function() { + function (done) { + projectBuilder.writeFile('test.json', function () { return 'foo'; }); - projectBuilder.writeFile('test_null.json', function() { + projectBuilder.writeFile('test_null.json', function () { // do nothing. }); - projectBuilder.writeFile('test_empty.json', function() { + projectBuilder.writeFile('test_empty.json', function () { return ''; }); projectBuilder.writeFile('test_static.json', 'static_content'); projectBuilder.writeFile('test_undefined.json'); helpers.run(generator) - .on('end', function() { - assert.file(['test.json', 'test_static.json','test_empty.json', 'test_null.json', + .on('end', function () { + assert.file(['test.json', 'test_static.json', 'test_empty.json', 'test_null.json', 'test_undefined.json']); done(); }); }); it('should delete all files flagged in the project builder', - function(done) { + function (done) { projectBuilder.removeFile('test.json'); helpers.run(generator) - .on('end', function() { + .on('end', function () { assert.noFile(['test.json']); done(); }); diff --git a/spec/app/lib/component/eslint.js b/spec/app/lib/component/eslint.js index 7d754dd..05280a4 100644 --- a/spec/app/lib/component/eslint.js +++ b/spec/app/lib/component/eslint.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var libDir = '../../../../generators/app/lib'; var mockGenerator; @@ -9,22 +9,22 @@ var mocks = require('../../../helpers/mocks'); var yaml = require('js-yaml'); - describe('generator-openstack:lib/component/eslint', function() { + describe('generator-openstack:lib/component/eslint', function () { - beforeEach(function() { + beforeEach(function () { mockGenerator = mocks.buildGenerator(); mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); projectBuilder.clear(); }); it('should define init, prompt, and configure', - function() { + function () { expect(typeof eslint.init).toBe('function'); expect(typeof eslint.prompt).toBe('function'); expect(typeof eslint.configure).toBe('function'); }); - describe('init()', function() { + describe('init()', function () { it('should return a generator', function () { var outputGenerator = eslint.init(mockGenerator); @@ -32,14 +32,14 @@ }); it('should not interact with config', - function() { + function () { var spy = spyOn(mockGenerator.config, 'defaults'); eslint.init(mockGenerator); expect(spy.calls.any()).toBeFalsy(); }); }); - describe('prompt()', function() { + describe('prompt()', function () { it('should return a generator', function () { var outputGenerator = eslint.prompt(mockGenerator); @@ -47,14 +47,14 @@ }); it('should do nothing', - function() { + function () { var spy = spyOn(mockGenerator, 'prompt'); eslint.prompt(mockGenerator); expect(spy.calls.any()).toBeFalsy(); }); }); - describe('configure()', function() { + describe('configure()', function () { it('should return a generator', function () { var outputGenerator = eslint.configure(mockGenerator); @@ -62,7 +62,7 @@ }); it('should add .eslintrc and .eslintignore to the project files.', - function() { + function () { eslint.configure(mockGenerator); var files = projectBuilder.getIncludedFiles(); @@ -72,14 +72,14 @@ }); }); - describe('.eslintrc management', function() { + describe('.eslintrc management', function () { var mockEslintRc = { extends: 'openstack', plugins: ['angular'] }; it('should write a .eslintrc file as valid .yaml', - function() { + function () { eslint.init(mockGenerator); eslint.configure(mockGenerator); @@ -91,7 +91,7 @@ }); it('should echo back existing .eslintrc', - function() { + function () { var yamlContent = yaml.safeDump(mockEslintRc); mockGenerator.fs.write('.eslintrc', yamlContent); @@ -105,7 +105,7 @@ }); it('should convert a json .eslintrc to yaml', - function() { + function () { mockGenerator.fs.write('.eslintrc', JSON.stringify(mockEslintRc)); eslint.init(mockGenerator); @@ -118,10 +118,10 @@ }); }); - describe('.eslintignore management', function() { + describe('.eslintignore management', function () { it('should echo back existing .eslintignore', - function() { + function () { mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); eslint.init(mockGenerator); @@ -132,13 +132,13 @@ var ignoreContent = ignoreRef.content().split('\n'); expect(ignoreContent.length).toBe(mockEslintIgnore.length); - ignoreContent.forEach(function(item) { + ignoreContent.forEach(function (item) { expect(mockEslintIgnore.indexOf(item)).not.toBe(-1); }); }); it('should sort the ignored files.', - function() { + function () { mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); eslint.init(mockGenerator); @@ -153,7 +153,7 @@ }); it('should remove any whitespace from the existing .eslintignore', - function() { + function () { mockGenerator.fs.write('.eslintignore', ['1_one', '', '2_two', ''].join('\n')); eslint.init(mockGenerator); @@ -167,7 +167,7 @@ expect(ignoreContent[1]).toBe('2_two'); }); - it('should delete the file if there\'s nothing to ignore', function() { + it('should delete the file if there\'s nothing to ignore', function () { mockGenerator.fs.write('.eslintignore', ''); eslint.init(mockGenerator); diff --git a/spec/app/lib/component/license.js b/spec/app/lib/component/license.js index 64a0378..600a928 100644 --- a/spec/app/lib/component/license.js +++ b/spec/app/lib/component/license.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var libDir = '../../../../generators/app/lib'; @@ -8,59 +8,59 @@ var mocks = require('../../../helpers/mocks'); var mockGenerator; - describe('generator-openstack:lib/component/license', function() { + describe('generator-openstack:lib/component/license', function () { - beforeEach(function() { + beforeEach(function () { mockGenerator = mocks.buildGenerator(); projectBuilder.clear(); }); it('should define init, prompt, and configure', - function() { + function () { expect(typeof license.init).toBe('function'); expect(typeof license.prompt).toBe('function'); expect(typeof license.configure).toBe('function'); }); - describe('init()', function() { + describe('init()', function () { it('should return a generator', - function() { + function () { var outputGenerator = license.init(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should do nothing', - function() { + function () { var spy = spyOn(mockGenerator.config, 'defaults'); license.init(mockGenerator); expect(spy.calls.any()).toBeFalsy(); }); }); - describe('prompt()', function() { + describe('prompt()', function () { it('should return a generator', - function() { + function () { var outputGenerator = license.prompt(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should do nothing', - function() { + function () { var spy = spyOn(mockGenerator, 'prompt'); license.prompt(mockGenerator); expect(spy.calls.any()).toBeFalsy(); }); }); - describe('configure()', function() { + describe('configure()', function () { it('should return a generator', - function() { + function () { var outputGenerator = license.configure(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should add license to the project files.', - function() { + function () { license.configure(mockGenerator); var files = projectBuilder.getIncludedFiles(); @@ -70,7 +70,7 @@ }); it('should add license to the package.json files.', - function() { + function () { license.configure(mockGenerator); var parsedResult = JSON.parse(pkgBuilder.toJSON()); diff --git a/spec/app/lib/component/pkg.js b/spec/app/lib/component/pkg.js index d533c82..f2322e9 100644 --- a/spec/app/lib/component/pkg.js +++ b/spec/app/lib/component/pkg.js @@ -1,4 +1,4 @@ -(function() { +(function () { 'use strict'; var libDir = '../../../../generators/app/lib'; @@ -8,29 +8,29 @@ var mocks = require('../../../helpers/mocks'); var mockGenerator; - describe('generator-openstack:lib/component/pkg', function() { + describe('generator-openstack:lib/component/pkg', function () { - beforeEach(function() { + beforeEach(function () { mockGenerator = mocks.buildGenerator(); projectBuilder.clear(); }); it('should define init, prompt, and configure', - function() { + function () { expect(typeof pkg.init).toBe('function'); expect(typeof pkg.prompt).toBe('function'); expect(typeof pkg.configure).toBe('function'); }); - describe('init()', function() { + describe('init()', function () { it('should return a generator', - function() { + function () { var outputGenerator = pkg.init(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should read an existing package.json file into the package builder', - function() { + function () { mockGenerator.fs.writeJSON("package.json", {name: "foo"}); pkg.init(mockGenerator); @@ -39,30 +39,30 @@ }); }); - describe('prompt()', function() { + describe('prompt()', function () { it('should return a generator', - function() { + function () { var outputGenerator = pkg.prompt(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should do nothing', - function() { + function () { var spy = spyOn(mockGenerator, 'prompt'); pkg.prompt(mockGenerator); expect(spy.calls.any()).toBeFalsy(); }); }); - describe('configure()', function() { + describe('configure()', function () { it('should return a generator', - function() { + function () { var outputGenerator = pkg.configure(mockGenerator); expect(outputGenerator).toEqual(mockGenerator); }); it('should add package.json to the project files.', - function() { + function () { pkg.configure(mockGenerator); var files = projectBuilder.getIncludedFiles();