Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Run babel on all files
run: npm run babel
run: npm run babel-test
14 changes: 7 additions & 7 deletions ChemEquilibrium/AcidModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ let pkas = [
{ ha: 'HCl', a: 'Cl-', pka: 1, specie: { label: 'Cl-', number: 1, pka: 1 } },
];

define(['lodash'], function (_) {
define(['lodash'], (_) => {
class AcidBase {
constructor(customPkas) {
this.pkas = customPkas || pkas;
Expand All @@ -165,14 +165,14 @@ define(['lodash'], function (_) {

addAcidBase(label, total) {
let titrProtonCount;
let titrSpecie = pkas.find(function (pka) {
let titrSpecie = pkas.find(function equalsLabel(pka) {
return pka.ha === label;
});
if (titrSpecie) {
titrProtonCount = titrSpecie.specie.number;
titrSpecie = titrSpecie.specie.label;
} else {
titrSpecie = pkas.find(function (pka) {
titrSpecie = pkas.find(function equalsLabel(pka) {
return pka.a === label;
});
if (titrSpecie) {
Expand Down Expand Up @@ -222,13 +222,13 @@ define(['lodash'], function (_) {
getModel() {
// Get all involved pkas
let pkas = this.pkas.filter((pka) => {
return this.components.find(function (c) {
return this.components.find(function equalsLabel(c) {
return String(c.label) === String(pka.specie.label);
});
});

// group pkas by component
let grouped = _.groupBy(pkas, function (pka) {
let grouped = _.groupBy(pkas, function equalsLabel(pka) {
return String(pka.specie.label);
});

Expand All @@ -241,7 +241,7 @@ define(['lodash'], function (_) {

// Model components
model.components = new Array(nbComponents);
for (i = 0; i < this.components.length; i++) {
for (let i = 0; i < this.components.length; i++) {
model.components[i] = { ...this.components[i] };
}

Expand All @@ -256,7 +256,7 @@ define(['lodash'], function (_) {

model.formedSpecies[0].components[protonIndex] = -1;

for (var i = 0; i < this.components.length; i++) {
for (let i = 0; i < this.components.length; i++) {
if (i === protonIndex) continue;
let group = grouped[this.components[i].label];
if (!group) throw new Error('Should be unreachable');
Expand Down
5 changes: 2 additions & 3 deletions ChemEquilibrium/chart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['src/util/color'], function (Color) {
define(['src/util/color'], (Color) => {
return {
getChart(x, y, options) {
options = options || {};
Expand All @@ -20,10 +20,9 @@ define(['src/util/color'], function (Color) {
let species = Object.keys(y[0]);
let colors = Color.getDistinctColors(species.length);

for (var i = 0; i < species.length; i++) {
for (let i = 0; i < species.length; i++) {
let data = {};
chart.data.push(data);
// eslint-disable-next-line no-loop-func
data.y = y.map((y) => {
return y[species[i]];
});
Expand Down
2 changes: 1 addition & 1 deletion biology/needleman/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function run(v, w, options = {}) {
let matrixScore;
try {
matrixScore = S[v[i - 1]][w[j - 1]];
} catch (e) {
} catch {
// e.g. a letter is not found in the matrix
matrixScore = indel;
}
Expand Down
3 changes: 1 addition & 2 deletions chemistry/PubChem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ async function getMolecules(mf) {

let response = await fetch(`${pubchemURL}${searchParams.toString()}`);
let results = await response.json();
console.log(results.data);
return results.data;
}

Expand Down Expand Up @@ -66,7 +65,7 @@ module.exports = {
rowHeight: 140,
},
})
.catch(function (e) {
.catch((e) => {
console.error(e); // eslint-disable-line no-console
ui.showNotification('search failed', 'error');
});
Expand Down
14 changes: 7 additions & 7 deletions chemistry/chemcalcSequenceSVG.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define([
'https://www.lactame.com/github/adobe-webplatform/Snap.svg/84fbff7d512c8145c522b71fc9c872cb0bcae49a/dist/snap.svg-min.js',
'./sequenceSplitter',
], function (Snap, sequenceSplitter) {
], (snap, sequenceSplitter) => {
function getSVG(sequence, analysisResult, options) {
const {
width = 600,
Expand All @@ -24,7 +24,7 @@ define([

let line = 0;
// we create a temporary paper in order to get the width of the text blocs
let tempPaper = Snap(1000, 40);
let tempPaper = snap(1000, 40);
for (let i = 0; i < mfParts.length; i++) {
let part = mfParts[i];
let text = tempPaper.text(xPos, 20, part);
Expand Down Expand Up @@ -130,11 +130,11 @@ define([
rowHeight * (line + 1) + 50 + verticalShiftForTerminalAnnotations;

// We start to create the SVG and create the paper
let paper = Snap(width, height);
let paper = snap(width, height);

addScript(paper);

residues.forEach(function (residue) {
residues.forEach((residue) => {
residue.y = (residue.line + 1) * rowHeight;
let text = paper.text(residue.xFrom, residue.y, residue.label);
text.attr({ id: `residue-${residue.nTer}` });
Expand Down Expand Up @@ -163,7 +163,7 @@ define([
let used = {};
for (let i = from; i < to; i++) {
let residue = residues[i];
residue.usedSlots.forEach(function (usedSlot, index) {
residue.usedSlots.forEach((usedSlot, index) => {
used[index] = true;
});
}
Expand All @@ -182,7 +182,7 @@ define([

function drawTerminals() {
for (let result of results) {
var residue;
let residue;
let nTerminal = false;
if (result.fromNTerm) {
residue = residues[result.to];
Expand Down Expand Up @@ -267,7 +267,7 @@ define([
// var charge = result.charge > 0 ? '+' + result.charge : result.charge;
// var label = result.type + ' (' + charge + ', ' + Math.round(result.similarity) + '%)';
// we need to check on how many lines we are
var fromX, toX, y;
let fromX, toX, y;
for (let line = fromResidue.line; line <= toResidue.line; line++) {
y =
-10 -
Expand Down
10 changes: 5 additions & 5 deletions chemistry/orbitals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
'https://www.lactame.com/github/adobe-webplatform/Snap.svg/84fbff7d512c8145c522b71fc9c872cb0bcae49a/dist/snap.svg-min.js',
], function (Snap) {
], (snap) => {
let exports = {};

let defaultOptions = {
Expand Down Expand Up @@ -133,7 +133,7 @@ define([
}

svgModifier = [];
paper = Snap(width, height);
paper = snap(width, height);

paper
.path('M 0 0 L 10 4 L 0 8 z')
Expand Down Expand Up @@ -216,7 +216,7 @@ define([

function parseelConfig(elConfig) {
elConfig = elConfig.split(' ');
elConfig = elConfig.map(function (o) {
elConfig = elConfig.map((o) => {
let m = o.match(/^(\d\w)(\d+)/);
return {
layer: m[1],
Expand Down Expand Up @@ -282,11 +282,11 @@ define([
return Math.floor(electron / num) === 0 ? 1 : -1;
}

exports.getSvg = function (...args) {
exports.getSvg = function getSvg(...args) {
createSvg(args);
return svg;
};
exports.getSvgAndModifier = function (...args) {
exports.getSvgAndModifier = function getSvgAndModifier(...args) {
createSvg(args);
return { svg, svgModifier };
};
Expand Down
3 changes: 2 additions & 1 deletion chemistry/structuralAnalysisExercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
}
let datum = data[file.rn];
switch (file.kind) {
case 'mol':
case 'mol': {
datum.mol = { type: 'mol2d', url: file.url };
const molfile = await (await fetch(file.url)).text();

Check warning on line 48 in chemistry/structuralAnalysisExercises.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected `await` inside a loop

Check warning on line 48 in chemistry/structuralAnalysisExercises.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected `await` inside a loop
const molecule = Molecule.fromMolfile(molfile);
datum.oclCode = molecule.getIDCode();
datum.id = datum.rn;
Expand All @@ -61,6 +61,7 @@
datum.nbH = Number(datum.mf.replace(/.*H([0-9]+).*/, '$1'));
datum.nbC = Number(datum.mf.replace(/.*C([0-9]+).*/, '$1'));
break;
}
case 'mass':
datum.mass = { type: 'jcamp', url: file.url };
datum.isMass = true;
Expand Down
2 changes: 1 addition & 1 deletion defaultOptions/mass.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(function () {
define(() => {
return {
monoisotopicMass: 300.123,
resolution: 100000,
Expand Down
2 changes: 1 addition & 1 deletion edx/channel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
'https://cdnjs.cloudflare.com/ajax/libs/jschannel/1.0.0-git-commit1-8c4f7eb/jschannel.js',
], function () {
], () => {
let initialized = false;
function init(options) {
if (initialized) return;
Expand Down
2 changes: 0 additions & 2 deletions eln/.eslintrc.yml

This file was deleted.

5 changes: 3 additions & 2 deletions eln/BioReaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@
case 'save':
await this.roc.update(this.sample);
break;
case 'deleteAttachment':
var attachment = action.value.name;
case 'deleteAttachment': {
const attachment = action.value.name;
await this.roc.deleteAttachment(this.sample, attachment);
break;
}
case 'unattach':
await this.roc.unattach(this.sample, action.value);
break;
Expand Down Expand Up @@ -217,7 +218,7 @@
}
for (let i = 0; i < files.length; i++) {
const data = DataObject.resurrect(files[i]);
await this.roc.attach(type, this.sample, data);

Check warning on line 221 in eln/BioReaction.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected `await` inside a loop
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions eln/ExpandableMolecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ class ExpandableMolecule {
case 'toggleJSMEEdition':
this.toggleJSMEEdition(!this.jsmeEditionMode);
break;
case 'clearMolfile':
var molfile = API.getData('editableMolfile');
case 'clearMolfile': {
const molfile = API.getData('editableMolfile');
molfile.setValue('');
break;
}
case 'swapHydrogens':
this.setExpandedHydrogens();
break;
Expand Down
11 changes: 4 additions & 7 deletions eln/ExtSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
case '$content.general.mf':
try {
this.mf.fromMF();
} catch (e) {
} catch {
// ignore
}
break;
Expand All @@ -119,7 +119,7 @@
}

async _init() {
this._initialized = new Promise(async (resolve) => {
this._initialized = (async () => {
let sample;
if (this.options.trackId) {
try {
Expand All @@ -143,8 +143,7 @@
sample.$content.general.molfile = ''; // can not be edited otherwise
}
this._loadSample(sample);
resolve();
});
})();
}

bindChange() {
Expand All @@ -157,7 +156,7 @@
}

async handleDrop(name, askType, options = {}) {
let { converters = {}, autoJcamp, autoKind } = options;
let { converters = {}, autoKind } = options;
if (!name) {
throw new Error('handleDrop expects a variable name');
}
Expand Down Expand Up @@ -201,15 +200,13 @@
}

if (converters[kind]) {
autoJcamp = false;

let converted = await converters[kind](droppedData.content);

Check warning on line 203 in eln/ExtSample.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected `await` inside a loop
if (!Array.isArray(converted)) {
converted = [converted];
}

for (let i = 1; i < converted.length; i++) {
newData.push({

Check failure on line 209 in eln/ExtSample.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

'newData' is not defined
filename: droppedData.filename.replace(/\.[^.]*$/, `_${i}.jdx`),
mimetype: 'chemical/x-jcamp-dx',
contentType: 'chemical/x-jcamp-dx',
Expand Down
8 changes: 2 additions & 6 deletions eln/MF.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class MF {
let mfInfo = new MolecularFormula.MF(mf).getInfo();
this.setCanonizedMF(mfInfo.mf);
this.previousEMMF = mfInfo.monoisotopicMass;
} catch (e) {
} catch (err) {
this.setCanonizedMF('');
console.log('Could not parse MF: ', mf);
reportError(err);
}
}
}
Expand Down Expand Up @@ -97,10 +97,6 @@ class MF {
this.sample.setChildSync(['$content', 'general', 'mf'], mf);
}

setMF(mf) {
this.sample.setChildSync(['$content', 'general', 'mf'], mf);
}

setMW(mw) {
this.sample.setChildSync(['$content', 'general', 'mw'], mw);
}
Expand Down
10 changes: 6 additions & 4 deletions eln/Nmr1dManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@
this._autoRanges(currentNmr);
break;
}
case 'deleteAllRanges':
var ranges = API.getData('currentNmrRanges');
case 'deleteAllRanges': {
const ranges = API.getData('currentNmrRanges');
while (ranges.length) {
ranges.pop();
}
ranges.triggerChange();
break;
}
case 'clearAssignments': {
let ranges = this.getCurrentRanges();
if (ranges) {
Expand Down Expand Up @@ -298,8 +299,9 @@
_getNMR(currentNMRLine) {
let filename = String(currentNMRLine.getChildSync(['jcamp', 'filename']));
return currentNMRLine.getChild(['jcamp', 'data']).then((jcamp) => {
let spectrum;
if (filename && this.spectra[filename]) {
var spectrum = this.spectra[filename];
spectrum = this.spectra[filename];
} else if (jcamp) {
jcamp = String(jcamp.get());
spectrum = NMR.fromJcamp(jcamp);
Expand Down Expand Up @@ -381,7 +383,7 @@
if (mfInfo && mfInfo.atoms && mfInfo.atoms.H) {
return mfInfo.atoms.H || 100;
}
} catch (e) {
} catch {
return 100;
}
}
Expand All @@ -397,7 +399,7 @@
}
}

// todo : migrate this code to spectra-data-ranges

Check warning on line 402 in eln/Nmr1dManager.js

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected 'todo' comment: 'todo : migrate this code to...'
getRangesTotalIntegral() {
let ranges = API.getData('currentNmrRanges') || [];
let sum = 0;
Expand Down
Loading
Loading