Skip to content

Commit

Permalink
deps: update eslint-config-airbnb-base to version 11.0.0 🚀 (#560)
Browse files Browse the repository at this point in the history
* chore(package): update eslint-config-airbnb-base to version 11.0.0

https://greenkeeper.io/

* fix: linter errors
  • Loading branch information
greenkeeperio-bot authored and zacharygolba committed Dec 14, 2016
1 parent 821a2c4 commit a139b81
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 57 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"babel-plugin-transform-es2015-modules-commonjs": "6.18.0",
"babel-preset-lux": "1.3.0",
"chai": "3.5.0",
"eslint-config-airbnb-base": "10.0.1",
"eslint-config-airbnb-base": "11.0.0",
"eslint-plugin-flowtype": "2.29.1",
"eslint-plugin-import": "2.2.0",
"faker": "3.1.0",
Expand Down
46 changes: 28 additions & 18 deletions src/packages/cli/commands/dbmigrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CWD } from '../../../constants';
import Database, { pendingMigrations } from '../../database';
import Logger, { sql } from '../../logger';
import { createLoader } from '../../loader';
import { composeAsync } from '../../../utils/compose';

/**
* @private
Expand All @@ -29,23 +30,32 @@ export async function dbmigrate() {
const pending = await pendingMigrations(CWD, () => connection('migrations'));

if (pending.length) {
for (const migration of pending) {
const version = migration.replace(/^(\d{16})-.+$/g, '$1');
const key = migration.replace(new RegExp(`${version}-(.+)\\.js`), '$1');
const value = migrations.get(`${key}-up`);

if (value) {
const query = value.run(schema());

await query.on('query', () => {
process.stdout.write(sql`${query.toString()}`);
process.stdout.write(EOL);
});

await connection('migrations').insert({
version
});
}
}
const runners = pending
.map(name => {
const version = name.replace(/^(\d{16})-.+$/g, '$1');
const key = name.replace(new RegExp(`${version}-(.+)\\.js`), '$1');

return [version, migrations.get(`${key}-up`)];
})
.filter(([, migration]) => Boolean(migration))
.reverse()
.map(([version, migration]) => () => {
const query = migration.run(schema());

return query
.on('query', () => {
process.stdout.write(sql`${query.toString()}`);
process.stdout.write(EOL);
})
.then(() => (
connection('migrations').insert({
version
})
));
});

await composeAsync(...runners)();
}

return true;
}
2 changes: 1 addition & 1 deletion src/packages/compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function compile(dir: string, env: string, {
banner = `'use strict';\n\n${banner}`;
}

return await bundle.write({
return bundle.write({
banner,
dest: path.join(dir, 'dist', 'bundle.js'),
format: 'cjs',
Expand Down
56 changes: 32 additions & 24 deletions src/packages/compiler/utils/create-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { mkdir, writeFile, appendFile } from '../../fs';
import chain from '../../../utils/chain';
import tryCatch from '../../../utils/try-catch';
import underscore from '../../../utils/underscore';
import { compose } from '../../../utils/compose';

import stripExt from './strip-ext';
import formatName from './format-name';
Expand Down Expand Up @@ -36,31 +37,32 @@ function createWriter(file: string) {
const writerFor = (
type: string,
handleWrite: void | (value: string) => Promise<void>
) => async (value: string | Array<string>) => {
for (const item of value) {
if (handleWrite) {
await handleWrite(item);
} else {
) => (value: Array<string>) => {
const formatSymbol = compose(str => str + capitalize(type), formatName);

return Promise.all(
value.map(item => {
if (handleWrite) {
return handleWrite(item);
}

const path = joinPath('app', pluralize(type), item);
const name = chain(item)
.pipe(formatName)
.pipe(str => str + capitalize(type))
.value();

await appendFile(file, createExportStatement(name, path));
}
}
const symbol = formatSymbol(item);

return appendFile(file, createExportStatement(symbol, path));
})
);
};

return {
controllers: writerFor('controller'),
serializers: writerFor('serializer'),

models: writerFor('model', async (item) => {
models: writerFor('model', async item => {
const path = joinPath('app', 'models', item);
const name = formatName(item);

return await appendFile(file, createExportStatement(name, path));
return appendFile(file, createExportStatement(name, path));
}),

migrations: writerFor('migration', async (item) => {
Expand Down Expand Up @@ -102,13 +104,19 @@ export default async function createManifest(
await tryCatch(() => mkdir(dist));
await writeFile(file, useStrict ? '\'use strict\';\n\n' : '');

for (const [key, value] of assets) {
const write = Reflect.get(writer, key);

if (write) {
await write(value);
} else if (!write && typeof value === 'string') {
await appendFile(file, createExportStatement(key, value));
}
}
await Promise.all(
Array
.from(assets)
.map(([key, value]) => {
const write = Reflect.get(writer, key);

if (write) {
return write(value);
} else if (!write && typeof value === 'string') {
return appendFile(file, createExportStatement(key, value));
}

return Promise.resolve();
})
);
}
4 changes: 2 additions & 2 deletions src/packages/fs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export type { fs$ParsedPath } from './interfaces';
/**
* @private
*/
export async function watch(path: string): Promise<Watcher> {
return await new Watcher(path);
export function watch(path: string): Promise<Watcher> {
return new Watcher(path);
}

/**
Expand Down
20 changes: 12 additions & 8 deletions src/packages/pm/cluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NODE_ENV } from '../../../constants';
import { line } from '../../logger';
import omit from '../../../utils/omit';
import range from '../../../utils/range';
import { composeAsync } from '../../../utils/compose';
import type Logger from '../../logger'; // eslint-disable-line max-len, no-duplicate-imports

import type { Cluster$opts } from './interfaces';
Expand Down Expand Up @@ -201,24 +202,27 @@ class Cluster extends EventEmitter {
});
}

async reload() {
reload() {
if (this.workers.size) {
const workers = Array
const groups = Array
.from(this.workers)
.reduce((arr, item, idx, src) => {
if ((idx + 1) % 2) {
return [...arr, src.slice(idx, idx + 2)];
const group = src.slice(idx, idx + 2);

return [
...arr,
() => Promise.all(group.map(worker => this.shutdown(worker)))
];
}

return arr;
}, []);

for (const group of workers) {
await Promise.all(group.map(worker => this.shutdown(worker)));
}
} else {
await this.fork();
return composeAsync(...groups)();
}

return this.fork();
}

forkAll() {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/router/route/action/enhancers/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function resource(action: Action<any>): Action<any> {
};
}

return await serializer.format({
return serializer.format({
data,
links,
domain,
Expand Down
3 changes: 2 additions & 1 deletion src/packages/router/route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class Route extends FreezeableSet<Action<any>> {
let data;

for (const handler of this) {
// eslint-disable-next-line no-await-in-loop
data = await handler(req, res, data);

if (handler.name === FINAL_HANDLER) {
Expand Down Expand Up @@ -160,7 +161,7 @@ class Route extends FreezeableSet<Action<any>> {
validateResourceId(req);
}

return await this.execHandlers(req, res);
return this.execHandlers(req, res);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/packages/serializer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ class Serializer<T: Model> {
)
};
} else if (related && related.id) {
return await this.formatRelationship({
return this.formatRelationship({
domain,
included,
item: related,
Expand Down

0 comments on commit a139b81

Please sign in to comment.