Skip to content

Commit

Permalink
Merge pull request #5298 from reactioncommerce/chore-kieckhafer-eslin…
Browse files Browse the repository at this point in the history
…tAudit-idLength

chore: fix all `id-length` eslint warnings
  • Loading branch information
kieckhafer authored Jul 10, 2019
2 parents b6c20a4 + 711718f commit 5012845
Show file tree
Hide file tree
Showing 47 changed files with 141 additions and 127 deletions.
4 changes: 2 additions & 2 deletions client/modules/core/domains.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ describe("DomainsMixin", () => {
});

test("wraps composeUrl with options only", () => {
const options = { a: 1, b: 2 };
const options = { optionA: 1, optionB: 2 };

DomainsMixin.absoluteUrl(options);

expect(composeUrl).toHaveBeenCalledWith(undefined, { ...options, rootUrl });
});

test("wraps composeUrl both a path and options", () => {
const options = { a: 1, b: 2 };
const options = { optionA: 1, optionB: 2 };

DomainsMixin.absoluteUrl(path, options);

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 @@ -145,7 +145,7 @@ export function Apps(optionHash) {
});

// Sort apps by priority (registry.priority)
return reactionApps.sort((a, b) => a.priority - b.priority).slice();
return reactionApps.sort((appA, appB) => appA.priority - appB.priority).slice();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions client/modules/i18n/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export function getLabelsFor(schema, name) {
Object.keys(schema.mergedSchema()).forEach((fieldName) => {
const i18nKey = `${titleCaseName}.${fieldName.split(".$").join("")}`;
// translate autoform label
const t = i18next.t(i18nKey);
if (t && new RegExp("string").test(t) !== true && t !== i18nKey) {
labels[fieldName] = t;
const translation = i18next.t(i18nKey);
if (translation && new RegExp("string").test(translation) !== true && translation !== i18nKey) {
labels[fieldName] = translation;
}
});
return labels;
Expand Down Expand Up @@ -84,7 +84,7 @@ export const localeDep = new Tracker.Dependency();
export const currencyDep = new Tracker.Dependency();

Meteor.startup(() => {
Tracker.autorun((c) => {
Tracker.autorun((trackerInstance) => {
let merchantShopsReadyOrSkipped = false;

// Choose shopSubscription based on marketplace settings
Expand All @@ -111,7 +111,7 @@ Meteor.startup(() => {
localeDep.changed();

// Stop the tracker
c.stop();
trackerInstance.stop();
});
}
});
Expand Down
6 changes: 3 additions & 3 deletions imports/plugins/core/accounts/client/components/editGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class EditGroup extends Component {
});
};

showForm = ((grp) = {}) => (e) => {
e.preventDefault();
e.stopPropagation();
showForm = ((grp) = {}) => (event) => {
event.preventDefault();
event.stopPropagation();
this.setState({ isEditing: true, selectedGroup: grp });
};

Expand Down
8 changes: 6 additions & 2 deletions imports/plugins/core/accounts/client/components/signIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ class SignIn extends Component {
</span>
);
}

return null;
}

renderPasswordErrors() {
return (
<span className="help-block">
{this.props.onError(this.props.messages.errors && this.props.messages.errors.password) &&
this.props.messages.errors.password.map((error, i) => (
this.props.messages.errors.password.map((error, index) => (
<Components.Translation
key={i}
key={index}
defaultValue={error.reason}
i18nKey={error.i18nKeyReason}
/>
Expand All @@ -97,6 +99,8 @@ class SignIn extends Component {
</div>
);
}

return null;
}

renderSpinnerOnWait() {
Expand Down
10 changes: 8 additions & 2 deletions imports/plugins/core/accounts/client/components/signUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ class SignUp extends Component {
</span>
);
}

return null;
}

renderPasswordErrors() {
return (
<span className="help-block">
{this.props.onError(this.props.messages.errors && this.props.messages.errors.password) &&
this.props.messages.errors.password.map((error, i) => (
this.props.messages.errors.password.map((error, index) => (
<Components.Translation
key={i}
key={index}
defaultValue={error.reason}
i18nKey={error.i18nKeyReason}
/>
Expand All @@ -82,6 +84,8 @@ class SignUp extends Component {
</div>
);
}

return null;
}

renderSpinnerOnWait() {
Expand Down Expand Up @@ -160,6 +164,8 @@ class SignUp extends Component {
</form>
);
}

return null;
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ class UpdatePassword extends Component {
</div>
);
}

return null;
}

renderPasswordErrors() {
return (
<span className="help-block">
{this.props.onError(this.props.messages.errors && this.props.messages.errors.password) &&
this.props.messages.errors.password.map((error, i) => (
this.props.messages.errors.password.map((error, index) => (
<Components.Translation
key={i}
key={index}
defaultValue={error.reason}
i18nKey={error.i18nKeyReason}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function groupPermissions(packages) {
}
}
// 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, (string) => ` ${string[1].toUpperCase()}`);

const newObj = {
shopId: pkg.shopId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Template.memberSettings.helpers({
}
}
// 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, (string) => ` ${string[1].toUpperCase()}`);

return permissionGroups.push({
shopId: pkg.shopId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Reaction.onAppStartupComplete(() => {

Meteor.call("products/cloneVariant", product._id, variant[0]._id);
const variants = Products.find({ ancestors: [product._id] }).fetch();
const clonedVariant = variants.filter((v) => v._id !== variant[0]._id);
const clonedVariant = variants.filter((filteredVariant) => filteredVariant._id !== variant[0]._id);
expect(variant[0]._id).to.not.equal(clonedVariant[0]._id);
expect(_.isEqual(variant[0].ancestors, clonedVariant[0].ancestors)).to.be.true;
// expect(variant[0].ancestors).to.equal(clonedVariant[0].ancestors);
Expand Down Expand Up @@ -226,8 +226,8 @@ Reaction.onAppStartupComplete(() => {
ancestors: { $in: [clone._id] }
}).fetch();
expect(cloneVariants.length).to.equal(3);
for (let i = 0; i < variants.length; i += 1) {
expect(cloneVariants.some((clonedVariant) => clonedVariant.title === variants[i].title)).to.be.ok;
for (let inc = 0; inc < variants.length; inc += 1) {
expect(cloneVariants.some((clonedVariant) => clonedVariant.title === variants[inc].title)).to.be.ok;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function getCatalogProductMedia(productId, collections) {
}
};
})
.sort((a, b) => a.priority - b.priority);
.sort((mediaA, mediaB) => mediaA.priority - mediaB.priority);

return catalogProductMedia;
}
12 changes: 6 additions & 6 deletions imports/plugins/core/core/server/Reaction/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ Importer.commit = function (collection) {
const message = `Error while importing to ${name}`;
const writeErrors = result.getWriteErrors();

for (let i = 0; i < writeErrors.length; i += 1) {
Logger.warn(`${message}: ${writeErrors[i].errmsg}`);
for (let inc = 0; inc < writeErrors.length; inc += 1) {
Logger.warn(`${message}: ${writeErrors[inc].errmsg}`);
}
const writeConcernError = result.getWriteConcernError();
if (writeConcernError) {
Expand Down Expand Up @@ -460,12 +460,12 @@ Importer.process = function (json, keys, callback, cbArgs) {

const array = EJSON.parse(json);

for (let i = 0; i < array.length; i += 1) {
for (let inc = 0; inc < array.length; inc += 1) {
const key = {};
for (let j = 0; j < keys.length; j += 1) {
key[keys[j]] = array[i][keys[j]];
for (let subInc = 0; subInc < keys.length; subInc += 1) {
key[keys[subInc]] = array[inc][keys[subInc]];
}
callback.call(this, key, array[i], ...cbArgs);
callback.call(this, key, array[inc], ...cbArgs);
}
};

Expand Down
4 changes: 2 additions & 2 deletions imports/plugins/core/core/server/fixtures/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export function getProduct() {
export function getProducts(limit = 2) {
const products = [];
const existingProducts = Products.find({}, { limit }).fetch();
for (let i = 0; i < limit; i += 1) {
const product = existingProducts[i] || Factory.create("product");
for (let inc = 0; inc < limit; inc += 1) {
const product = existingProducts[inc] || Factory.create("product");
products.push(product);
}
return products;
Expand Down
4 changes: 2 additions & 2 deletions imports/plugins/core/core/server/fixtures/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function getUser() {
export function getUsers(limit = 2) {
const users = [];
const existingUsers = Meteor.users.find({}, { limit }).fetch();
for (let i = 0; i < limit; i += 1) {
const user = existingUsers[i] || Factory.create("user");
for (let inc = 0; inc < limit; inc += 1) {
const user = existingUsers[inc] || Factory.create("user");
users.push(user);
}
return users;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async function tag(_, connectionArgs, context) {

try {
dbTagId = decodeTagOpaqueId(slugOrId);
} catch (e) {
} catch (error) {
dbTagId = slugOrId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getFakeMongoCursor from "/imports/test-utils/helpers/getFakeMongoCursor";
import Factory from "/imports/test-utils/helpers/factory";

const base64ID = "cmVhY3Rpb24vc2hvcDoxMjM="; // reaction/shop:123
const mockTags = Factory.Tag.makeMany(3, { _id: (i) => (i + 100).toString() });
const mockTags = Factory.Tag.makeMany(3, { _id: (newId) => (newId + 100).toString() });
const mockTagsQuery = getFakeMongoCursor("Tags", mockTags);

test("calls queries.tags and returns a partial connection", async () => {
Expand Down
10 changes: 5 additions & 5 deletions imports/plugins/core/core/server/startup/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ export function importAllTranslations() {
// Then loop through those I18N assets and import them
if (shopId) {
// If there isn't a shop yet, and for future shops, this will be done in the "afterShopCreate" listener
Assets.find({ type: "i18n" }).forEach((t) => {
Logger.debug(`Importing ${t.name} translation for "${t.ns}"`);
if (t.content) {
Reaction.Importer.process(t.content, ["i18n"], Reaction.Importer.translation, [shopId]);
Assets.find({ type: "i18n" }).forEach((translation) => {
Logger.debug(`Importing ${translation.name} translation for "${translation.ns}"`);
if (translation.content) {
Reaction.Importer.process(translation.content, ["i18n"], Reaction.Importer.translation, [shopId]);
} else {
Logger.debug(`No translation content found for ${t.name} - ${t.ns} asset`);
Logger.debug(`No translation content found for ${translation.name} - ${translation.ns} asset`);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions imports/plugins/core/core/server/util/geocoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ function GeoCoder(options) {
}

function gc(address, options, callback) {
const g = require("node-geocoder")(
const geocoder = require("node-geocoder")(
options.geocoderProvider, options.httpAdapter,
options.extra
);
g.geocode(address, callback);
geocoder.geocode(address, callback);
}

GeoCoder.prototype.geocode = function geoCoderGeocode(address, callback) {
Expand All @@ -67,11 +67,11 @@ GeoCoder.prototype.geocode = function geoCoderGeocode(address, callback) {
};

function rv(lat, lng, options, callback) {
const g = require("node-geocoder")(
const geocoder = require("node-geocoder")(
options.geocoderProvider, options.httpAdapter,
options.extra
);
g.reverse({
geocoder.reverse({
lat,
lon: lng
}, callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PackageList extends Component {

try {
actionComponent = getComponent(`${packageData.template}_ActionDashboard`);
} catch (e) {
} catch (error) {
actionComponent = null;
} finally {
// If one exists, add it to the list of elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function composer(props, onData) {
const settings = Reaction.Apps({ provides: "settings", enabled: true, audience }) || [];

const dashboard = Reaction.Apps({ provides: "dashboard", enabled: true, audience })
.filter((d) => typeof Template[d.template] !== "undefined") || [];
.filter((dash) => typeof Template[dash.template] !== "undefined") || [];

onData(null, {
currentView: Reaction.getActionView(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function uploadHandler(event) {
const userId = Reaction.getUserId();
const { files } = event.target.files;

for (let i = 0; i < files.length; i += 1) {
const parts = files[i].name.split(".");
for (let inc = 0; inc < files.length; inc += 1) {
const parts = files[inc].name.split(".");
let product;
if (parts[0]) {
product = Products.findOne({
Expand All @@ -24,7 +24,7 @@ function uploadHandler(event) {
});
}
if (product) {
const fileRecord = FileRecord.fromFile(files[i]);
const fileRecord = FileRecord.fromFile(files[inc]);
fileRecord.metadata = {
ownerId: userId,
productId: product._id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { renameKeys } from "./ramda-ext";

test("renameKeys renames keys in a map", () => {
const input = { a: 1, b: 2 };
expect(renameKeys({ a: "d" }, input)).toEqual({ d: 1, b: 2 });
const input = { varA: 1, varB: 2 };
expect(renameKeys({ varA: "varD" }, input)).toEqual({ varD: 1, varB: 2 });
});

test("renameKeys passes over missing keys", () => {
const input = { a: 1, b: 2 };
expect(renameKeys({ f: "d" }, input)).toEqual({ a: 1, b: 2 });
const input = { varA: 1, varB: 2 };
expect(renameKeys({ varF: "varD" }, input)).toEqual({ varA: 1, varB: 2 });
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const wrapComponent = (Comp) => (
static propTypes = LocalizationSettings.propTypes

handleUpdateLanguageConfiguration = (event, isChecked, name) => {
const language = this.props.languages.find((l) => l.value === name);
const language = this.props.languages.find((lang) => lang.value === name);

if (language) {
Meteor.call("shop/updateLanguageConfiguration", language.value, isChecked);
Expand Down
Loading

0 comments on commit 5012845

Please sign in to comment.