Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix consistent-return eslint warnings #5334

Merged
merged 13 commits into from
Jul 23, 2019
2 changes: 2 additions & 0 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,8 @@ export default {
if (this.Router.getRouteName() === "tag") {
return this.Router.current().params.slug;
}

return null;
},

/**
Expand Down
8 changes: 7 additions & 1 deletion client/modules/i18n/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { mergeDeep } from "/lib/api";
* Every schema that feature an expireMonth and an expireYear
* field will be validated against the dateBeforeNow rule.
*/
// eslint-disable-next-line consistent-return
SimpleSchema.addValidator(function () {
let expireMonth;
let expireYear;
Expand Down Expand Up @@ -50,6 +51,8 @@ SimpleSchema.addValidator(function () {
}
}
}

return null;
});

/**
Expand Down Expand Up @@ -122,6 +125,7 @@ Meteor.startup(() => {
//
// subscribe to user + shop Translations
//
// eslint-disable-next-line consistent-return
return Meteor.subscribe("Translations", language, () => {
//
// reduce and merge translations
Expand Down Expand Up @@ -177,7 +181,9 @@ Meteor.startup(() => {
}
return $("html").removeClass("rtl");
});
}); // return

return null;
});
});

// Detect user currency changes.
Expand Down
8 changes: 6 additions & 2 deletions imports/collections/schemas/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export function createdAtAutoValue() {
// document, for example, in a product being added to cart items
if (this.closestSubschemaFieldName) return;

/* eslint-disable consistent-return */
// This function returns different `types`, therefore
// consistent-return needs to be disabled
if (this.isInsert) return new Date();
if (this.isUpsert) return { $setOnInsert: new Date() };
this.unset();
return this.unset();
/* eslint-enable consistent-return */
}

/**
Expand All @@ -30,7 +34,7 @@ export function createdAtAutoValue() {
export function updatedAtAutoValue() {
// We don't want to overwrite an updatedAt in a nested
// document, for example, in a product being added to cart items
if (this.closestSubschemaFieldName) return;
if (this.closestSubschemaFieldName) return null;

return new Date();
}
Expand Down
4 changes: 2 additions & 2 deletions imports/plugins/core/accounts/client/components/editGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EditGroup extends Component {
Object.assign({}, this.state.alertOptions, { i18nKey: "admin.settings.createGroupSuccess" })
);

this.setState({ isEditing: false });
return this.setState({ isEditing: false });
});
};

Expand All @@ -111,7 +111,7 @@ class EditGroup extends Component {
Object.assign({}, this.state.alertOptions, { i18nKey: "admin.settings.updateGroupSuccess" })
);

this.setState({ isEditing: false });
return this.setState({ isEditing: false });
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Forgot extends Component {
</div>
);
}

return null;
}

renderEmailErrors() {
Expand All @@ -61,6 +63,8 @@ class Forgot extends Component {
</span>
);
}

return null;
}

renderSpinnerOnWait() {
Expand Down
2 changes: 2 additions & 0 deletions imports/plugins/core/accounts/client/components/groupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class GroupForm extends Component {
if (this.props.updateGroup) {
return this.props.updateGroup(this.props.group._id, this.state);
}

return null;
};

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class LoginButtons extends Component {
</div>
);
}

return null;
}

render() {
Expand Down
19 changes: 16 additions & 3 deletions imports/plugins/core/accounts/client/components/permissionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import PropTypes from "prop-types";
import _ from "lodash";
import { Components, registerComponent } from "@reactioncommerce/reaction-components";

// resolvePermissions - helper to resolve toggled permission(s).
// It returns a list of all parent and child permissions when a parent permission is toggled.
/**
* @function
* @description helper to resolve toggled permissions
* @param {Object} permission permission to check
* @return {Array} list of all parent and child permissions when a parent permission is toggled
*/
function resolvePermissions(permission) {
const result = [];

Expand All @@ -19,7 +23,14 @@ function resolvePermissions(permission) {

return result;
}
// helper to remove all array items in "old" from "current"

/**
* @function
* @description helper to remove all array items in "old" from "current"
* @param {Array} current current array items
* @param {Array} old older array items
* @return {Array} updated permissions array
*/
function removePermissions(current, old) {
const currentArray = [...current];

Expand Down Expand Up @@ -65,6 +76,8 @@ class PermissionsList extends Component {
if (this.props.updateGroup) {
return this.props.updateGroup(this.state.group._id, groupData);
}

return null;
};

checked = (permission) => {
Expand Down
8 changes: 8 additions & 0 deletions imports/plugins/core/accounts/client/containers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class AuthContainer extends Component {
/>
);
}

return null;
}

render() {
Expand All @@ -207,6 +209,12 @@ class AuthContainer extends Component {
}
}

/**
* @private
* @param {Object} props Props
* @param {Function} onData Call this to update props
* @returns {undefined}
*/
function composer(props, onData) {
onData(null, { currentRoute: Router.current() });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ const handlers = {
Alerts.toast(i18next.t("accountsUI.info.emailUpdated"), "success");
return callback();
});

return null;
});

return null;
});
}
};
Expand Down
2 changes: 2 additions & 0 deletions imports/plugins/core/accounts/client/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const LoginFormSharedHelpers = {
if (error !== true && typeof error !== "undefined") {
return "has-error has-feedback";
}

return null;
},

/**
Expand Down
2 changes: 2 additions & 0 deletions imports/plugins/core/accounts/client/helpers/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ Template.registerHelper("displayName", (displayUser) => {
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}
}

return null;
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Template.accountsDashboard.helpers({
});
}
}

return null;
},

accountsDashboard() {
Expand All @@ -104,6 +106,7 @@ Template.accountsSettings.helpers({
const serviceHelper = new ServiceConfigHelper();
const configurations = ServiceConfiguration.configurations.find().fetch();

// eslint-disable-next-line consistent-return
const services = serviceHelper.services((item) => {
const matchingConfigurations = _.filter(configurations, {
service: item.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const LoginFormSharedHelpers = {
if (error !== true && typeof error !== "undefined") {
return "has-error has-feedback";
}

return null;
},
capitalize(str) {
const finalString = str === null ? "" : String(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ Template.registerHelper("displayName", (displayUser) => {
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}
}

return null;
});
10 changes: 10 additions & 0 deletions imports/plugins/core/accounts/client/templates/members/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Template.memberSettings.helpers({
return true;
}
}

return false;
},
userId() {
return Reaction.getUserId();
Expand All @@ -54,6 +56,8 @@ Template.memberSettings.helpers({
))) {
return "checked";
}

return null;
},
groupsForUser(groupUserId) {
const userId = groupUserId || this.userId || Template.parentData(1).userId;
Expand All @@ -67,6 +71,8 @@ Template.memberSettings.helpers({
if (shop && shop.name) {
return shop.name || "Default Shop";
}

return null;
},
permissionGroups(thisShopId) {
const permissionGroups = [];
Expand Down Expand Up @@ -117,6 +123,8 @@ Template.memberSettings.helpers({
permissions: _.uniq(permissions)
});
}

return null;
});

return permissionGroups;
Expand Down Expand Up @@ -188,5 +196,7 @@ Template.memberSettings.events({
}
return results;
}

return null;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ Template.accountProfile.helpers({
if (Reaction.hasPermission("account/profile")) {
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}

return null;
},

/**
Expand All @@ -147,6 +149,8 @@ Template.accountProfile.helpers({
return (defaultEmail && defaultEmail.address) || account.emails[0].address;
}
}

return null;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { decodeAccountOpaqueId } from "@reactioncommerce/reaction-graphql-xforms
import { decodeGroupOpaqueId } from "@reactioncommerce/reaction-graphql-xforms/group";

/**
* @name "Mutation.addAccountToGroup"
* @name Mutation/addAccountToGroup
* @method
* @memberof Accounts/GraphQL
* @summary resolver for the addAccountToGroup GraphQL mutation
Expand Down
1 change: 1 addition & 0 deletions imports/plugins/core/catalog/server/methods/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ Meteor.methods({
* @param {String} productId - productId to delete
* @returns {Number} returns number of removed products
*/
// eslint-disable-next-line consistent-return
"products/archiveProduct"(productId) {
check(productId, Match.OneOf(Array, String));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/* eslint-disable consistent-return */
import { GraphQLScalarType } from "graphql";
import { Kind } from "graphql/language";

const MAX_LIMIT = 200;

/**
* Adjusts value to be between 1 and MAX_LIMIT, inclusive
* @description Adjusts value to be between 1 and MAX_LIMIT, inclusive
* @private
* @param {Number|undefined} value value to check
* @return {Number|undefined} parsed value
*/
function parseValue(value) {
/* eslint-disable consistent-return */
if (value === undefined || isNaN(value)) return undefined;
if (typeof value !== "number") return MAX_LIMIT;
return Math.min(Math.max(1, value), MAX_LIMIT);
/* eslint-enable consistent-return */
}

const description = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function transform(doc, userId) {
return doc;
}

// eslint-disable-next-line consistent-return
Meteor.publish("Packages", function (shopId) {
check(shopId, Match.Maybe(String));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ Mongo.Collection.prototype._getCollection = function () {
return db.collection(this._name);
};

/**
* Provides a way to get at the underlying instance of the DB connection
* @param {Object} mongoConn mongo connection
* @returns {Object} The underlying Mongo connection database
*/
function wrapWithDb(mongoConn) {
if (mongoConn.db) {
return mongoConn.db;
}

return null;
}


Expand Down Expand Up @@ -92,7 +99,9 @@ export function ReactiveAggregate(pub, collection, pipeline, options) {
pub._ids = {};
pub._iteration = 1;

// run this function every time a record changes
/**
* @return {undefined}
*/
function update() {
if (initializing) {
return;
Expand Down
Loading