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

upgrade eslint configuration to 8.x #4178

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/moog.js
Expand Up @@ -432,7 +432,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
Expand Up @@ -151,8 +151,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 @@ -233,7 +233,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 @@ -262,7 +262,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 @@ -275,7 +275,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 @@ -324,7 +324,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
Expand Up @@ -163,7 +163,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 @@ -379,7 +379,7 @@ module.exports = {
}
_.set(doc, dotPath, {
metaType: 'area',
items: items
items
});
return self.apos.doc.update(req, doc);
}
Expand Down Expand Up @@ -691,7 +691,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
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
Expand Up @@ -297,7 +297,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 @@ -408,7 +408,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: [],
archivedDocIds: []
Expand Down Expand Up @@ -503,7 +503,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 @@ -846,8 +846,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 @@ -1077,7 +1077,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
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
2 changes: 1 addition & 1 deletion modules/@apostrophecms/doc-type/index.js
Expand Up @@ -2055,7 +2055,7 @@ module.exports = {
finalize() {
const type = query.get('type');
if (type) {
query.and({ type: type });
query.and({ type });
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion modules/@apostrophecms/doc/index.js
Expand Up @@ -67,7 +67,7 @@ module.exports = {
}
const slug = self.apos.launder.string(req.body.slug);
const _id = self.apos.launder.id(req.body._id);
const criteria = { slug: slug };
const criteria = { slug };
if (_id) {
criteria._id = { $ne: _id };
}
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/email/index.js
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
Expand Up @@ -496,7 +496,7 @@ module.exports = {
const criteria = {
$or: [
{
'attachment.extension': { $nin: $nin }
'attachment.extension': { $nin }
},
{
'attachment.width': { $gte: minSize[0] },
Expand Down
Expand Up @@ -423,7 +423,7 @@ export default {
};
</script>

<style scoped lang="scss" >
<style scoped lang="scss">
.apos-schema {
margin: 30px 15px 0;

Expand Down
6 changes: 3 additions & 3 deletions modules/@apostrophecms/job/index.js
Expand Up @@ -311,7 +311,7 @@ module.exports = {
};
const context = {
_id: job._id,
options: options
options
};

await self.db.insertOne(job);
Expand Down Expand Up @@ -371,7 +371,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 @@ -395,7 +395,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
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
8 changes: 4 additions & 4 deletions modules/@apostrophecms/login/index.js
Expand Up @@ -299,9 +299,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 @@ -484,7 +484,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 Down Expand Up @@ -562,7 +562,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
Expand Up @@ -71,8 +71,8 @@ module.exports = {
options = {};
}
self.migrations.push({
name: name,
options: options,
name,
options,
fn: migrationFn
});
},
Expand Down Expand Up @@ -147,8 +147,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 @@ -220,7 +220,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
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
Expand Up @@ -158,9 +158,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
Expand Up @@ -257,11 +257,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 @@ -458,7 +458,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
Expand Up @@ -1373,7 +1373,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 @@ -1998,7 +1998,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
Expand Up @@ -447,7 +447,7 @@ export default {
body: {
...requestOptions,
_ids: this.checked,
messages: messages,
messages,
type: this.checked.length === 1 ? this.moduleLabels.singular
: this.moduleLabels.plural
}
Expand Down
4 changes: 2 additions & 2 deletions modules/@apostrophecms/polymorphic-type/index.js
Expand Up @@ -26,8 +26,8 @@ module.exports = {
});
return self.send(req, 'chooserModal', {
options: self.options,
limit: limit,
types: types
limit,
types
});
}
}
Expand Down