diff --git a/client/helpers/confirmationDialog.js b/client/helpers/confirmationDialog.js index c94f69eaf..32bb4a03d 100644 --- a/client/helpers/confirmationDialog.js +++ b/client/helpers/confirmationDialog.js @@ -1,4 +1,4 @@ -import { _ } from "lodash"; +import { assignIn } from "lodash"; import { Blaze } from "meteor/blaze"; import { Template } from "meteor/templating"; import { i18n } from "meteor/universe:i18n"; @@ -7,7 +7,7 @@ const DIALOG_TEMPLATE = Template.confirmationDialog; export class ConfirmationDialog { constructor(options, callbacks = {}) { - this.options = _.assignIn( + this.options = assignIn( { title: i18n.__("Dialog.ConfirmDelete.title"), content: i18n.__("Dialog.ConfirmDelete.body"), @@ -19,7 +19,7 @@ export class ConfirmationDialog { }, options, ); // overwrite above defaults with given options - this.callback = _.assignIn( + this.callback = assignIn( { onSuccess() {}, }, diff --git a/client/templates/topic/topicEdit.js b/client/templates/topic/topicEdit.js index 1a1931a21..a0712638b 100644 --- a/client/templates/topic/topicEdit.js +++ b/client/templates/topic/topicEdit.js @@ -4,7 +4,7 @@ import { configureSelect2Responsibles } from "/imports/client/ResponsibleSearch" import { MeetingSeries } from "/imports/meetingseries"; import { Minutes } from "/imports/minutes"; import { Topic } from "/imports/topic"; -import { _ } from "lodash"; +import { assignIn } from "lodash"; import { $ } from "meteor/jquery"; import { Meteor } from "meteor/meteor"; import { Session } from "meteor/session"; @@ -66,7 +66,7 @@ Template.topicEdit.events({ const editTopic = getEditTopic(); const topicDoc = {}; if (editTopic) { - _.extend(topicDoc, editTopic._topicDoc); + assignIn(topicDoc, editTopic._topicDoc); } let labels = tmpl.$("#id_item_selLabels").val(); diff --git a/client/templates/topic/topicInfoItemEdit.js b/client/templates/topic/topicInfoItemEdit.js index d30c614d4..1942d70ec 100644 --- a/client/templates/topic/topicInfoItemEdit.js +++ b/client/templates/topic/topicInfoItemEdit.js @@ -7,7 +7,7 @@ import { Minutes } from "/imports/minutes"; import { Priority } from "/imports/priority"; import { Topic } from "/imports/topic"; import { User, userSettings } from "/imports/user"; -import { _ } from "lodash"; +import { assignIn } from "lodash"; import { Meteor } from "meteor/meteor"; import { ReactiveDict } from "meteor/reactive-dict"; import { ReactiveVar } from "meteor/reactive-var"; @@ -214,7 +214,7 @@ Template.topicInfoItemEdit.events({ const doc = {}; if (editItem) { - _.assignIn(doc, editItem._infoItemDoc); + assignIn(doc, editItem._infoItemDoc); } doc.subject = newSubject; diff --git a/imports/attachment.js b/imports/attachment.js index daa161283..938bc8045 100644 --- a/imports/attachment.js +++ b/imports/attachment.js @@ -1,4 +1,4 @@ -import { _ } from "lodash"; +import { assignIn } from "lodash"; import { AttachmentsCollection } from "./collections/attachments_private"; import { Minutes } from "./minutes"; @@ -42,7 +42,7 @@ export class Attachment { static uploadFile(uploadFilename, minutesObj, callbacks = {}) { const doNothing = () => {}; - callbacks = _.assignIn( + callbacks = assignIn( { onStart: doNothing, onEnd: doNothing, diff --git a/imports/ldap/import.js b/imports/ldap/import.js index 3ef6d8e53..5a9d2b34a 100644 --- a/imports/ldap/import.js +++ b/imports/ldap/import.js @@ -1,9 +1,9 @@ -let getLDAPUsers = require("./getLDAPUsers"), - saveUsers = require("./saveUsers"); +import getLDAPUsers from "./getLDAPUsers"; +import saveUsers from "./saveUsers"; const report = (bulkResult) => { - let inserted = bulkResult.nUpserted, - updated = bulkResult.nModified; + const inserted = bulkResult.nUpserted; + const updated = bulkResult.nModified; console.log( `Successfully inserted ${inserted} users and updated ${updated} users.`, @@ -55,4 +55,4 @@ const importUsers = (ldapSettings, mongoUrl) => .then(resetSelfSigned) .catch(handleRejection); -module.exports = importUsers; +export default importUsers; diff --git a/imports/ldap/saveUsers.js b/imports/ldap/saveUsers.js index 2dc894834..fe71a10a8 100644 --- a/imports/ldap/saveUsers.js +++ b/imports/ldap/saveUsers.js @@ -1,8 +1,9 @@ import { MongoClient as mongo } from "mongodb"; import { parse } from "mongo-uri"; import transformUser from "./transformUser"; + import { map, forEach } from "lodash"; -import { Random } from "../../tests/performance/fixtures/lib/random"; +import { generateId } from "../../tests/performance/fixtures/lib/random"; const _transformUsers = (settings, users) => map(users, (user) => transformUser(settings, user)); @@ -41,7 +42,7 @@ const _insertUsers = (client, mongoUri, users) => { .upsert() .updateOne({ $setOnInsert: { - _id: Random.generateId(), + _id: generateId(), // by setting this only on insert we won't log out everyone // everytime we sync the users services: { @@ -68,9 +69,9 @@ const _insertUsers = (client, mongoUri, users) => { }; const _closeMongo = (data) => { - let force = false, - client = data.client, - result = data.bulkResult; + const force = false; + const client = data.client; + const result = data.bulkResult; return new Promise((resolve) => { client.close(force); diff --git a/imports/ldap/transformUser.js b/imports/ldap/transformUser.js index f6599be4e..082039b7e 100644 --- a/imports/ldap/transformUser.js +++ b/imports/ldap/transformUser.js @@ -1,11 +1,19 @@ -import { pick, without } from "lodash"; +import { pick } from "lodash"; +/** + * Filters an array and returns a new array without the specified values. + * + * @param {Array} arr - The array to filter. + * @param {...*} args - The values to exclude from the filtered array. + * @returns {Array} - A new array with the values excluded. + */ +const without = (arr, ...args) => arr.filter(item => !args.includes(item)) export default (ldapSettings, userData) => { ldapSettings.propertyMap = ldapSettings.propertyMap || {}; const usernameAttribute = - ldapSettings.searchDn || ldapSettings.propertyMap.username || "cn", - longnameAttribute = ldapSettings.propertyMap.longname, - mailAttribute = ldapSettings.propertyMap.email || "mail"; + ldapSettings.searchDn || ldapSettings.propertyMap.username || "cn"; + const longnameAttribute = ldapSettings.propertyMap.longname; + const mailAttribute = ldapSettings.propertyMap.email || "mail"; // userData.mail may be a string with one mail address or an array. // Nevertheless we are only interested in the first mail address here - if diff --git a/programs/generateLicenseList.js b/programs/generateLicenseList.js index b2b3ee349..f4187d09d 100644 --- a/programs/generateLicenseList.js +++ b/programs/generateLicenseList.js @@ -1,7 +1,7 @@ -const crawler = require("npm-license-crawler"), - http = require("http"), - https = require("https"), - fs = require("fs"); +import { dumpLicenses } from "npm-license-crawler"; +import { get as _get } from "http"; +import { get as __get } from "https"; +import { createWriteStream } from "fs"; const meteorPackages = { meteor: { @@ -107,9 +107,9 @@ const meteorPackages = { function get(url, callback) { if (url.startsWith("https")) { - https.get(url, callback); + __get(url, callback); } else { - http.get(url, callback); + _get(url, callback); } } @@ -169,11 +169,11 @@ function streamCollector(streams, index, outStream) { outStream.write(`\n\n${licenseSeparator}\n\n`); streamCollector(streams, index + 1, outStream); }); - } else { - console.log(`NO LICENSE TEXT FOUND FOR ${project}`); - outStream.write(`\n\n${licenseSeparator}\n\n`); - streamCollector(streams, index + 1, outStream); + return; } + console.log(`NO LICENSE TEXT FOUND FOR ${project}`); + outStream.write(`\n\n${licenseSeparator}\n\n`); + streamCollector(streams, index + 1, outStream); }) .catch(console.error); } @@ -185,13 +185,13 @@ function getSortedKeys(obj) { return keys.sort((a, b) => obj[b] - obj[a]); } -crawler.dumpLicenses({ start: ["."] }, (error, res) => { +dumpLicenses({ start: ["."] }, (error, res) => { if (error) { console.error("Error:", error); return; } - const output = fs.createWriteStream("LicensesOfDependencies.txt"); + const output = createWriteStream("LicensesOfDependencies.txt"); const streams = Object.keys(res).map((project) => downloadToStream(project, res[project].licenseUrl, res[project].licenses), );