diff --git a/package.json b/package.json index 1cbd648815..6a9e767a09 100755 --- a/package.json +++ b/package.json @@ -24,10 +24,23 @@ "website/**" ], "rules": { + "array-callback-return": 0, + "brace-style": 0, + "camelcase": 0, + "default-case": 0, + "dot-notation": 0, + "no-case-declarations": 0, + "no-else-return": 0, "no-implicit-coercion": 0, + "no-lonely-if": 0, + "no-negated-condition": 0, + "no-throw-literal": 0, "no-unused-expressions": 0, + "no-unused-vars": 0, "padded-blocks": 0, "prefer-template": 0, + "quote-props": 0, + "space-infix-ops": 0, "strict": 0 } }, diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js index 35a43785bd..04c95f50cc 100755 --- a/packages/strapi-bookshelf/lib/index.js +++ b/packages/strapi-bookshelf/lib/index.js @@ -36,7 +36,6 @@ module.exports = function (strapi) { initialize: function (cb) { let globalName; - let attributes = []; // Make sure the Knex hook is present since Knex needs it. if (!strapi.hooks.knex) { @@ -101,7 +100,7 @@ module.exports = function (strapi) { const done = _.after(_.size(definition.attributes), function () { try { // Initialize lifecycle callbacks. - loadedModel.initialize = function() { + loadedModel.initialize = function () { const self = this; const lifecycle = { creating: 'beforeCreate', @@ -116,7 +115,7 @@ module.exports = function (strapi) { saved: 'afterSave' }; - _.forEach(lifecycle, function(fn, key) { + _.forEach(lifecycle, function (fn, key) { if (_.isFunction(strapi.models[model.toLowerCase()][fn])) { self.on(key, strapi.models[model.toLowerCase()][fn]); } @@ -155,13 +154,12 @@ module.exports = function (strapi) { // Build associations key if (!_.isEmpty(verbose)) { - utilsModels.defineAssociations(globalName, definition, details, name) + utilsModels.defineAssociations(globalName, definition, details, name); } switch (verbose) { case 'hasOne': - // Looking for foreign key on one-to-one relation - const FK = _.findKey(strapi.models[details.model].attributes, function(details) { + const FK = _.findKey(strapi.models[details.model].attributes, function (details) { if (details.hasOwnProperty('model') && details.model === model && details.hasOwnProperty('via') && details.via === name) { return details; } diff --git a/packages/strapi-bookshelf/lib/utils/graphql.js b/packages/strapi-bookshelf/lib/utils/graphql.js index ec3997f41d..95ec18ef1e 100755 --- a/packages/strapi-bookshelf/lib/utils/graphql.js +++ b/packages/strapi-bookshelf/lib/utils/graphql.js @@ -32,7 +32,7 @@ module.exports = { * @return {Object} */ - fetch: function(collectionIdentity, collection, criteria) { + fetch: function (collectionIdentity, collection, criteria) { return collection.forge(criteria) .fetch({withRelated: helpers.getAssociationsByIdentity(collectionIdentity)}) .then(function (data) { @@ -46,7 +46,7 @@ module.exports = { * @return {Array} */ - fetchAll: function(collectionIdentity, collection, criteria) { + fetchAll: function (collectionIdentity, collection, criteria) { const filters = _.omit(helpers.handleFilters(criteria), function (value) { return _.isUndefined(value) || _.isNumber(value) ? _.isNull(value) : _.isEmpty(value); }); @@ -119,7 +119,7 @@ module.exports = { return strapi.services[collectionIdentity.toLowerCase()] .add(rootValue.context.request.body) .then(function (data) { - return _.isFunction(_.get(data, 'toJSON')) ? data.toJSON() : data; + return _.isFunction(_.get(data, 'toJSON')) ? data.toJSON() : data; }); }, @@ -145,14 +145,14 @@ module.exports = { * @return {Object} */ - delete : function (collectionIdentity, rootValue, args) { + delete: function (collectionIdentity, rootValue, args) { _.merge(args, rootValue.context.request.body); return strapi.services[collectionIdentity.toLowerCase()] .remove(args) .then(function (data) { return _.isFunction(_.get(data, 'toJSON')) ? data.toJSON() : data; - }) + }); }, /** diff --git a/packages/strapi-bookshelf/lib/utils/index.js b/packages/strapi-bookshelf/lib/utils/index.js index c219285916..5290c73da9 100755 --- a/packages/strapi-bookshelf/lib/utils/index.js +++ b/packages/strapi-bookshelf/lib/utils/index.js @@ -20,7 +20,7 @@ module.exports = { getPK: function (collectionIdentity, collection, models) { // This is not a Bookshelf collection, only the name. if (_.isString(collectionIdentity) && !_.isUndefined(models)) { - const PK = _.findKey(_.get(models, collectionIdentity + '.attributes'), function(o) { + const PK = _.findKey(_.get(models, collectionIdentity + '.attributes'), function (o) { return o.hasOwnProperty('primary'); }); @@ -57,4 +57,4 @@ module.exports = { return count; }); } -} +}; diff --git a/packages/strapi-cli/bin/strapi-generate.js b/packages/strapi-cli/bin/strapi-generate.js index cff4c83f1c..0fecb60563 100755 --- a/packages/strapi-cli/bin/strapi-generate.js +++ b/packages/strapi-cli/bin/strapi-generate.js @@ -40,7 +40,7 @@ module.exports = function () { scope.generatorType = process.argv[2].split(':')[1]; // Register the name. - scope.generatorName = cliArguments[1] + scope.generatorName = cliArguments[1]; // Check that we're in a valid Strapi project. if (scope.generatorType !== 'new' || scope.generatorType !== 'generator' || scope.generatorType !== 'hook') { diff --git a/packages/strapi-knex/lib/index.js b/packages/strapi-knex/lib/index.js index 9065b93c95..0392d8c83b 100755 --- a/packages/strapi-knex/lib/index.js +++ b/packages/strapi-knex/lib/index.js @@ -60,25 +60,25 @@ module.exports = function (strapi) { _.forEach(strapi.config.connections, function (connection, name) { // Make sure we use the client even if the typo is not the exact one. - switch(connection.client) { + switch (connection.client) { case 'postgre': case 'postgres': case 'postgresql': - connection.client = 'pg' - break; + connection.client = 'pg'; + break; case 'sqlite': - connection.client = 'sqlite3' - break; + connection.client = 'sqlite3'; + break; case 'maria': case 'mariadb': - connection.client = 'mariasql' - break; + connection.client = 'mariasql'; + break; case 'ms': - connection.client = 'mssql' - break; + connection.client = 'mssql'; + break; case 'web': - connection.client = 'websql' - break; + connection.client = 'websql'; + break; } // Make sure the client is supported. diff --git a/packages/strapi/lib/configuration/hooks/graphql/schema.js b/packages/strapi/lib/configuration/hooks/graphql/schema.js index d61a380314..bc30275a32 100755 --- a/packages/strapi/lib/configuration/hooks/graphql/schema.js +++ b/packages/strapi/lib/configuration/hooks/graphql/schema.js @@ -95,7 +95,7 @@ module.exports = { const rootValue = { graphql: _.get(strapi.api, rootKey + '.config.graphql') || {} - } + }; // Override or write file fs.writeJson(path.join(strapi.config.appPath, 'api', rootKey, 'config', 'graphql.json'), _.merge(value, rootValue), function (err) { diff --git a/packages/strapi/lib/configuration/hooks/models/utils/index.js b/packages/strapi/lib/configuration/hooks/models/utils/index.js index e77cb1eb69..5d149523d5 100755 --- a/packages/strapi/lib/configuration/hooks/models/utils/index.js +++ b/packages/strapi/lib/configuration/hooks/models/utils/index.js @@ -23,9 +23,9 @@ module.exports = { getPK: function (collectionIdentity, collection, models) { if (_.isString(collectionIdentity)) { const ORM = this.getORM(collectionIdentity); + let GraphQLFunctions; try { const GraphQLFunctions = require(path.resolve(strapi.config.appPath, 'node_modules', 'strapi-' + ORM, 'lib', 'utils')); - if (!_.isUndefined(GraphQLFunctions)) { return GraphQLFunctions.getPK(collectionIdentity, collection, models || strapi.models); } @@ -46,9 +46,7 @@ module.exports = { const ORM = this.getORM(collectionIdentity); try { const GraphQLFunctions = require(path.resolve(strapi.config.appPath, 'node_modules', 'strapi-' + ORM, 'lib', 'utils')); - const ORMFunctions = require(path.resolve(strapi.config.appPath, 'node_modules', 'strapi-' + ORM, 'lib', 'utils')); - if (!_.isUndefined(ORMFunctions)) { return ORMFunctions.getCount(collectionIdentity); } diff --git a/packages/strapi/lib/private/initialize.js b/packages/strapi/lib/private/initialize.js index c9bf889e6d..48779aa59c 100755 --- a/packages/strapi/lib/private/initialize.js +++ b/packages/strapi/lib/private/initialize.js @@ -7,6 +7,9 @@ // Node.js core. const cluster = require('cluster'); +// Public node modules. +const _ = require('lodash'); + /** * `strapi.prototype.initialize()` *