diff --git a/.eslintrc.json b/.eslintrc.json index 3c1eb87b4b65b438d312e82bf2137c22cb704d8c..c8740de119e38e394988609bade687307a8c8269 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -53,7 +53,8 @@ "func-call-spacing": "off", "no-multi-spaces": "error", "block-spacing": "error", - "keyword-spacing": "off" + "keyword-spacing": "off", + "space-before-blocks": "error" }, "overrides": [ { diff --git a/src/extensions/cellpack/curve.ts b/src/extensions/cellpack/curve.ts index 5b5c4fe64072a391ff56de71a730ffa9816af612..83358584a5ce5c2c098d928a398dc328fbbcc409 100644 --- a/src/extensions/cellpack/curve.ts +++ b/src/extensions/cellpack/curve.ts @@ -195,7 +195,7 @@ export function getMatFromResamplePoints(points: NumberArray, segmentLength: num let new_points: Vec3[] = []; if (resample) new_points = ResampleControlPoints(points, segmentLength); else { - for (let idx = 0; idx < points.length / 3; ++idx){ + for (let idx = 0; idx < points.length / 3; ++idx) { new_points.push(Vec3.fromArray(Vec3.zero(), points, idx * 3)); } } diff --git a/src/extensions/cellpack/model.ts b/src/extensions/cellpack/model.ts index d57624cc3d335a52782ce43c580529cbd33dfa3f..f52b431332b18dbde1c30a53d6ce6bf7e728995c 100644 --- a/src/extensions/cellpack/model.ts +++ b/src/extensions/cellpack/model.ts @@ -68,7 +68,7 @@ async function getModel(plugin: PluginContext, id: string, ingredient: Ingredien throw new Error(`unsupported file type '${file.name}'`); } } else if (id.match(/^[1-9][a-zA-Z0-9]{3,3}$/i)) { - if (surface){ + if (surface) { try { const data = await getFromOPM(plugin, id, assetManager); assets.push(data.asset); @@ -108,7 +108,7 @@ async function getStructure(plugin: PluginContext, model: Model, source: Ingredi structure = await plugin.runTask(StructureSymmetry.buildAssembly(structure, assembly)); } let query; - if (source.selection){ + if (source.selection) { const asymIds: string[] = source.selection.replace(' ', '').replace(':', '').split('or'); query = MS.struct.modifier.union([ MS.struct.generator.atomGroups({ @@ -157,9 +157,9 @@ function getCurveTransforms(ingredient: Ingredient) { const n = ingredient.nbCurve || 0; const instances: Mat4[] = []; let segmentLength = 3.4; - if (ingredient.uLength){ + if (ingredient.uLength) { segmentLength = ingredient.uLength; - } else if (ingredient.radii){ + } else if (ingredient.radii) { segmentLength = ingredient.radii[0].radii ? ingredient.radii[0].radii[0] * 2.0 : 3.4; @@ -333,7 +333,7 @@ async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredi structure = await getCurve(plugin, name, ingredient, getCurveTransforms(ingredient), model); } else { let bu: string|undefined = source.bu ? source.bu : undefined; - if (bu){ + if (bu) { if (bu === 'AU') { bu = undefined; } else { @@ -343,22 +343,22 @@ async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredi structure = await getStructure(plugin, model, source, { assembly: bu }); // transform with offset and pcp let legacy: boolean = true; - if (ingredient.offset || ingredient.principalAxis){ + if (ingredient.offset || ingredient.principalAxis) { legacy = false; const structureMean = getStructureMean(structure); Vec3.negate(structureMean, structureMean); const m1: Mat4 = Mat4.identity(); Mat4.setTranslation(m1, structureMean); structure = Structure.transform(structure, m1); - if (ingredient.offset){ - if (!Vec3.exactEquals(ingredient.offset, Vec3.zero())){ + if (ingredient.offset) { + if (!Vec3.exactEquals(ingredient.offset, Vec3.zero())) { const m: Mat4 = Mat4.identity(); Mat4.setTranslation(m, ingredient.offset); structure = Structure.transform(structure, m); } } - if (ingredient.principalAxis){ - if (!Vec3.exactEquals(ingredient.principalAxis, Vec3.unitZ)){ + if (ingredient.principalAxis) { + if (!Vec3.exactEquals(ingredient.principalAxis, Vec3.unitZ)) { const q: Quat = Quat.identity(); Quat.rotationTo(q, ingredient.principalAxis, Vec3.unitZ); const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q); @@ -387,7 +387,7 @@ export function createStructureFromCellPack(plugin: PluginContext, packing: Cell structures.push(ingredientStructure.structure); assets.push(...ingredientStructure.assets); const c = ingredients[iName].color; - if (c){ + if (c) { colors.push(Color.fromNormalizedRgb(c[0], c[1], c[2])); } else { skipColors = true; @@ -454,7 +454,7 @@ async function loadMembrane(plugin: PluginContext, name: string, state: State, p break; } } - if (!file){ + if (!file) { // check for cif directly const cifileName = `${name}.cif`; for (const f of params.ingredients) { @@ -544,7 +544,7 @@ async function loadPackings(plugin: PluginContext, runtime: RuntimeContext, stat representation: params.preset.representation, }; await CellpackPackingPreset.apply(packing, packingParams, plugin); - if (packings[i].location === 'surface' && params.membrane){ + if (packings[i].location === 'surface' && params.membrane) { await loadMembrane(plugin, packings[i].name, state, params); } } diff --git a/src/extensions/cellpack/state.ts b/src/extensions/cellpack/state.ts index e7bc842ab4c8f3c9f195cb9b77414d0c823c04cd..9be5b9ede505b01e6e22f4961493b226a52d20e0 100644 --- a/src/extensions/cellpack/state.ts +++ b/src/extensions/cellpack/state.ts @@ -120,7 +120,7 @@ const StructureFromAssemblies = PluginStateTransform.BuiltIn({ let structure: Structure = initial_structure; // the list of asambly *? const symmetry = ModelSymmetry.Provider.get(model); - if (symmetry && symmetry.assemblies.length !== 0){ + if (symmetry && symmetry.assemblies.length !== 0) { for (const a of symmetry.assemblies) { const s = await StructureSymmetry.buildAssembly(initial_structure, a.id).runInContext(ctx); structures.push(s); diff --git a/src/extensions/cellpack/util.ts b/src/extensions/cellpack/util.ts index 0d790ad1b2a03d9662f402c4fd4271467b66f5df..2d25a12cdf6d987033e68fa53e6d5c43318d7707 100644 --- a/src/extensions/cellpack/util.ts +++ b/src/extensions/cellpack/util.ts @@ -41,7 +41,7 @@ export async function getFromPdb(plugin: PluginContext, pdbId: string, assetMana return { mmcif: cif.blocks[0], asset }; } -export async function getFromOPM(plugin: PluginContext, pdbId: string, assetManager: AssetManager){ +export async function getFromOPM(plugin: PluginContext, pdbId: string, assetManager: AssetManager) { const asset = await plugin.runTask(assetManager.resolve(Asset.getUrlAsset(assetManager, `https://opm-assets.storage.googleapis.com/pdb/${pdbId.toLowerCase()}.pdb`), 'string')); return { pdb: await parsePDBfile(plugin, asset.data, pdbId), asset }; } diff --git a/src/mol-plugin-ui/controls/line-graph/line-graph-component.tsx b/src/mol-plugin-ui/controls/line-graph/line-graph-component.tsx index b080af9cf9d88cd04b1330c76059c41a00160837..46e7e8788322fb17a7903ad29893ed3c3014bfea 100644 --- a/src/mol-plugin-ui/controls/line-graph/line-graph-component.tsx +++ b/src/mol-plugin-ui/controls/line-graph/line-graph-component.tsx @@ -44,16 +44,16 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS this.ghostPoints = []; this.namespace = 'http://www.w3.org/2000/svg'; - for (const point of this.props.data){ + for (const point of this.props.data) { this.state.points.push(point); } this.state.points.sort((a, b) => { - if (a[0] === b[0]){ - if (a[0] === 0){ + if (a[0] === b[0]) { + if (a[0] === 0) { return a[1] - b[1]; } - if (a[1] === 1){ + if (a[1] === 1) { return b[1] - a[1]; } return a[1] - b[1]; @@ -108,7 +108,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS this.gElement = document.getElementsByClassName('ghost-points')[0] as SVGElement; } - private change(points: Vec2[]){ + private change(points: Vec2[]) { const copyPoints = points.slice(); copyPoints.shift(); copyPoints.pop(); @@ -128,7 +128,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS } private handleMouseDown = (id: number) => (event: any) => { - if (id === 0 || id === this.state.points.length - 1){ + if (id === 0 || id === this.state.points.length - 1) { return; } @@ -150,7 +150,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS } private handleDrag(event: any) { - if (this.selected === undefined){ + if (this.selected === undefined) { return; } @@ -209,11 +209,11 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS const points = this.state.points.filter((_, i) => i !== selected[0]); points.push(updatedPoint);; points.sort((a, b) => { - if (a[0] === b[0]){ - if (a[0] === 0){ + if (a[0] === b[0]) { + if (a[0] === 0) { return a[1] - b[1]; } - if (a[1] === 1){ + if (a[1] === 1) { return b[1] - a[1]; } return a[1] - b[1]; @@ -247,11 +247,11 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS const newPoint = this.unNormalizePoint(Vec2.create(svgP.x, svgP.y)); points.push(newPoint); points.sort((a, b) => { - if (a[0] === b[0]){ - if (a[0] === 0){ + if (a[0] === b[0]) { + if (a[0] === 0) { return a[1] - b[1]; } - if (a[1] === 1){ + if (a[1] === 1) { return b[1] - a[1]; } return a[1] - b[1]; @@ -263,14 +263,14 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS } private deletePoint = (i: number) => (event: any) => { - if (i === 0 || i === this.state.points.length - 1){ return; } + if (i === 0 || i === this.state.points.length - 1) { return; } const points = this.state.points.filter((_, j) => j !== i); points.sort((a, b) => { - if (a[0] === b[0]){ - if (a[0] === 0){ + if (a[0] === b[0]) { + if (a[0] === 0) { return a[1] - b[1]; } - if (a[1] === 1){ + if (a[1] === 1) { return b[1] - a[1]; } return a[1] - b[1]; @@ -320,7 +320,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS } private refCallBack(element: any) { - if (element){ + if (element) { this.myRef = element; } } @@ -328,8 +328,8 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS private renderPoints() { const points: any[] = []; let point: Vec2; - for (let i = 0; i < this.state.points.length; i++){ - if (i !== 0 && i !== this.state.points.length - 1){ + for (let i = 0; i < this.state.points.length; i++) { + if (i !== 0 && i !== this.state.points.length - 1) { point = this.normalizePoint(this.state.points[i]); points.push(<PointComponent key={i} @@ -359,7 +359,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS let normalizedY: number; let reverseY: number; - for (const point of this.state.points){ + for (const point of this.state.points) { min = this.padding / 2; maxX = this.width + min; maxY = this.height + min; @@ -372,7 +372,7 @@ export class LineGraphComponent extends React.Component<any, LineGraphComponentS const data = points; const size = data.length; - for (let i = 0; i < size - 1;i++){ + for (let i = 0; i < size - 1;i++) { const x1 = data[i][0]; const y1 = data[i][1]; const x2 = data[i + 1][0]; diff --git a/src/mol-util/polyfill.ts b/src/mol-util/polyfill.ts index 496918f894b5c771e89f9b351738d79dd41c0927..8c8fa61b3308994db5b45272f47103ce1981e669 100644 --- a/src/mol-util/polyfill.ts +++ b/src/mol-util/polyfill.ts @@ -489,7 +489,7 @@ if (Object.defineProperty !== undefined) { } if (!Object.entries) { - Object.entries = function (obj: any){ + Object.entries = function (obj: any) { const ownProps = Object.keys(obj); let i = ownProps.length; const resArray = new Array(i); // preallocate the Array diff --git a/src/mol-util/zip/bin.ts b/src/mol-util/zip/bin.ts index 38111eff98c0898bebc027ae9cbb33cf8669343d..1b3d2a1a4feffe2be4fa128fc7342ff184691f06 100644 --- a/src/mol-util/zip/bin.ts +++ b/src/mol-util/zip/bin.ts @@ -33,7 +33,7 @@ export function writeUint(buff: Uint8Array, p: number, n: number) { buff[p + 3] = (n >> 24) & 255; } -function readASCII(buff: Uint8Array, p: number, l: number){ +function readASCII(buff: Uint8Array, p: number, l: number) { let s = ''; for (let i = 0; i < l; i++) s += String.fromCharCode(buff[p + i]); return s; diff --git a/src/mol-util/zip/huffman.ts b/src/mol-util/zip/huffman.ts index 6caf1f974c8867853de8261c111e10cac50ef032..5ed971d0219e58131bbe1868bd85011b60d935e1 100644 --- a/src/mol-util/zip/huffman.ts +++ b/src/mol-util/zip/huffman.ts @@ -32,7 +32,7 @@ export function _hufTree(hst: NumberArray, tree: number[], MAXL: number) { tree[(l2 << 1) + 1] = 1; return 1; } - list.sort(function (a, b){ return a.f - b.f; }); + list.sort(function (a, b) { return a.f - b.f; }); let a = list[0], b = list[1], i0 = 0, i1 = 1, i2 = 2; list[0] = { lit: -1, @@ -80,7 +80,7 @@ function setDepth(t: HufTree, d: number): number { function restrictDepth(dps: HufTree[], MD: number, maxl: number) { let i = 0, dbt = 0; const bCost = 1 << (maxl - MD); - dps.sort(function (a: HufTree, b: HufTree){ return b.d === a.d ? a.f - b.f : b.d - a.d; }); + dps.sort(function (a: HufTree, b: HufTree) { return b.d === a.d ? a.f - b.f : b.d - a.d; }); for (i = 0; i < dps.length; i++) { if (dps[i].d > MD) { diff --git a/src/mol-util/zip/util.ts b/src/mol-util/zip/util.ts index f5eec31fd92418de58fd333fdc99f00350ede0cb..3dee75492f8bb79918aa1cb94c2fd1ce0bd02306 100644 --- a/src/mol-util/zip/util.ts +++ b/src/mol-util/zip/util.ts @@ -7,7 +7,7 @@ * MIT License, Copyright (c) 2018 Photopea */ -export const U = (function (){ +export const U = (function () { const u16 = Uint16Array, u32 = Uint32Array; return { next_code: new u16(16), @@ -33,7 +33,7 @@ export const U = (function (){ }; })(); -(function (){ +(function () { const len = 1 << 15; for (let i = 0; i < len; i++) { let x = i;