Skip to content

Commit

Permalink
Eslint autofix object shorthand (#4800)
Browse files Browse the repository at this point in the history
  • Loading branch information
myovchev authored Nov 19, 2024
1 parent 9e98ba9 commit 019d039
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion lib/moog.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ module.exports = function(options) {
if (!object.__meta.chain) {
return false;
}
return !!_.find(object.__meta.chain, { name: name });
return !!_.find(object.__meta.chain, { name });
};

// Given a moog class name like `my-foo` or `@namespace/my-foo`,
Expand Down
12 changes: 6 additions & 6 deletions modules/@apostrophecms/admin-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ module.exports = {
const item = {
name: name.indexOf(':') === -1 ? name : name.split(':')[0],
action: name,
label: label,
permission: permission,
label,
permission,
options: options || {}
};
if (options && options.after) {
Expand Down Expand Up @@ -294,7 +294,7 @@ module.exports = {
self.items = self.items.concat(moving);
// ... But then explicit order kicks in
_.each(self.options.order || [], function (name) {
const item = _.find(self.items, { name: name });
const item = _.find(self.items, { name });
if (item) {
self.items = [ item ].concat(_.filter(self.items, function (item) {
return item.name !== name;
Expand Down Expand Up @@ -323,7 +323,7 @@ module.exports = {
self.groupLabels[group.items[0]] = group.label;

group.items.forEach(function (name, groupIndex) {
const item = _.find(self.items, { name: name });
const item = _.find(self.items, { name });
if (item) {
item.menuLeader = group.items[0];
} else {
Expand All @@ -336,7 +336,7 @@ module.exports = {
if (indexLeader === -1) {
throw new Error('Admin bar grouping error: no match for ' + item.menuLeader + ' in menu item ' + item.name);
}
let indexMe = _.findIndex(self.items, { name: name });
let indexMe = _.findIndex(self.items, { name });
if (indexMe !== indexLeader + groupIndex) {
// Swap ourselves into the right position following our leader
if (indexLeader + groupIndex < indexMe) {
Expand Down Expand Up @@ -391,7 +391,7 @@ module.exports = {
}
}
return {
items: items,
items,
components: { the: 'TheAposAdminBar' },
context: context && {
_id: context._id,
Expand Down
6 changes: 3 additions & 3 deletions modules/@apostrophecms/area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module.exports = {
const manager = self.widgetManagers[name];
if (manager) {
choices.push({
name: name,
name,
icon: manager.options.icon,
label: options.addLabel || manager.label || `No label for ${name}`
});
Expand Down Expand Up @@ -434,7 +434,7 @@ module.exports = {
}
_.set(doc, dotPath, {
metaType: 'area',
items: items
items
});
return self.apos.doc.update(req, doc);
}
Expand Down Expand Up @@ -746,7 +746,7 @@ module.exports = {
} else {
area = doc[name];
}
return self.isEmpty({ area: area });
return self.isEmpty({ area });
}
};
},
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/asset/lib/refresh-on-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
} else {
apos.http.post(document.querySelector('[data-apos-refresh-on-restart]').getAttribute('data-apos-refresh-on-restart'), {
qs: {
fast: fast
fast
}
}, function(err, result) {
if (err) {
Expand Down
12 changes: 6 additions & 6 deletions modules/@apostrophecms/attachment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ module.exports = {
texts.push({
weight: field.weight || 15,
text: (value && value.title) || '',
silent: silent
silent
});
},
// When the field is registered in the schema,
Expand Down Expand Up @@ -414,7 +414,7 @@ module.exports = {
createdAt: new Date(),
name: self.apos.util.slugify(path.basename(file.name, path.extname(file.name))),
title: self.apos.util.sortify(path.basename(file.name, path.extname(file.name))),
extension: extension,
extension,
type: 'attachment',
docIds: options.docIds ?? [],
archivedDocIds: options.archivedDocIds ?? []
Expand Down Expand Up @@ -565,7 +565,7 @@ module.exports = {

await Promise.promisify(self.uploadfs.copyOut)(originalFile, tempFile);
await Promise.promisify(self.uploadfs.copyImageIn)(tempFile, croppedFile, {
crop: crop,
crop,
sizes: self.imageSizes
});

Expand Down Expand Up @@ -909,8 +909,8 @@ module.exports = {
const x = attachment._focalPoint ? attachment._focalPoint.x : attachment.x;
const y = attachment._focalPoint ? attachment._focalPoint.y : attachment.y;
return {
x: x,
y: y
x,
y
};
},
// Returns true if this type of attachment is croppable.
Expand Down Expand Up @@ -1140,7 +1140,7 @@ module.exports = {
continue;
}
const path = self.url(attachment, {
crop: crop,
crop,
uploadfsPath: true,
size: size.name
});
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/attachment/lib/tasks/rescale.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = function(self) {
console.log('Cropping ' + tempFile + ' to ' + originalFile);
try {
await Promise.promisify(self.uploadfs.copyImageIn)(tempFile, originalFile, {
crop: crop,
crop,
sizes: self.imageSizes
});
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ module.exports = {
}
});
const args = _.assign({
html: html,
text: text,
html,
text,
from: (module.options.email && module.options.email.from) || self.options.from
}, options);
if (process.env.APOS_LOG_EMAIL) {
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ module.exports = {
const criteria = {
$or: [
{
'attachment.extension': { $nin: $nin }
'attachment.extension': { $nin }
},
{
'attachment.width': { $gte: minSize[0] },
Expand Down
6 changes: 3 additions & 3 deletions modules/@apostrophecms/job/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ module.exports = {
};
const context = {
_id: job._id,
options: options
options
};

await self.db.insertOne(job);
Expand Down Expand Up @@ -380,7 +380,7 @@ module.exports = {
// No promise is returned as this method just updates
// the job tracking information in the background.
setTotal(job, total) {
self.db.updateOne({ _id: job._id }, { $set: { total: total } }, function (err) {
self.db.updateOne({ _id: job._id }, { $set: { total } }, function (err) {
if (err) {
self.apos.util.error(err);
}
Expand All @@ -404,7 +404,7 @@ module.exports = {
$set: {
ended: true,
status: success ? 'completed' : 'failed',
results: results
results
}
});
},
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/lock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ module.exports = {
async function insert() {
await self.db.insertOne({
_id: name,
when: when,
idleTimeout: idleTimeout,
when,
idleTimeout,
unique: self.apos.util.generateId()
});
}
Expand Down
10 changes: 5 additions & 5 deletions modules/@apostrophecms/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ module.exports = {
parsed.searchParams.append('email', user.email);
try {
await self.email(req, 'passwordResetEmail', {
user: user,
user,
url: parsed.toString(),
site: site
site
}, {
to: user.email,
subject: req.t('apostrophe:passwordResetRequest', { site })
Expand Down Expand Up @@ -491,7 +491,7 @@ module.exports = {
const req = self.apos.task.getReq();
const user = await self.apos.user.find(req, {
$or: [
{ username: username },
{ username },
{ email: username }
],
disabled: { $ne: true }
Expand All @@ -512,7 +512,7 @@ module.exports = {
self.logInfo('correct-password', {
username,
ip,
attempts: attempts,
attempts,
requestId
});
return user;
Expand Down Expand Up @@ -588,7 +588,7 @@ module.exports = {
const adminReq = self.apos.task.getReq();
const criteriaOr = [
{ username: email },
{ email: email }
{ email }
];
const criteriaAnd = {};
if (resetToken !== false) {
Expand Down
10 changes: 5 additions & 5 deletions modules/@apostrophecms/migration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ module.exports = {
options = {};
}
self.migrations.push({
name: name,
options: options,
name,
options,
fn: migrationFn
});
},
Expand Down Expand Up @@ -150,8 +150,8 @@ module.exports = {
const areaInfos = [];
self.apos.area.walk(doc, function (area, dotPath) {
areaInfos.push({
area: area,
dotPath: dotPath
area,
dotPath
});
});
for (const areaInfo of areaInfos) {
Expand Down Expand Up @@ -223,7 +223,7 @@ module.exports = {
await self.eachDoc({ $and: clauses }, 5, async function (doc) {
const $set = {};
$set[field + 'Sortified'] = self.apos.util.sortify(doc[field]);
await self.apos.doc.db.updateOne({ _id: doc._id }, { $set: $set });
await self.apos.doc.db.updateOne({ _id: doc._id }, { $set });
});
});
},
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/module/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module.exports = function(self) {
}
eh[eventName].push({
moduleName: self.__meta.name,
handlerName: handlerName
handlerName
});
self.compiledHandlers = self.compiledHandlers || {};
self.compiledHandlers[moduleName] = self.compiledHandlers[moduleName] || {};
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/oembed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ module.exports = {
}
html = html.replace('STYLE', style);
return {
title: title,
title,
type: 'rich',
html: html
html
};
},
// Returns browser-side javascript to load a given
Expand Down
8 changes: 4 additions & 4 deletions modules/@apostrophecms/page-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,11 @@ module.exports = {
const keys = [];
const regexp = pathToRegexp(pattern, keys);
self.rules[pattern] = {
pattern: pattern,
pattern,
middleware: Array.prototype.slice.call(arguments, 1, arguments.length - 1),
handler: arguments[arguments.length - 1],
regexp: regexp,
keys: keys
regexp,
keys
};
},
// Match a URL according to the provided rule as registered
Expand Down Expand Up @@ -533,7 +533,7 @@ module.exports = {
}
return schema;
function getLabel(name) {
const choice = _.find(self.apos.page.typeChoices, { name: name });
const choice = _.find(self.apos.page.typeChoices, { name });
let label = choice && choice.label;
if (!label) {
const manager = self.apos.doc.getManager(name);
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ database.`);
}
async function findPage() {
// Also checks permissions
return self.find(req, { _id: _id }).permission('edit').ancestors({
return self.find(req, { _id }).permission('edit').ancestors({
depth: 1,
archived: null,
areas: false
Expand Down Expand Up @@ -2455,7 +2455,7 @@ database.`);
throw new Error('Wrong number of arguments');
}
const slug = argv._[1];
const count = await self.apos.doc.db.updateOne({ slug: slug }, { $unset: { parked: 1 } });
const count = await self.apos.doc.db.updateOne({ slug }, { $unset: { parked: 1 } });
if (!count) {
throw 'No page with that slug was found.';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export default {
body: {
...requestOptions,
_ids: this.checked,
messages: messages,
messages,
type: this.checked.length === 1 ? this.moduleLabels.singular
: this.moduleLabels.plural
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export default {
body: {
...requestOptions,
_ids: this.checked,
messages: messages,
messages,
type: this.checked.length === 1 ? this.moduleLabels.singular
: this.moduleLabels.plural
}
Expand Down
6 changes: 3 additions & 3 deletions modules/@apostrophecms/schema/lib/addFieldTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = (self) => {
texts.push({
weight: field.weight || 15,
text: value,
silent: silent
silent
});
},
isEmpty(field, value) {
Expand Down Expand Up @@ -296,7 +296,7 @@ module.exports = (self) => {
texts.push({
weight: field.weight || 15,
text: (value || []).join(' '),
silent: silent
silent
});
},
addQueryBuilder(field, query) {
Expand Down Expand Up @@ -350,7 +350,7 @@ module.exports = (self) => {
texts.push({
weight: field.weight || 15,
text: value,
silent: silent
silent
});
},
addQueryBuilder(field, query) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default {
.map(({ name, namespace }) => {
return {
name,
namespace: namespace,
namespace,
data: meta[namespace] || {}
};
});
Expand Down
Loading

0 comments on commit 019d039

Please sign in to comment.