From 6d267f030f16311767f02950ee57f0db51915749 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 12 Feb 2017 03:07:39 +0700 Subject: [PATCH] Use XO So we don't have to manually manage a huge .eslintrc file --- .editorconfig | 3 - .eslintrc | 121 ------------------ .gitattributes | 1 + .travis.yml | 28 ++-- benchmark/module.js | 4 +- gulpfile.js | 15 +-- lib/actions/help.js | 25 ++-- lib/actions/install.js | 12 +- .../{spawn_command.js => spawn-command.js} | 10 +- lib/actions/user.js | 9 +- lib/index.js | 45 +++---- lib/util/conflicter.js | 4 +- lib/util/deprecate.js | 2 +- lib/util/prompt-suggestion.js | 9 +- lib/util/storage.js | 2 +- package.json | 43 +++++-- readme.md | 2 + test/base.js | 51 ++++---- test/conflicter.js | 25 ++-- test/deprecate.js | 1 - test/generators.js | 1 - test/install.js | 11 +- test/prompt-suggestion.js | 9 +- test/{spawn_command.js => spawn-command.js} | 29 ++--- test/storage.js | 34 ++--- test/user.js | 4 +- 26 files changed, 184 insertions(+), 316 deletions(-) delete mode 100644 .eslintrc rename lib/actions/{spawn_command.js => spawn-command.js} (59%) rename test/{spawn_command.js => spawn-command.js} (66%) diff --git a/.editorconfig b/.editorconfig index beffa308..1923d410 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,6 +6,3 @@ indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index edb52720..00000000 --- a/.eslintrc +++ /dev/null @@ -1,121 +0,0 @@ -{ - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 6 - }, - "env": { - "node": true, - "mocha": true - }, - "rules": { - "array-bracket-spacing": [ - 2, - "never" - ], - "brace-style": [ - 2, - "1tbs" - ], - "consistent-return": 0, - "indent": [ - 2, - 2, - { - "SwitchCase": 1 - } - ], - "no-multiple-empty-lines": [ - 2, - { - "max": 2 - } - ], - "no-use-before-define": [ - 2, - "nofunc" - ], - "one-var": [ - 2, - "never" - ], - "quote-props": [ - 2, - "as-needed" - ], - "quotes": [ - 2, - "single" - ], - "strict": [ - 2, - "global" - ], - "curly": [ - 2, - "all" - ], - "eol-last": 2, - "keyword-spacing": 2, - "key-spacing": [ - 2, - { - "beforeColon": false, - "afterColon": true - } - ], - "no-eval": 2, - "no-with": 2, - "space-infix-ops": 2, - "dot-notation": [ - 2, - { - "allowKeywords": true - } - ], - "eqeqeq": [ - 2, - "allow-null" - ], - "no-alert": 2, - "no-caller": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-implied-eval": 2, - "no-iterator": 2, - "no-label-var": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-loop-func": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-native-reassign": 2, - "no-new-func": 2, - "no-new-wrappers": 2, - "no-octal-escape": 2, - "no-proto": 2, - "no-return-assign": 2, - "no-script-url": 2, - "no-sequences": 2, - "no-unused-expressions": 2, - "yoda": 2, - "no-undef-init": 2, - "camelcase": 2, - "comma-spacing": 2, - "new-cap": 2, - "new-parens": 2, - "no-array-constructor": 2, - "no-extra-parens": 2, - "no-console": 0, - "no-new-object": 2, - "no-spaced-func": 2, - "no-trailing-spaces": 2, - "semi": 2, - "semi-spacing": [ - 2, - { - "before": false, - "after": true - } - ] - } -} diff --git a/.gitattributes b/.gitattributes index 176a458f..391f0a4e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ * text=auto +*.js text eol=lf diff --git a/.travis.yml b/.travis.yml index ae96e5d2..377cf9a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,20 @@ sudo: false language: node_js node_js: - - 4 - - 6 - - node -after_success: "./deploy.sh" + - '6' + - '4' + - '0.12' + - '0.10' +after_success: ./deploy.sh env: global: - - COMMIT_AUTHOR_EMAIL: yeoman@yeoman.io - - COMMIT_AUTHOR_NAME: yeoman - - SOURCE_BRANCH: master - - TARGET_BRANCH: gh-pages - - DOCS_DIR: "../yeoman-generator-doc" - - GH_OWNER: yeoman - - GH_PROJECT_NAME: generator - - DEPLOY_ON_NODE_VERSION: v6 - - secure: Hv7gACQoYGtesz1NTJYRHjGCimEJEjj4bQP2iTpDUUbfAiYe/4QPemoyDEFjRxbu5m2uoYwMk0AQrW7DnQhNAhl7u24jYnRgQyd/2GOx3xZgjwnao27gsrTHss4IyXEaS2h3kRuIVSD+xibz/lwZm+erHOQ9VOwvCQkOKnILXW8= + - COMMIT_AUTHOR_EMAIL: yeoman@yeoman.io + - COMMIT_AUTHOR_NAME: yeoman + - SOURCE_BRANCH: master + - TARGET_BRANCH: gh-pages + - DOCS_DIR: ../yeoman-generator-doc + - GH_OWNER: yeoman + - GH_PROJECT_NAME: generator + - DEPLOY_ON_NODE_VERSION: v6 + - secure: >- + Hv7gACQoYGtesz1NTJYRHjGCimEJEjj4bQP2iTpDUUbfAiYe/4QPemoyDEFjRxbu5m2uoYwMk0AQrW7DnQhNAhl7u24jYnRgQyd/2GOx3xZgjwnao27gsrTHss4IyXEaS2h3kRuIVSD+xibz/lwZm+erHOQ9VOwvCQkOKnILXW8= diff --git a/benchmark/module.js b/benchmark/module.js index 3911de88..f4c31e43 100644 --- a/benchmark/module.js +++ b/benchmark/module.js @@ -1,9 +1,9 @@ -/*global suite, bench */ +/* global suite, bench */ 'use strict'; suite('yeoman-generator module', function () { bench('require', function () { - require('..'); + require('..'); // eslint-disable-line import/no-unassigned-import delete require.cache[require.resolve('..')]; }); }); diff --git a/gulpfile.js b/gulpfile.js index 49e2c686..1d73ceb7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,25 +1,12 @@ 'use strict'; var path = require('path'); var gulp = require('gulp'); -var eslint = require('gulp-eslint'); -var excludeGitignore = require('gulp-exclude-gitignore'); var mocha = require('gulp-mocha'); var istanbul = require('gulp-istanbul'); var nsp = require('gulp-nsp'); var plumber = require('gulp-plumber'); var coveralls = require('gulp-coveralls'); -gulp.task('static', function () { - return gulp.src([ - '**/*.js', - '!test/fixtures/**' - ]) - .pipe(excludeGitignore()) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - gulp.task('nsp', function (cb) { nsp({package: path.resolve('package.json')}, cb); }); @@ -57,4 +44,4 @@ gulp.task('coveralls', ['test'], function () { }); gulp.task('prepublish', ['nsp']); -gulp.task('default', ['static', 'test', 'coveralls']); +gulp.task('default', ['test', 'coveralls']); diff --git a/lib/actions/help.js b/lib/actions/help.js index 22559fa2..1b11f319 100644 --- a/lib/actions/help.js +++ b/lib/actions/help.js @@ -16,7 +16,7 @@ var help = module.exports; * source root otherwise uses a default description. */ -help.help = function help() { +help.help = function () { var filepath = path.join(this.sourceRoot(), '../USAGE'); var exists = pathExists.sync(filepath); var out = [ @@ -25,8 +25,8 @@ help.help = function help() { '' ]; - // build options - if (Object.keys(this._options).length) { + // Build options + if (Object.keys(this._options).length > 0) { out = out.concat([ 'Options:', this.optionsHelp(), @@ -34,8 +34,8 @@ help.help = function help() { ]); } - // build arguments - if (this._arguments.length) { + // Build arguments + if (this._arguments.length > 0) { out = out.concat([ 'Arguments:', this.argumentsHelp(), @@ -43,7 +43,7 @@ help.help = function help() { ]); } - // append USAGE file is any + // Append USAGE file is any if (exists) { out.push(fs.readFileSync(filepath, 'utf8')); } @@ -66,12 +66,12 @@ function formatArg(config) { * or options. */ -help.usage = function usage() { +help.usage = function () { var options = Object.keys(this._options).length ? '[options]' : ''; var name = ' ' + this.options.namespace; var args = ''; - if (this._arguments.length) { + if (this._arguments.length > 0) { args = this._arguments.map(formatArg).join(' '); } @@ -91,7 +91,7 @@ help.usage = function usage() { * @param {String} description */ -help.desc = function desc(description) { +help.desc = function (description) { this.description = description || ''; return this; }; @@ -100,9 +100,8 @@ help.desc = function desc(description) { * Get help text for arguments * @returns {String} Text of options in formatted table */ -help.argumentsHelp = function argumentsHelp() { +help.argumentsHelp = function () { var rows = this._arguments.map(function (config) { - return [ '', config.name ? config.name : '', @@ -119,7 +118,7 @@ help.argumentsHelp = function argumentsHelp() { * Get help text for options * @returns {String} Text of options in formatted table */ -help.optionsHelp = function optionsHelp() { +help.optionsHelp = function () { var options = _.reject(this._options, function (el) { return el.hide; }); @@ -130,7 +129,7 @@ help.optionsHelp = function optionsHelp() { opt.alias ? '-' + opt.alias + ', ' : '', '--' + opt.name, opt.description ? '# ' + opt.description : '', - opt.default != null && opt.default !== '' ? 'Default: ' + opt.default : '' + (opt.default !== undefined && opt.default !== null && opt.default !== '') ? 'Default: ' + opt.default : '' ]; }); diff --git a/lib/actions/install.js b/lib/actions/install.js index 922ce008..55b75cd4 100644 --- a/lib/actions/install.js +++ b/lib/actions/install.js @@ -34,7 +34,7 @@ install.runInstall = function (installer, paths, options, cb, spawnOptions) { options = options || {}; spawnOptions = spawnOptions || {}; cb = cb || function () {}; - paths = Array.isArray(paths) ? paths : paths && paths.split(' ') || []; + paths = Array.isArray(paths) ? paths : (paths && paths.split(' ')) || []; var args = ['install'].concat(paths).concat(dargs(options)); @@ -43,7 +43,7 @@ install.runInstall = function (installer, paths, options, cb, spawnOptions) { args[0] = 'add'; } - // only for npm, use a minimum cache of one day + // Only for npm, use a minimum cache of one day if (installer === 'npm') { args = args.concat(['--cache-min', 24 * 60 * 60]); } @@ -69,7 +69,7 @@ install.runInstall = function (installer, paths, options, cb, spawnOptions) { cb(err); done(); }.bind(this)); - }.bind(this), { once: installer + ' ' + args.join(' '), run: false }); + }.bind(this), {once: installer + ' ' + args.join(' '), run: false}); return this; }; @@ -158,7 +158,7 @@ install.installDependencies = function (options) { * @param {Object} [spawnOptions] Options to pass `child_process.spawn`. */ -install.bowerInstall = function install(cmpnt, options, cb, spawnOptions) { +install.bowerInstall = function (cmpnt, options, cb, spawnOptions) { return this.runInstall('bower', cmpnt, options, cb, spawnOptions); }; @@ -173,7 +173,7 @@ install.bowerInstall = function install(cmpnt, options, cb, spawnOptions) { * @param {Object} [spawnOptions] Options to pass `child_process.spawn`. */ -install.npmInstall = function install(pkgs, options, cb, spawnOptions) { +install.npmInstall = function (pkgs, options, cb, spawnOptions) { return this.runInstall('npm', pkgs, options, cb, spawnOptions); }; /** @@ -187,6 +187,6 @@ install.npmInstall = function install(pkgs, options, cb, spawnOptions) { * @param {Object} [spawnOptions] Options to pass `child_process.spawn`. */ -install.yarnInstall = function install(pkgs, options, cb, spawnOptions) { +install.yarnInstall = function (pkgs, options, cb, spawnOptions) { return this.runInstall('yarn', pkgs, options, cb, spawnOptions); }; diff --git a/lib/actions/spawn_command.js b/lib/actions/spawn-command.js similarity index 59% rename from lib/actions/spawn_command.js rename to lib/actions/spawn-command.js index dd14c42f..52b644fe 100644 --- a/lib/actions/spawn_command.js +++ b/lib/actions/spawn-command.js @@ -4,7 +4,7 @@ var spawn = require('cross-spawn'); /** * @mixin - * @alias actions/spawn_command + * @alias actions/spawn-command */ var spawnCommand = module.exports; @@ -15,9 +15,9 @@ var spawnCommand = module.exports; * @param {Array} args * @param {object} [opt] */ -spawnCommand.spawnCommand = function spawnCommand(command, args, opt) { +spawnCommand.spawnCommand = function (command, args, opt) { opt = opt || {}; - return spawn(command, args, _.defaults(opt, { stdio: 'inherit' })); + return spawn(command, args, _.defaults(opt, {stdio: 'inherit'})); }; /** @@ -27,7 +27,7 @@ spawnCommand.spawnCommand = function spawnCommand(command, args, opt) { * @param {Array} args * @param {object} [opt] */ -spawnCommand.spawnCommandSync = function spawnCommandSync(command, args, opt) { +spawnCommand.spawnCommandSync = function (command, args, opt) { opt = opt || {}; - return spawn.sync(command, args, _.defaults(opt, { stdio: 'inherit' })); + return spawn.sync(command, args, _.defaults(opt, {stdio: 'inherit'})); }; diff --git a/lib/actions/user.js b/lib/actions/user.js index 97ca3382..10b1446a 100644 --- a/lib/actions/user.js +++ b/lib/actions/user.js @@ -1,6 +1,7 @@ 'use strict'; var shell = require('shelljs'); var githubUsername = require('github-username'); + var nameCache = {}; var emailCache = {}; @@ -26,7 +27,7 @@ user.git.name = function () { } if (shell.which('git')) { - name = shell.exec('git config --get user.name', { silent: true }).stdout.trim(); + name = shell.exec('git config --get user.name', {silent: true}).stdout.trim(); nameCache[process.cwd()] = name; } @@ -46,7 +47,7 @@ user.git.email = function () { } if (shell.which('git')) { - email = shell.exec('git config --get user.email', { silent: true }).stdout.trim(); + email = shell.exec('git config --get user.email', {silent: true}).stdout.trim(); emailCache[process.cwd()] = email; } @@ -62,8 +63,8 @@ user.github.username = function (cb) { if (cb) { promise.then( - (val) => cb(null, val), - (err) => cb(err) + val => cb(null, val), + err => cb(err) ); } diff --git a/lib/index.js b/lib/index.js index 7aa4217d..eb847b3c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,10 +15,10 @@ var userHome = require('user-home'); var FileEditor = require('mem-fs-editor'); var pathIsAbsolute = require('path-is-absolute'); var pathExists = require('path-exists'); +var debug = require('debug')('yeoman:generator'); var Conflicter = require('./util/conflicter'); var Storage = require('./util/storage'); var promptSuggestion = require('./util/prompt-suggestion'); -var debug = require('debug')('yeoman:generator'); var EMPTY = '@@_YEOMAN_EMPTY_MARKER_@@'; @@ -32,7 +32,7 @@ var EMPTY = '@@_YEOMAN_EMPTY_MARKER_@@'; * * @constructor * @mixes actions/install - * @mixes actions/spawn_command + * @mixes actions/spawn-command * @mixes actions/user * @mixes actions/help * @mixes nodejs/EventEmitter @@ -58,7 +58,7 @@ var EMPTY = '@@_YEOMAN_EMPTY_MARKER_@@'; * }; */ -var Base = module.exports = function Base(args, options) { +var Base = module.exports = function (args, options) { events.EventEmitter.call(this); if (!Array.isArray(args)) { @@ -92,7 +92,7 @@ var Base = module.exports = function Base(args, options) { default: false }); - // checks required paramaters + // Checks required paramaters assert(this.options.env, 'You must provide the environment object. Use env#create() to create a new generator.'); assert(this.options.resolved, 'You must provide the resolved path value. Use env#create() to create a new generator.'); this.env = this.options.env; @@ -117,7 +117,7 @@ var Base = module.exports = function Base(args, options) { // this.log.error('bar'); this.log = this.env.adapter.log; - // determine the app root + // Determine the app root this.contextRoot = this.env.cwd; var rootPath = findUp.sync('.yo-rc.json', { @@ -138,7 +138,7 @@ var Base = module.exports = function Base(args, options) { this.config = this._getStorage(); this._globalConfig = this._getGlobalStorage(); - // ensure source/destination path, can be configured from subclasses + // Ensure source/destination path, can be configured from subclasses this.sourceRoot(path.join(path.dirname(this.resolved), 'templates')); }; @@ -147,10 +147,10 @@ util.inherits(Base, events.EventEmitter); // Mixin the actions modules _.extend(Base.prototype, require('./actions/install')); _.extend(Base.prototype, require('./actions/help')); -_.extend(Base.prototype, require('./actions/spawn_command')); +_.extend(Base.prototype, require('./actions/spawn-command')); Base.prototype.user = require('./actions/user'); -/** +/* * Prompt user to answer questions. The signature of this method is the same as {@link https://github.com/SBoudrias/Inquirer.js Inquirer.js} * * On top of the Inquirer.js API, you can provide a `{cache: true}` property for @@ -173,7 +173,6 @@ Base.prototype.prompt = function (questions) { return answers; }.bind(this)); - }; /** @@ -193,10 +192,10 @@ Base.prototype.prompt = function (questions) { * @param {Object} config */ -Base.prototype.option = function option(name, config) { +Base.prototype.option = function (name, config) { config = config || {}; - // alias default to defaults for backward compatibility. + // Alias default to defaults for backward compatibility. if ('defaults' in config) { config.default = config.defaults; } @@ -221,7 +220,7 @@ Base.prototype.option = function option(name, config) { ].join(''))); } - if (this._options[name] == null) { + if (this._options[name] === null || this._options[name] === undefined) { this._options[name] = config; } @@ -251,10 +250,10 @@ Base.prototype.option = function option(name, config) { * @param {Object} config */ -Base.prototype.argument = function argument(name, config) { +Base.prototype.argument = function (name, config) { config = config || {}; - // alias default to defaults for backward compatibility. + // Alias default to defaults for backward compatibility. if ('defaults' in config) { config.default = config.defaults; } @@ -262,7 +261,7 @@ Base.prototype.argument = function argument(name, config) { _.defaults(config, { name: name, - required: config.default == null, + required: config.default === null || config.default === undefined, type: String }); @@ -330,12 +329,10 @@ Base.prototype.parseOptions = function () { } else { return; } + } else if (config.type === Array) { + value = parsedOpts._.slice(index, parsedOpts._.length); } else { - if (config.type === Array) { - value = parsedOpts._.slice(index, parsedOpts._.length); - } else { - value = config.type(parsedOpts._[index]); - } + value = config.type(parsedOpts._[index]); } parsedOpts[config.name] = value; @@ -384,7 +381,7 @@ Base.prototype.checkRequiredArgs = function () { * @param {Function} [cb] */ -Base.prototype.run = function run(cb) { +Base.prototype.run = function (cb) { cb = cb || function () {}; var self = this; @@ -433,7 +430,7 @@ Base.prototype.run = function run(cb) { function addInQueue(name) { var item = Object.getPrototypeOf(self)[name]; - var queueName = self.env.runLoop.queueNames.indexOf(name) !== -1 ? name : null; + var queueName = self.env.runLoop.queueNames.indexOf(name) === -1 ? null : name; // Name points to a function; run it! if (_.isFunction(item)) { @@ -499,7 +496,7 @@ Base.prototype.run = function run(cb) { * this.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true }); */ -Base.prototype.composeWith = function composeWith(modulePath, options) { +Base.prototype.composeWith = function (modulePath, options) { var generator; options = options || {}; @@ -512,7 +509,7 @@ Base.prototype.composeWith = function composeWith(modulePath, options) { }, options); try { - var Generator = require(modulePath); + var Generator = require(modulePath); // eslint-disable-line import/no-dynamic-require Generator.resolved = require.resolve(modulePath); Generator.namespace = this.env.namespace(modulePath); generator = this.env.instantiate(Generator, { diff --git a/lib/util/conflicter.js b/lib/util/conflicter.js index 03985482..9fbe15de 100644 --- a/lib/util/conflicter.js +++ b/lib/util/conflicter.js @@ -4,9 +4,9 @@ var path = require('path'); var async = require('async'); var detectConflict = require('detect-conflict'); var _ = require('lodash'); -var binaryDiff = require('./binary-diff'); var pathExists = require('path-exists'); var typedError = require('error/typed'); +var binaryDiff = require('./binary-diff'); var AbortedError = typedError({ type: 'AbortedError', @@ -28,7 +28,7 @@ var AbortedError = typedError({ * @param {Boolean} force - When set to true, we won't check for conflict. (the * conflicter become a passthrough) */ -var Conflicter = module.exports = function Conflicter(adapter, force) { +var Conflicter = module.exports = function (adapter, force) { this.force = force === true; this.adapter = adapter; this.conflicts = []; diff --git a/lib/util/deprecate.js b/lib/util/deprecate.js index 587169cd..b043da5b 100644 --- a/lib/util/deprecate.js +++ b/lib/util/deprecate.js @@ -25,7 +25,7 @@ deprecate.object = function (message, object) { return; } - mirror[name] = deprecate(msgTpl({ name: name }), func); + mirror[name] = deprecate(msgTpl({name: name}), func); }); return mirror; diff --git a/lib/util/prompt-suggestion.js b/lib/util/prompt-suggestion.js index 9849f216..a15b66a1 100644 --- a/lib/util/prompt-suggestion.js +++ b/lib/util/prompt-suggestion.js @@ -40,9 +40,8 @@ var getListDefault = function (question, defaultValue) { var choiceValues = _.map(question.choices, function (choice) { if (typeof choice === 'object') { return choice.value; - } else { - return choice; } + return choice; }); return choiceValues.indexOf(defaultValue); @@ -59,8 +58,8 @@ var getListDefault = function (question, defaultValue) { * @private */ var storeListAnswer = function (question, answer, storeAll) { - var choiceValues = _.map(question.choices, function(choice) { - if (choice.hasOwnProperty('value')) { + var choiceValues = _.map(question.choices, function (choice) { + if (Object.prototype.hasOwnProperty.call(choice, 'value')) { return choice.value; } return choice; @@ -121,7 +120,7 @@ promptSuggestion.prefillQuestions = function (store, questions) { var storedValue = promptValues[question.name]; - if (storedValue == null) { + if (storedValue === undefined) { return question; } diff --git a/lib/util/storage.js b/lib/util/storage.js index 1362c75c..a69b7612 100644 --- a/lib/util/storage.js +++ b/lib/util/storage.js @@ -20,7 +20,7 @@ var _ = require('lodash'); * }); */ -var Storage = module.exports = function Storage(name, fs, configPath) { +var Storage = module.exports = function (name, fs, configPath) { assert(name, 'A name parameter is required to create a storage'); assert(configPath, 'A config filepath is required to create a storage'); diff --git a/package.json b/package.json index 67d44b49..fe5b1561 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,22 @@ "name": "yeoman-generator", "version": "1.1.0", "description": "Rails-inspired generator system that provides scaffolding for your apps", + "license": "BSD-2-Clause", + "repository": "yeoman/generator", "homepage": "http://yeoman.io", "author": "Yeoman", + "main": "lib", + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "xo && gulp", + "doc": "jsdoc -c jsdoc.json", + "prepublish": "gulp prepublish" + }, "files": [ "lib" ], - "main": "lib/index.js", "keywords": [ "development", "dev", @@ -21,16 +31,6 @@ "yeoman", "app" ], - "license": "BSD-2-Clause", - "repository": "yeoman/generator", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "gulp", - "doc": "jsdoc -c jsdoc.json", - "prepublish": "gulp prepublish" - }, "dependencies": { "async": "^2.0.0", "chalk": "^1.0.0", @@ -64,11 +64,8 @@ "yeoman-environment": "^1.1.0" }, "devDependencies": { - "eslint": "^3.15.0", "gulp": "^3.6.0", "gulp-coveralls": "^0.1.0", - "gulp-eslint": "^3.0.1", - "gulp-exclude-gitignore": "^1.0.0", "gulp-istanbul": "^1.0.0", "gulp-mocha": "^3.0.1", "gulp-nsp": "^2.1.0", @@ -81,7 +78,25 @@ "proxyquire": "^1.0.0", "sinon": "^1.9.1", "tui-jsdoc-template": "^1.0.4", + "xo": "^0.16.0", "yeoman-assert": "^3.0.0", "yeoman-test": "^1.0.0" + }, + "xo": { + "esnext": false, + "space": true, + "rules": { + "quote-props": "off", + "import/newline-after-import": "off" + }, + "overrides": [ + { + "files": "test/**", + "envs": [ + "node", + "mocha" + ] + } + ] } } diff --git a/readme.md b/readme.md index fe9f896e..95c4837e 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,7 @@ ![](https://raw.githubusercontent.com/yeoman/media/master/optimized/yeoman-masthead.png) + ## Getting Started If you're interested in writing your own Yeoman generator we recommend reading [the official getting started guide](http://yeoman.io/authoring/). The guide covers all the basics you need to get started. @@ -118,6 +119,7 @@ Love Yeoman work and community? Help us keep it alive by donating funds to cover + ## License [BSD license](http://opensource.org/licenses/bsd-license.php) diff --git a/test/base.js b/test/base.js index d6ef5f6e..ea18004e 100644 --- a/test/base.js +++ b/test/base.js @@ -1,7 +1,7 @@ -/*global describe, before, beforeEach, after, afterEach, it */ 'use strict'; var fs = require('fs'); var os = require('os'); +var LF = require('os').EOL; var path = require('path'); var util = require('util'); var sinon = require('sinon'); @@ -14,18 +14,17 @@ var Promise = require('pinkie-promise'); var yeoman = require('yeoman-environment'); var userHome = require('user-home'); -var LF = require('os').EOL; - mockery.enable({ warnOnReplace: false, warnOnUnregistered: false }); +var assert = require('yeoman-assert'); +var helpers = require('yeoman-test'); var TestAdapter = require('yeoman-test/lib/adapter').TestAdapter; var Base = require('..'); var Conflicter = require('../lib/util/conflicter'); -var helpers = require('yeoman-test'); -var assert = require('yeoman-assert'); + var tmpdir = path.join(os.tmpdir(), 'yeoman-base'); var resolveddir = path.join(os.tmpdir(), 'yeoman-base-generator'); @@ -33,7 +32,7 @@ describe('Base', function () { before(helpers.setUpTestDirectory(tmpdir)); beforeEach(function () { - this.env = yeoman.createEnv([], { 'skip-install': true }, new TestAdapter()); + this.env = yeoman.createEnv([], {'skip-install': true}, new TestAdapter()); mkdirp.sync(resolveddir); this.Dummy = Base.extend({ exec: sinon.spy() @@ -42,7 +41,7 @@ describe('Base', function () { this.dummy = new this.Dummy(['bar', 'baz', 'bom'], { foo: false, something: 'else', - // mandatory options, created by the env#create() helper + // Mandatory options, created by the env#create() helper resolved: resolveddir, namespace: 'dummy', env: this.env, @@ -114,7 +113,7 @@ describe('Base', function () { it('set options with false values', function (done) { var generator = helpers .run(path.join(__dirname, './fixtures/options-generator')) - .withOptions({ testOption: false }).on('end', function () { + .withOptions({testOption: false}).on('end', function () { assert.equal(generator.options.testOption, false); done(); }); @@ -179,7 +178,7 @@ describe('Base', function () { describe('.extend()', function () { it('create a new object inheriting the Generator', function () { - var gen = new (Base.extend())([], { resolved: 'path/', env: this.env }); + var gen = new (Base.extend())([], {resolved: 'path/', env: this.env}); assert.ok(gen instanceof Base); }); @@ -189,13 +188,13 @@ describe('Base', function () { }); it('assign prototype methods', function () { - var proto = { foo: function () {}}; + var proto = {foo: function () {}}; var Sub = Base.extend(proto); assert.equal(Sub.prototype.foo, proto.foo); }); it('assign static methods', function () { - var staticProps = { foo: function () {}}; + var staticProps = {foo: function () {}}; var Sub = Base.extend({}, staticProps); assert.equal(Sub.foo, staticProps.foo); }); @@ -465,7 +464,7 @@ describe('Base', function () { }); it('allow skipping file writes to disk', function (done) { - var action = { action: 'skip' }; + var action = {action: 'skip'}; var filepath = path.join(__dirname, '/fixtures/conflict.js'); assert(pathExists.sync(filepath)); @@ -473,7 +472,7 @@ describe('Base', function () { this.fs.write(filepath, 'some new content'); }; - var env = yeoman.createEnv([], { 'skip-install': true }, new TestAdapter(action)); + var env = yeoman.createEnv([], {'skip-install': true}, new TestAdapter(action)); var testGen = new this.TestGenerator([], { resolved: 'generator/app/index.js', namespace: 'dummy', @@ -487,12 +486,12 @@ describe('Base', function () { }); it('does not prompt again for skipped files', function (done) { - var action = { action: 'skip' }; + var action = {action: 'skip'}; var filepath = path.join(__dirname, '/fixtures/conflict.js'); var filepath2 = path.join(__dirname, '/fixtures/file-conflict.txt'); sinon.spy(Conflicter.prototype, 'checkForCollision'); - var env = yeoman.createEnv([], { 'skip-install': true }, new TestAdapter(action)); + var env = yeoman.createEnv([], {'skip-install': true}, new TestAdapter(action)); env.registerStub(this.Dummy, 'dummy:app'); // The composed generator need to write at least one file for it to go through it's @@ -607,7 +606,7 @@ describe('Base', function () { }); it('slice positional arguments when config.type is Array', function () { - this.dummy.argument('bar', { type: Array }); + this.dummy.argument('bar', {type: Array}); assert.deepEqual(this.dummy.options.bar, ['bar', 'baz', 'bom']); }); @@ -619,7 +618,7 @@ describe('Base', function () { done(); }); - dummy.argument('foo', { required: true }); + dummy.argument('foo', {required: true}); }); it('doesn\'t raise an error if required arguments are not provided, but the help option has been specified', function () { @@ -630,7 +629,7 @@ describe('Base', function () { }); assert.equal(dummy._arguments.length, 0); - assert.doesNotThrow(dummy.argument.bind(dummy, 'foo', { required: true })); + assert.doesNotThrow(dummy.argument.bind(dummy, 'foo', {required: true})); assert.equal(dummy._arguments.length, 1); }); @@ -641,7 +640,7 @@ describe('Base', function () { }); dummy.argument('baz'); - dummy.option('foo', { type: String }); + dummy.option('foo', {type: String}); assert.equal(dummy.options.baz, 'baz'); }); @@ -649,7 +648,7 @@ describe('Base', function () { describe('#option()', function () { it('add a new option to the set of generator expected options', function () { - // every generator have the --help options + // Every generator have the --help options var generator = new this.Dummy([], { env: this.env, resolved: 'test' @@ -707,12 +706,11 @@ describe('Base', function () { env: this.env, resolved: 'test' }); - var addWrongOp = function() { + var addWrongOp = function () { generator.option('no-op'); }; assert.throws(addWrongOp, /this\.option\('op', \{type: Boolean\}\)/); }); - }); describe('#parseOptions()', function () { @@ -772,7 +770,7 @@ describe('Base', function () { }); this.spy = sinon.spy(); - this.GenCompose = Base.extend({ exec: this.spy }); + this.GenCompose = Base.extend({exec: this.spy}); this.env.registerStub(this.GenCompose, 'composed:gen'); }); @@ -820,7 +818,7 @@ describe('Base', function () { beforeEach(function () { this.spy = sinon.spy(); this.stubPath = path.join(__dirname, 'fixtures/generator-mocha'); - this.LocalDummy = Base.extend({ exec: this.spy }); + this.LocalDummy = Base.extend({exec: this.spy}); mockery.registerMock(this.stubPath, this.LocalDummy); }); @@ -833,7 +831,7 @@ describe('Base', function () { }); it('pass options and arguments to the composed generators', function (done) { - this.dummy.composeWith(this.stubPath, { foo: 'bar', 'skip-install': true }); + this.dummy.composeWith(this.stubPath, {foo: 'bar', 'skip-install': true}); this.dummy.run(function () { assert.equal(this.spy.firstCall.thisValue.options.foo, 'bar'); @@ -891,7 +889,7 @@ describe('Base', function () { ]; help.split('\n').forEach(function (line, i) { - // do not test whitespace; we care about the content, not formatting. + // Do not test whitespace; we care about the content, not formatting. // formatting is best left up to the tests for module "text-table" assert.textEqual(line.trim().replace(/\s+/g, ' '), expected[i]); }); @@ -1057,7 +1055,6 @@ describe('Base', function () { if (e === 'end') { done(); - return; } }; } diff --git a/test/conflicter.js b/test/conflicter.js index aa25ae80..0dd2b237 100644 --- a/test/conflicter.js +++ b/test/conflicter.js @@ -1,12 +1,11 @@ -/*global describe, before, after, it, beforeEach, afterEach */ 'use strict'; var assert = require('assert'); var fs = require('fs'); var path = require('path'); var _ = require('lodash'); var sinon = require('sinon'); -var Conflicter = require('../lib/util/conflicter'); var TestAdapter = require('yeoman-test/lib/adapter').TestAdapter; +var Conflicter = require('../lib/util/conflicter'); describe('Conflicter', function () { beforeEach(function () { @@ -45,7 +44,7 @@ describe('Conflicter', function () { describe('#collision()', function () { beforeEach(function () { - this.conflictingFile = { path: __filename, contents: '' }; + this.conflictingFile = {path: __filename, contents: ''}; }); it('identical status', function (done) { @@ -71,7 +70,7 @@ describe('Conflicter', function () { }); it('user choose "yes"', function (done) { - var conflicter = new Conflicter(new TestAdapter({ action: 'write' })); + var conflicter = new Conflicter(new TestAdapter({action: 'write'})); conflicter.collision(this.conflictingFile, function (status) { assert.equal(status, 'force'); @@ -80,7 +79,7 @@ describe('Conflicter', function () { }); it('user choose "skip"', function (done) { - var conflicter = new Conflicter(new TestAdapter({ action: 'skip' })); + var conflicter = new Conflicter(new TestAdapter({action: 'skip'})); conflicter.collision(this.conflictingFile, function (status) { assert.equal(status, 'skip'); @@ -89,7 +88,7 @@ describe('Conflicter', function () { }); it('user choose "force"', function (done) { - var conflicter = new Conflicter(new TestAdapter({ action: 'force' })); + var conflicter = new Conflicter(new TestAdapter({action: 'force'})); conflicter.collision(this.conflictingFile, function (status) { assert.equal(status, 'force'); @@ -116,14 +115,14 @@ describe('Conflicter', function () { }); it('does not provide a diff option for directory', function (done) { - var conflicter = new Conflicter(new TestAdapter({ action: 'write' })); + var conflicter = new Conflicter(new TestAdapter({action: 'write'})); var spy = sinon.spy(conflicter.adapter, 'prompt'); conflicter.collision({ path: __dirname, contents: null }, function () { assert.equal( - _.filter(spy.firstCall.args[0][0].choices, { value: 'diff' }).length, + _.filter(spy.firstCall.args[0][0].choices, {value: 'diff'}).length, 0 ); done(); @@ -131,7 +130,7 @@ describe('Conflicter', function () { }); it('displays default diff for text files', function (done) { - var testAdapter = new TestAdapter({ action: 'diff' }); + var testAdapter = new TestAdapter({action: 'diff'}); var conflicter = new Conflicter(testAdapter); var _prompt = testAdapter.prompt.bind(testAdapter); var promptStub = sinon.stub(testAdapter, 'prompt', function (prompts, resultHandler) { @@ -142,9 +141,8 @@ describe('Conflicter', function () { }; return _prompt(prompts, stubbedResultHandler); - } else { - return _prompt(prompts, resultHandler); } + return _prompt(prompts, resultHandler); }); conflicter.collision({ @@ -158,7 +156,7 @@ describe('Conflicter', function () { }); it('displays custom diff for binary files', function (done) { - var testAdapter = new TestAdapter({ action: 'diff' }); + var testAdapter = new TestAdapter({action: 'diff'}); var conflicter = new Conflicter(testAdapter); var _prompt = testAdapter.prompt.bind(testAdapter); var promptStub = sinon.stub(testAdapter, 'prompt', function (prompts, resultHandler) { @@ -169,9 +167,8 @@ describe('Conflicter', function () { }; return _prompt(prompts, stubbedResultHandler); - } else { - return _prompt(prompts, resultHandler); } + return _prompt(prompts, resultHandler); }); conflicter.collision({ diff --git a/test/deprecate.js b/test/deprecate.js index 57991ecc..dfd7dd42 100644 --- a/test/deprecate.js +++ b/test/deprecate.js @@ -1,4 +1,3 @@ -/*global describe, before, beforeEach, after, afterEach, it */ 'use strict'; var assert = require('assert'); var chalk = require('chalk'); diff --git a/test/generators.js b/test/generators.js index 73ea5b88..35ef7efd 100644 --- a/test/generators.js +++ b/test/generators.js @@ -1,4 +1,3 @@ -/*global describe, before, beforeEach, it */ 'use strict'; var events = require('events'); var Environment = require('yeoman-environment'); diff --git a/test/install.js b/test/install.js index f95a32cf..b3fa7b9d 100644 --- a/test/install.js +++ b/test/install.js @@ -1,4 +1,3 @@ -/*global describe, it, before, after, beforeEach, afterEach */ 'use strict'; var yeoman = require('yeoman-environment'); var sinon = require('sinon'); @@ -41,7 +40,7 @@ describe('Base (actions/install mixin)', function () { } }; - // args: installer, paths, options, cb + // Args: installer, paths, options, cb this.dummy.runInstall('nestedScript', ['path1', 'path2'], options, callbackSpy, spawnEnv); this.dummy.run(function () { sinon.assert.calledWithExactly( @@ -113,7 +112,7 @@ describe('Base (actions/install mixin)', function () { }); it('spawn a bower process with formatted options', function (done) { - this.dummy.bowerInstall('jquery', { saveDev: true }, function () { + this.dummy.bowerInstall('jquery', {saveDev: true}, function () { sinon.assert.calledOnce(this.spawnCommandStub); sinon.assert.calledWithExactly( this.spawnCommandStub, @@ -140,7 +139,7 @@ describe('Base (actions/install mixin)', function () { }); it('run without callback', function (done) { - this.dummy.npmInstall('yo', { save: true }); + this.dummy.npmInstall('yo', {save: true}); this.dummy.run(function () { sinon.assert.calledOnce(this.spawnCommandStub); done(); @@ -148,7 +147,7 @@ describe('Base (actions/install mixin)', function () { }); it('run with callback', function (done) { - this.dummy.npmInstall('yo', { save: true }, function () { + this.dummy.npmInstall('yo', {save: true}, function () { sinon.assert.calledOnce(this.spawnCommandStub); done(); }.bind(this)); @@ -203,7 +202,7 @@ describe('Base (actions/install mixin)', function () { }); it('spawn yarn', function (done) { - this.dummy.installDependencies({ yarn: true, npm: false, callback: function () { + this.dummy.installDependencies({yarn: true, npm: false, callback: function () { sinon.assert.calledTwice(this.spawnCommandStub); sinon.assert.calledWithExactly(this.spawnCommandStub, 'bower', ['install'], {}); sinon.assert.calledWithExactly(this.spawnCommandStub, 'yarn', ['install'], {}); diff --git a/test/prompt-suggestion.js b/test/prompt-suggestion.js index 6c76623d..36d53c07 100644 --- a/test/prompt-suggestion.js +++ b/test/prompt-suggestion.js @@ -1,4 +1,3 @@ -/*global describe, it, before, after, beforeEach, afterEach */ 'use strict'; var path = require('path'); var assert = require('assert'); @@ -16,7 +15,7 @@ describe('PromptSuggestion', function () { this.fs = FileEditor.create(this.memFs); this.storePath = path.join(os.tmpdir(), 'suggestion-config.json'); this.store = new Storage('suggestion', this.fs, this.storePath); - this.store.set('promptValues', { respuesta: 'foo' }); + this.store.set('promptValues', {respuesta: 'foo'}); }); afterEach(function (done) { @@ -224,7 +223,7 @@ describe('PromptSuggestion', function () { describe('.storeAnswers()', function () { beforeEach(function () { - this.store.set('promptValues', { respuesta: 'foo' }); + this.store.set('promptValues', {respuesta: 'foo'}); }); it('require a store parameter', function () { @@ -263,7 +262,7 @@ describe('PromptSuggestion', function () { assert.equal(this.store.get('promptValues').respuesta, 'baz'); }); - it('don\`t store default answer in global store', function () { + it('don\'t store default answer in global store', function () { var question = { name: 'respuesta', default: 'bar', @@ -335,7 +334,7 @@ describe('PromptSuggestion', function () { beforeEach(function () { this.store.delete('promptValues'); }); - it('don\`t store default answer from rawlist type', function () { + it('don\'t store default answer from rawlist type', function () { var question = { type: 'rawlist', name: 'respuesta', diff --git a/test/spawn_command.js b/test/spawn-command.js similarity index 66% rename from test/spawn_command.js rename to test/spawn-command.js index 37ac29f8..d3e01860 100644 --- a/test/spawn_command.js +++ b/test/spawn-command.js @@ -1,13 +1,12 @@ -/*global it, describe, before, beforeEach, afterEach */ 'use strict'; var proxyquire = require('proxyquire'); var sinon = require('sinon'); -describe('generators.Base (actions/spawn_command)', function () { +describe('generators.Base (actions/spawn-command)', function () { beforeEach(function () { this.crossSpawn = sinon.spy(); this.crossSpawn.sync = sinon.spy(); - this.spawn = proxyquire('../lib/actions/spawn_command', { + this.spawn = proxyquire('../lib/actions/spawn-command', { 'cross-spawn': this.crossSpawn }); }); @@ -15,44 +14,44 @@ describe('generators.Base (actions/spawn_command)', function () { describe('#spawnCommand()', function () { it('provide default options', function () { this.spawn.spawnCommand('foo'); - sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, { stdio: 'inherit' }); + sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, {stdio: 'inherit'}); }); it('pass arguments', function () { this.spawn.spawnCommand('foo', 'bar'); - sinon.assert.calledWith(this.crossSpawn, 'foo', 'bar', { stdio: 'inherit' }); + sinon.assert.calledWith(this.crossSpawn, 'foo', 'bar', {stdio: 'inherit'}); }); it('pass options', function () { - this.spawn.spawnCommand('foo', undefined, { foo: 1 }); - sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, { foo: 1, stdio: 'inherit' }); + this.spawn.spawnCommand('foo', undefined, {foo: 1}); + sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, {foo: 1, stdio: 'inherit'}); }); it('allow overriding default options', function () { - this.spawn.spawnCommand('foo', undefined, { stdio: 'wut' }); - sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, { stdio: 'wut' }); + this.spawn.spawnCommand('foo', undefined, {stdio: 'wut'}); + sinon.assert.calledWith(this.crossSpawn, 'foo', undefined, {stdio: 'wut'}); }); }); describe('#spawnCommandSync()', function () { it('provide default options', function () { this.spawn.spawnCommandSync('foo'); - sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, { stdio: 'inherit' }); + sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, {stdio: 'inherit'}); }); it('pass arguments', function () { this.spawn.spawnCommandSync('foo', 'bar'); - sinon.assert.calledWith(this.crossSpawn.sync, 'foo', 'bar', { stdio: 'inherit' }); + sinon.assert.calledWith(this.crossSpawn.sync, 'foo', 'bar', {stdio: 'inherit'}); }); it('pass options', function () { - this.spawn.spawnCommandSync('foo', undefined, { foo: 1 }); - sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, { foo: 1, stdio: 'inherit' }); + this.spawn.spawnCommandSync('foo', undefined, {foo: 1}); + sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, {foo: 1, stdio: 'inherit'}); }); it('allow overriding default options', function () { - this.spawn.spawnCommandSync('foo', undefined, { stdio: 'wut' }); - sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, { stdio: 'wut' }); + this.spawn.spawnCommandSync('foo', undefined, {stdio: 'wut'}); + sinon.assert.calledWith(this.crossSpawn.sync, 'foo', undefined, {stdio: 'wut'}); }); }); }); diff --git a/test/storage.js b/test/storage.js index 55412d85..e44b4c42 100644 --- a/test/storage.js +++ b/test/storage.js @@ -1,4 +1,3 @@ -/*global describe, it, before, after, beforeEach, afterEach */ 'use strict'; var assert = require('assert'); var fs = require('fs'); @@ -7,8 +6,9 @@ var path = require('path'); var FileEditor = require('mem-fs-editor'); var pathExists = require('path-exists'); var env = require('yeoman-environment'); -var Storage = require('../lib/util/storage'); var helpers = require('yeoman-test'); +var Storage = require('../lib/util/storage'); + var tmpdir = path.join(os.tmpdir(), 'yeoman-storage'); function rm(filepath) { @@ -37,7 +37,7 @@ describe('Storage', function () { describe('.constructor()', function () { it('require a name parameter', function () { assert.throws(function () { - new Storage(); + new Storage(); // eslint-disable-line no-new }); }); @@ -56,7 +56,7 @@ describe('Storage', function () { it('a config path is required', function () { assert.throws(function () { - new Storage('yo', this.fs); + new Storage('yo', this.fs); // eslint-disable-line no-new }); }); @@ -79,7 +79,7 @@ describe('Storage', function () { }); it('set multipe values at once', function () { - this.store.set({ foo: 'bar', john: 'doe' }); + this.store.set({foo: 'bar', john: 'doe'}); assert.equal(this.store.get('foo'), 'bar'); assert.equal(this.store.get('john'), 'doe'); }); @@ -111,16 +111,16 @@ describe('Storage', function () { it('the saved value (without key)', function () { assert.deepEqual( - this.store.set({ foo: 'bar', john: 'doe' }), - { foo: 'bar', john: 'doe' } + this.store.set({foo: 'bar', john: 'doe'}), + {foo: 'bar', john: 'doe'} ); }); it('the saved value (update values)', function () { - this.store.set({ foo: 'bar', john: 'doe' }); + this.store.set({foo: 'bar', john: 'doe'}); assert.deepEqual( - this.store.set({ foo: 'moo' }), - { foo: 'moo', john: 'doe' } + this.store.set({foo: 'moo'}), + {foo: 'moo', john: 'doe'} ); }); }); @@ -162,7 +162,7 @@ describe('Storage', function () { describe('#getAll()', function () { beforeEach(function () { - this.store.set({ foo: 'bar', john: 'doe' }); + this.store.set({foo: 'bar', john: 'doe'}); }); it('get all values', function () { @@ -192,7 +192,7 @@ describe('Storage', function () { }); it('set defaults values if not predefined', function () { - this.store.defaults({ val1: 3, val2: 4 }); + this.store.defaults({val1: 3, val2: 4}); assert.equal(this.store.get('val1'), 1); assert.equal(this.store.get('val2'), 4); @@ -215,20 +215,20 @@ describe('Storage', function () { }); it('the saved value when passed an empty object', function () { - assert.deepEqual(this.store.defaults({}), { foo: 'bar', val1: 1 }); + assert.deepEqual(this.store.defaults({}), {foo: 'bar', val1: 1}); }); it('the saved value when passed the same key', function () { assert.deepEqual( - this.store.defaults({ foo: 'baz' }), - { foo: 'bar', val1: 1 } + this.store.defaults({foo: 'baz'}), + {foo: 'bar', val1: 1} ); }); it('the saved value when passed new key', function () { assert.deepEqual( - this.store.defaults({ food: 'pizza' }), - { foo: 'bar', val1: 1, food: 'pizza' } + this.store.defaults({food: 'pizza'}), + {foo: 'bar', val1: 1, food: 'pizza'} ); }); }); diff --git a/test/user.js b/test/user.js index c5f6eafe..ccaef8e5 100644 --- a/test/user.js +++ b/test/user.js @@ -1,4 +1,3 @@ -/*global describe, before, it, after, before, beforeEach, afterEach */ 'use strict'; var assert = require('assert'); var os = require('os'); @@ -10,6 +9,7 @@ var rimraf = require('rimraf'); var shell = require('shelljs'); var sinon = require('sinon'); var Base = require('..'); + var tmpdir = path.join(os.tmpdir(), 'yeoman-user'); describe('Base#user', function () { @@ -95,7 +95,7 @@ describe('Base#user', function () { .times(1) .reply(200, { items: [ - { login: 'mockname' } + {login: 'mockname'} ] }); });