Skip to content

Commit

Permalink
Merge pull request #3604 from reactioncommerce/refactor-3570-willopez…
Browse files Browse the repository at this point in the history
…-fix-eslint-errors

Refactor 3570 willopez fix eslint errors
  • Loading branch information
spencern authored Feb 3, 2018
2 parents 0c4e299 + 50a9170 commit 71e4253
Show file tree
Hide file tree
Showing 110 changed files with 483 additions and 428 deletions.
34 changes: 22 additions & 12 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"no-confusing-arrow": ["error", { "allowParens": true }],
"no-empty-pattern": "error",
"no-lonely-if": "error",
// This rule copied from Airbnb's config
// This rule copied from Airbnb's config
"no-mixed-operators": ["error", {
"groups": [
["%", "**"],
Expand All @@ -317,18 +317,18 @@
"no-plusplus": "error",
"no-prototype-builtins": "error",
"no-tabs": "error",
// "no-undef-init": "error",
// "no-unneeded-ternary": ["error", { "defaultAssignment": false }],
// "no-unsafe-finally": "error",
// "no-useless-computed-key": "error",
// "no-useless-concat": "error",
// "no-useless-constructor": "error",
// "no-useless-escape": "error",
// "no-void": "error",
// "object-curly-newline": ["error", { "ObjectExpression": { "multiline": true, "consistent": true }, "ObjectPattern": { "multiline": true, "consistent": true } }],
// "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
"no-undef-init": "error",
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
"no-unsafe-finally": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-void": "error",
"object-curly-newline": ["error", { "ObjectExpression": { "multiline": true, "consistent": true }, "ObjectPattern": { "multiline": true, "consistent": true } }],
"object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
"object-shorthand": ["error", "always"],
// "operator-assignment": ["error", "always"],
"operator-assignment": ["error", "always"],
"prefer-arrow-callback": ["error", { "allowNamedFunctions": false, "allowUnboundThis": true }],
// "prefer-destructuring": ["error", {
// "VariableDeclarator": {
Expand All @@ -342,6 +342,16 @@
// }, {
// "enforceForRenamedProperties": false
// }],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"rest-spread-spacing": ["error", "never"],
// "space-unary-ops": ["error", {
// "words": true,
// "nonwords": false,
// "overrides": {}
// }],
// "template-curly-spacing": "error"
// "prefer-rest-params": "error",
// "prefer-spread": "error",
// "prefer-template": "error",
Expand Down
2 changes: 1 addition & 1 deletion client/modules/core/helpers/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function Apps(optionHash) {
const value = options[key];
if (value) {
if (!(key === "enabled" || key === "name" || key === "shopId")) {
filter["registry." + key] = Array.isArray(options[key]) ? { $in: value } : value;
filter[`registry.${key}`] = Array.isArray(options[key]) ? { $in: value } : value;
registryFilter[key] = value;
} else {
// perhaps not the best way to check but lets admin see all packages
Expand Down
7 changes: 3 additions & 4 deletions client/modules/core/helpers/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ Template.registerHelper("key_value", (context) => {
* @returns {String} returns formatted Spacebars.SafeString
*/
Template.registerHelper("nl2br", (text) => {
const nl2br = (text + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1" +
"<br>" + "$2");
const nl2br = (`${text}`).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1<br>$2");
return new Spacebars.SafeString(nl2br);
});

Expand Down Expand Up @@ -316,7 +315,7 @@ Template.registerHelper("timeAgo", (context) => moment(context).from(new Date())
*/
Template.registerHelper("pluralize", (nCount, pString) => {
if (nCount === 1) {
return "1 " + pString;
return `1 ${pString}`;
}
return nCount + " " + pString + "s";
return `${nCount} ${pString}s`;
});
4 changes: 2 additions & 2 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export default {

// Primary Shop should probably not have a prefix (or should it be /shop?)
getPrimaryShopPrefix() {
return "/" + this.getSlug(this.getPrimaryShopName().toLowerCase());
return `/${this.getSlug(this.getPrimaryShopName().toLowerCase())}`;
},

getPrimaryShopSettings() {
Expand Down Expand Up @@ -502,7 +502,7 @@ export default {
getShopPrefix() {
const shopName = this.getShopName();
if (shopName) {
return "/" + this.getSlug(shopName.toLowerCase());
return `/${this.getSlug(shopName.toLowerCase())}`;
}
},

Expand Down
4 changes: 2 additions & 2 deletions client/modules/core/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function isLocalStorageAvailable() {
}

function readCookie(name) {
const nameEq = name + "=";
const nameEq = `${name}=`;
const ca = document.cookie.split(";");
for (let i = 0; i < ca.length; i += 1) {
let c = ca[i];
Expand All @@ -79,5 +79,5 @@ function readCookie(name) {
}

function createSessionCookie(name, value) {
document.cookie = name + "=" + value + "; path=/";
document.cookie = `${name}=${value}; path=/`;
}
4 changes: 2 additions & 2 deletions client/modules/i18n/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export function getLabelsFor(schema, name) {
const labels = {};
// loop through all the rendered form fields and generate i18n keys
for (const fieldName of schema._schemaKeys) {
const i18nKey = name.charAt(0).toLowerCase() + name.slice(1) + "." +
const i18nKey = `${name.charAt(0).toLowerCase() + name.slice(1)}.${
fieldName
.split(".$").join("");
.split(".$").join("")}`;
// translate autoform label
const t = i18next.t(i18nKey);
if (new RegExp("string").test(t) !== true && t !== i18nKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const GroupsTableCell = ({ account, columnName, group, adminGroups, handleRemove
// Permission check. Remove owner option, if user is not current owner.
// Also remove groups user does not have roles to manage. This is also checked on the server
const dropOptions = groups
.filter((grp) => ((grp.slug === "owner" && !hasOwnerAccess) ? false : true))
.filter((grp) => !((grp.slug === "owner" && !hasOwnerAccess)))
.filter((grp) => Reaction.canInviteToGroup({ group: grp })) || [];

if (dropOptions.length < 2) { return dropDownButton(); } // do not use dropdown if only one option
Expand Down
2 changes: 1 addition & 1 deletion imports/plugins/core/accounts/client/containers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AuthContainer extends Component {
serviceName = this.capitalizeName(serviceName);
}

const loginWithService = Meteor["loginWith" + serviceName];
const loginWithService = Meteor[`loginWith${serviceName}`];
const options = {}; // use default scope unless specified

loginWithService(options, (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ export function groupPermissions(packages) {
if (!permissionMap[registryItem.route]) {
permissions.push({
shopId: pkg.shopId,
permission: registryItem.name || pkg.name + "/" + registryItem.template,
permission: registryItem.name || `${pkg.name}/${registryItem.template}`,
icon: registryItem.icon,
// TODO: Rethink naming convention for permissions list
label: registryItem.label || registryItem.route
});
}
}
// TODO review this, hardcoded WIP "reaction"
const label = pkg.name.replace("reaction", "").replace(/(-.)/g, (x) => " " + x[1].toUpperCase());
const label = pkg.name.replace("reaction", "").replace(/(-.)/g, (x) => ` ${x[1].toUpperCase()}`);

const newObj = {
shopId: pkg.shopId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Template.addressBookForm.helpers({
if (!selectedCountry) {
return false;
}
if ((shop !== null ? shop.locales.countries[selectedCountry].states : void 0) === null) {
if ((shop !== null ? shop.locales.countries[selectedCountry].states : undefined) === null) {
return false;
}
const options = [];
const ref = shop !== null ? shop.locales.countries[selectedCountry].states : void 0;
const ref = shop !== null ? shop.locales.countries[selectedCountry].states : undefined;
for (const state in ref) {
if ({}.hasOwnProperty.call(ref, state)) {
locale = ref[state];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ Template.memberSettings.helpers({
if (!permissionMap[registryItem.route]) {
permissions.push({
shopId: pkg.shopId,
permission: registryItem.name || pkg.name + "/" + registryItem.template, // launchdock-connect/connectDashboard
permission: registryItem.name || `${pkg.name}/${registryItem.template}`, // launchdock-connect/connectDashboard
icon: registryItem.icon,
label: registryItem.label || registryItem.provides || registryItem.route
});
}
}
// TODO review this, hardcoded WIP
const label = pkg.name.replace("reaction", "").replace(/(-.)/g, (x) => " " + x[1].toUpperCase());
const label = pkg.name.replace("reaction", "").replace(/(-.)/g, (x) => ` ${x[1].toUpperCase()}`);

return permissionGroups.push({
shopId: pkg.shopId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Template.userOrdersList.helpers({
orders = [];
}

return { component: UserOrdersList,
return {
component: UserOrdersList,
orders
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const creditCardClasses = {
*/
const CompletedOrderPaymentMethod = ({ paymentMethod }) => {
// allow i18n override for "processor" label
const i18nKey = "checkout.paymentMethod." + paymentMethod.processor;
const i18nKey = `checkout.paymentMethod.${paymentMethod.processor}`;
// display stored card methods
if (paymentMethod.method === "credit" && paymentMethod.storedCard) {
const creditCardType = paymentMethod.storedCard.substring(0, 4).toUpperCase();
Expand Down
3 changes: 1 addition & 2 deletions imports/plugins/core/checkout/server/methods/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ Meteor.methods({
if (gotoNextWorkflowStep && statusExistsInWorkflow === true &&
templateProcessedinWorkflow === false) {
Logger.debug(
"######## Condition Three #########: complete workflow " +
currentWorkflowStatus + " updates and move to: ",
`######## Condition Three #########: complete workflow ${currentWorkflowStatus} updates and move to: `,
nextWorkflowStep.template
);
return Cart.update(currentCart._id, {
Expand Down
2 changes: 1 addition & 1 deletion imports/plugins/core/collections/lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Validation {
const hasMessage = messages[fieldName];

fields[fieldName] = {
isValid: hasMessage ? false : true,
isValid: !hasMessage,
value: cleanedObject[fieldName]
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function enableReactionPackage(reactionPackage) {
{ app: i18next.t(self.i18nKeyLabel) }
),
"error", {
type: "pkg-enabled-" + self.name
type: `pkg-enabled-${self.name}`
}
);
if (self.name || self.route) {
Expand Down
6 changes: 3 additions & 3 deletions imports/plugins/core/email/client/components/emailLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class EmailLogs extends Component {
// add i18n handling to headers
const customColumnMetadata = [];
filteredFields.forEach((field) => {
let colWidth = undefined;
let colStyle = undefined;
let colClassName = undefined;
let colWidth;
let colStyle;
let colClassName;

if (field === "status") {
colWidth = 70;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const composer = (props, onData) => {
const locale = Reaction.Locale.get();

if (profileCurrency && shop.currencies[profileCurrency] && shop.currencies[profileCurrency].symbol) {
currentCurrency = profileCurrency + " " + shop.currencies[profileCurrency].symbol;
currentCurrency = `${profileCurrency} ${shop.currencies[profileCurrency].symbol}`;
} else if (locale && locale.currency && locale.currency.enabled) {
currentCurrency = locale.locale.currency.split(",")[0] + " " + locale.currency.symbol;
currentCurrency = `${locale.locale.currency.split(",")[0]} ${locale.currency.symbol}`;
} else {
currentCurrency = shop.currency.split(",")[0] + " " + shop.currencies[shop.currency].symbol;
currentCurrency = `${shop.currency.split(",")[0]} ${shop.currencies[shop.currency].symbol}`;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const composer = (props, onData) => {
if (typeof shop === "object" && shop.languages) {
for (const language of shop.languages) {
if (language.enabled === true) {
language.translation = "languages." + language.label.toLowerCase();
language.translation = `languages.${language.label.toLowerCase()}`;
// appending a helper to let us know this
// language is currently selected
const { profile } = Meteor.user();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function composer(props, onData) {

if (typeof shop === "object" && shop.languages) {
for (const language of shop.languages) {
const i18nKey = "languages." + language.label.toLowerCase();
const i18nKey = `languages.${language.label.toLowerCase()}`;
languages.push({
label: language.label,
value: language.i18n,
Expand All @@ -89,8 +89,7 @@ function composer(props, onData) {
}

const structure = currencies[currency];
const label = currency + " | " + structure.symbol + " | " +
structure.format;
const label = `${currency} | ${structure.symbol} | ${structure.format}`;

currencyList.push({
name: currency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function addBodyClasses(context) {
} else {
classes = [
// push clean route-name
"app-" + context.route.name.replace(/[\/_]/i, "-")
`app-${context.route.name.replace(/[/_]/i, "-")}`
];
}

Expand Down
6 changes: 3 additions & 3 deletions imports/plugins/core/layout/lib/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export function getComponent(name) {
try {
component = newGetComponent(name);
} catch (e) {
component = null;
} finally {
return component;
console.log("Component not found");
}

return component;
}

export function getAllComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test("OrderSummary snapshot test", () => {
status: "new"
},
billing: [
{ paymentMethod: {},
{
paymentMethod: {},
invoice: {}
}
]
Expand Down
14 changes: 7 additions & 7 deletions imports/plugins/core/orders/client/components/orderTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ class OrderTable extends Component {
}

render() {
let getTrProps = undefined;
let getTheadProps = undefined;
let getTrGroupProps = undefined;
let getTableProps = undefined;
let getTrProps;
let getTheadProps;
let getTrGroupProps;
let getTableProps;

const customColumnMetadata = [];

Expand Down Expand Up @@ -260,7 +260,7 @@ class OrderTable extends Component {

// https://react-table.js.org/#/story/cell-renderers-custom-components
columnNames.forEach((columnName) => {
let colHeader = undefined;
let colHeader;
let resizable = true;
let sortable = true;
let columnNameLabel;
Expand Down Expand Up @@ -295,7 +295,7 @@ class OrderTable extends Component {
const columnMeta = {
accessor: filteredFields[columnName].accessor,
id: filteredFields[columnName].id,
Header: colHeader ? colHeader : columnNameLabel,
Header: colHeader || columnNameLabel,
headerClassName: classNames.headerClassNames[columnName],
className: classNames.colClassNames[columnName],
resizable,
Expand Down Expand Up @@ -373,7 +373,7 @@ class OrderTable extends Component {
className: "order-table-pagination-visible"
})}
getTableProps={getTableProps}
showPaginationTop={this.props.selectedItems.length ? false : true}
showPaginationTop={!this.props.selectedItems.length}
/>
</div>
);
Expand Down
Loading

0 comments on commit 71e4253

Please sign in to comment.