Skip to content

Commit

Permalink
Start lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed May 29, 2019
1 parent 69b1899 commit 31a222e
Show file tree
Hide file tree
Showing 19 changed files with 692 additions and 382 deletions.
2 changes: 1 addition & 1 deletion examples/getstarted/config/functions/responses/404.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = async ctx => {
module.exports = async (/* ctx */) => {
// return ctx.notFound('My custom message 404');
};
3 changes: 1 addition & 2 deletions fileTransformer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const path = require('path');

module.exports = {
process(src, filename, config, options) {
process(src, filename) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};

2 changes: 0 additions & 2 deletions jest.config.front.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const jest = require('jest');

module.exports = {
collectCoverageFrom: [
'packages/strapi-admin/admin/src/**/**/*.js',
Expand Down
1 change: 0 additions & 1 deletion packages/strapi-admin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const chalk = require('chalk');
const fs = require('fs-extra');
const webpack = require('webpack');
const getWebpackConfig = require('./webpack.config.js');
Expand Down
3 changes: 0 additions & 3 deletions packages/strapi-admin/webpack.alias.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const path = require('path');
const pkg = require('./package.json');

const alias = [
'object-assign',
'whatwg-fetch',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = async ctx => {
module.exports = async (/* ctx */) => {
// return ctx.notFound('My custom message 404');
};
2 changes: 1 addition & 1 deletion packages/strapi-generate-new/lib/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async function handleCustomDatabase({ scope, hasDatabaseConfig, isQuick }) {
message: `Port${
isMongo ? ' (It will be ignored if you enable +srv)' : ''
}:`,
default: answers => {
default: () => {
// eslint-disable-line no-unused-vars
if (_.get(scope.database, 'port')) {
return scope.database.port;
Expand Down
5 changes: 3 additions & 2 deletions packages/strapi-helper-plugin/lib/src/utils/request.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'whatwg-fetch';
import auth from './auth';
import _ from 'lodash';

/**
* Parses the JSON returned by a network request
Expand Down Expand Up @@ -136,7 +137,7 @@ export default function request(...args) {
options.headers,
{
'X-Forwarded-Host': 'strapi',
},
}
);
}

Expand All @@ -147,7 +148,7 @@ export default function request(...args) {
{
Authorization: `Bearer ${token}`,
},
options.headers,
options.headers
);
}

Expand Down
9 changes: 7 additions & 2 deletions packages/strapi-hook-bookshelf/lib/buildDatabaseSchema.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const _ = require('lodash');
const pluralize = require('pluralize');
const { models: utilsModels } = require('strapi-utils');

/* global StrapiConfigs */
module.exports = async ({ ORM, loadedModel, definition, connection, model }) => {
module.exports = async ({
ORM,
loadedModel,
definition,
connection,
model,
}) => {
const quote = definition.client === 'pg' ? '"' : '`';

// Equilize database tables
Expand Down
44 changes: 31 additions & 13 deletions packages/strapi-hook-mongoose/lib/buildQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ const utils = require('./utils')();
* @param {Object} options.populate - An array of paths to populate
* @param {boolean} options.aggregate - Force aggregate function to use group by feature
*/
const buildQuery = ({ model, filters = {}, populate = [], aggregate = false } = {}) => {
const deepFilters = (filters.where || []).filter(({ field }) => field.split('.').length > 1);
const buildQuery = ({
model,
filters = {},
populate = [],
aggregate = false,
} = {}) => {
const deepFilters = (filters.where || []).filter(
({ field }) => field.split('.').length > 1
);

if (deepFilters.length === 0 && aggregate === false) {
return buildSimpleQuery({ model, filters, populate });
Expand Down Expand Up @@ -60,7 +67,11 @@ const buildDeepQuery = ({ model, filters, populate }) => {

// Init the query
let query = model
.aggregate(buildQueryAggregate(model, { paths: _.merge({}, populatePaths, wherePaths) }))
.aggregate(
buildQueryAggregate(model, {
paths: _.merge({}, populatePaths, wherePaths),
})
)
.append(buildQueryMatches(model, filters));

query = applyQueryParams({ query, filters });
Expand Down Expand Up @@ -98,7 +109,9 @@ const buildDeepQuery = ({ model, filters, populate }) => {
* Maps to query.count
*/
count() {
return query.count('count').then(results => _.get(results, ['0', 'count'], 0));
return query
.count('count')
.then(results => _.get(results, ['0', 'count'], 0));
},

/**
Expand Down Expand Up @@ -202,7 +215,8 @@ const computePopulatedPaths = ({ model, populate = [], where = [] }) => {
* }
* @param {Array<string>} paths - A list of paths to transform
*/
const pathsToTree = paths => paths.reduce((acc, path) => _.merge(acc, _.set({}, path, {})), {});
const pathsToTree = paths =>
paths.reduce((acc, path) => _.merge(acc, _.set({}, path, {})), {});

/**
* Builds the aggregations pipeling of the query
Expand Down Expand Up @@ -246,11 +260,11 @@ const buildLookup = ({ model, key, paths }) => {
].concat(
assoc.type === 'model'
? {
$unwind: {
path: `$${assoc.alias}`,
preserveNullAndEmptyArrays: true,
},
}
$unwind: {
path: `$${assoc.alias}`,
preserveNullAndEmptyArrays: true,
},
}
: []
);
};
Expand Down Expand Up @@ -314,7 +328,9 @@ const buildLookupMatch = ({ assoc }) => {
case 'manyToManyMorph':
case 'oneToManyMorph': {
return [
{ $unwind: { path: `$${assoc.via}`, preserveNullAndEmptyArrays: true } },
{
$unwind: { path: `$${assoc.via}`, preserveNullAndEmptyArrays: true },
},
{
$match: {
$expr: {
Expand Down Expand Up @@ -424,7 +440,7 @@ const buildWhereClause = ({ field, operator, value }) => {
};

default:
throw new Error(`Unhandled whereClause : ${fullField} ${operator} ${value}`);
throw new Error(`Unhandled whereClause : ${field} ${operator} ${value}`);
}
};

Expand Down Expand Up @@ -497,7 +513,9 @@ const hydrateModel = ({ model: rootModel, populatedModels }) => async obj => {

acc.push({
path: key,
data: Array.isArray(val) ? Promise.all(val.map(v => subHydrate(v))) : subHydrate(val),
data: Array.isArray(val)
? Promise.all(val.map(v => subHydrate(v)))
: subHydrate(val),
});

return acc;
Expand Down
4 changes: 1 addition & 3 deletions packages/strapi-plugin-graphql/services/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @description: A set of functions similar to controller's actions to avoid code duplication.
*/

const fs = require('fs');
const path = require('path');
const { gql, makeExecutableSchema } = require('apollo-server-koa');
const _ = require('lodash');
const graphql = require('graphql');
Expand Down Expand Up @@ -287,7 +285,7 @@ const schemaBuilder = {

writeGenerateSchema: schema => {
return strapi.fs.writeAppFile('exports/graphql/schema.graphql', schema);
}
},
};

module.exports = schemaBuilder;
Loading

0 comments on commit 31a222e

Please sign in to comment.