Skip to content

Commit

Permalink
Use XO
Browse files Browse the repository at this point in the history
So we don't have to manually manage a huge .eslintrc file
  • Loading branch information
sindresorhus committed Feb 11, 2017
1 parent 17173a2 commit 6d267f0
Show file tree
Hide file tree
Showing 26 changed files with 184 additions and 316 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
121 changes: 0 additions & 121 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
*.js text eol=lf
28 changes: 15 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
- 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: [email protected]
- 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=
4 changes: 2 additions & 2 deletions benchmark/module.js
Original file line number Diff line number Diff line change
@@ -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('..')];
});
});
15 changes: 1 addition & 14 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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);
});
Expand Down Expand Up @@ -57,4 +44,4 @@ gulp.task('coveralls', ['test'], function () {
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test', 'coveralls']);
gulp.task('default', ['test', 'coveralls']);
25 changes: 12 additions & 13 deletions lib/actions/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -25,25 +25,25 @@ 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(),
''
]);
}

// build arguments
if (this._arguments.length) {
// Build arguments
if (this._arguments.length > 0) {
out = out.concat([
'Arguments:',
this.argumentsHelp(),
''
]);
}

// append USAGE file is any
// Append USAGE file is any
if (exists) {
out.push(fs.readFileSync(filepath, 'utf8'));
}
Expand All @@ -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(' ');
}

Expand All @@ -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;
};
Expand All @@ -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 : '',
Expand All @@ -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;
});
Expand All @@ -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 : ''
];
});

Expand Down
12 changes: 6 additions & 6 deletions lib/actions/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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]);
}
Expand All @@ -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;
};
Expand Down Expand Up @@ -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);
};

Expand All @@ -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);
};
/**
Expand All @@ -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);
};
10 changes: 5 additions & 5 deletions lib/actions/spawn_command.js → lib/actions/spawn-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var spawn = require('cross-spawn');

/**
* @mixin
* @alias actions/spawn_command
* @alias actions/spawn-command
*/
var spawnCommand = module.exports;

Expand All @@ -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'}));
};

/**
Expand All @@ -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'}));
};
Loading

0 comments on commit 6d267f0

Please sign in to comment.