diff --git a/.eslintrc.json b/.eslintrc.json index ca46ec3cef678b76d0d53677132024b3e2127ec1..4ca358039cd8d566b8b65657e7f4bdec1e04b596 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,7 +43,8 @@ "key-spacing": "error", "object-curly-spacing": ["error", "always"], "array-bracket-spacing": "error", - "space-in-parens": "error" + "space-in-parens": "error", + "computed-property-spacing": "error" }, "overrides": [ { diff --git a/src/cli/cifschema/index.ts b/src/cli/cifschema/index.ts index 94584492ef03485865b34ee79932bc6a449608b5..3b8d96a01ce47682762765f3585d4a8256e9040f 100644 --- a/src/cli/cifschema/index.ts +++ b/src/cli/cifschema/index.ts @@ -131,8 +131,8 @@ async function getFieldNamesFilter(fieldNamesPath: string): Promise<Filter> { fieldNames.forEach((name, i) => { const [category, field] = name.split('.'); // console.log(category, field) - if (!filter[ category ]) filter[ category ] = {}; - filter[ category ][ field ] = true; + if (!filter[category]) filter[category] = {}; + filter[category][field] = true; }); return filter; } diff --git a/src/cli/cifschema/util/schema.ts b/src/cli/cifschema/util/schema.ts index 579ba0a16f39f54d8454f11cc69a8cbb492d4863..9763930cd5750140894a253762e01ee1633512c1 100644 --- a/src/cli/cifschema/util/schema.ts +++ b/src/cli/cifschema/util/schema.ts @@ -57,7 +57,7 @@ export function mergeFilters (...filters: Filter[]) { const fields: Map<string, number> = new Map(); filters.forEach(filter => { Object.keys(filter).forEach(category => { - Object.keys(filter[ category ]).forEach(field => { + Object.keys(filter[category]).forEach(field => { const key = `${category}.${field}`; const value = fields.get(key) || 0; fields.set(key, value + 1); diff --git a/src/extensions/rcsb/validation-report/prop.ts b/src/extensions/rcsb/validation-report/prop.ts index e153187f53f993f8c215844a293d1004df17f1a8..60696e986fc04908c48bb413e3b2955c8c16b39b 100644 --- a/src/extensions/rcsb/validation-report/prop.ts +++ b/src/extensions/rcsb/validation-report/prop.ts @@ -431,7 +431,7 @@ function parseValidationReportXml(xml: XMLDocument, model: Model): ValidationRep const groups = xml.getElementsByTagName('ModelledSubgroup'); for (let i = 0, il = groups.length; i < il; ++i) { - const g = groups[ i ]; + const g = groups[i]; const ga = g.attributes; const pdbx_PDB_model_num = parseInt(getItem(ga, 'model')); diff --git a/src/mol-canvas3d/passes/multi-sample.ts b/src/mol-canvas3d/passes/multi-sample.ts index 7df8188159ee332192ef78e40d81906ac8631681..3dc1e56615674ff80bd6e038479e3f36466d6653 100644 --- a/src/mol-canvas3d/passes/multi-sample.ts +++ b/src/mol-canvas3d/passes/multi-sample.ts @@ -123,7 +123,7 @@ export class MultiSamplePass { // // This manual approach to MSAA re-renders the scene once for // each sample with camera jitter and accumulates the results. - const offsetList = JitterVectors[ Math.max(0, Math.min(props.multiSample.sampleLevel, 5)) ]; + const offsetList = JitterVectors[Math.max(0, Math.min(props.multiSample.sampleLevel, 5))]; const { x, y, width, height } = camera.viewport; const baseSampleWeight = 1.0 / offsetList.length; @@ -190,7 +190,7 @@ export class MultiSamplePass { // // This manual approach to MSAA re-renders the scene once for // each sample with camera jitter and accumulates the results. - const offsetList = JitterVectors[ Math.max(0, Math.min(props.multiSample.sampleLevel, 5)) ]; + const offsetList = JitterVectors[Math.max(0, Math.min(props.multiSample.sampleLevel, 5))]; if (sampleIndex === -2 || sampleIndex >= offsetList.length) return -2; diff --git a/src/mol-geo/primitive/cylinder.ts b/src/mol-geo/primitive/cylinder.ts index 8bf9f52f988a492bef00ae20e2378cf0aeec5af5..38f2b3488892ebf9539643fa52a0138c9ed130e0 100644 --- a/src/mol-geo/primitive/cylinder.ts +++ b/src/mol-geo/primitive/cylinder.ts @@ -89,10 +89,10 @@ export function Cylinder(props?: CylinderProps): Primitive { for (let y = 0; y < heightSegments; ++y) { // we use the index array to access the correct indices - const a = indexArray[ y ][ x ]; - const b = indexArray[ y + 1 ][ x ]; - const c = indexArray[ y + 1 ][ x + 1 ]; - const d = indexArray[ y ][ x + 1 ]; + const a = indexArray[y][x]; + const b = indexArray[y + 1][x]; + const c = indexArray[y + 1][x + 1]; + const d = indexArray[y][x + 1]; // faces indices.push(a, b, d); diff --git a/src/mol-geo/primitive/polyhedron.ts b/src/mol-geo/primitive/polyhedron.ts index 2b2698d234a7a29d0189cb5204088b38f258f9c8..08799aaa9b4f263976cd7a5761aa019e7e368c57 100644 --- a/src/mol-geo/primitive/polyhedron.ts +++ b/src/mol-geo/primitive/polyhedron.ts @@ -46,9 +46,9 @@ export function Polyhedron(_vertices: ArrayLike<number>, _indices: ArrayLike<num // iterate over all faces and apply a subdivison with the given detail value for (let i = 0; i < _indices.length; i += 3) { // get the vertices of the face - Vec3.fromArray(a, _vertices, _indices[ i + 0 ] * 3); - Vec3.fromArray(b, _vertices, _indices[ i + 1 ] * 3); - Vec3.fromArray(c, _vertices, _indices[ i + 2 ] * 3); + Vec3.fromArray(a, _vertices, _indices[i + 0] * 3); + Vec3.fromArray(b, _vertices, _indices[i + 1] * 3); + Vec3.fromArray(c, _vertices, _indices[i + 2] * 3); // perform subdivision subdivideFace(a, b, c, detail); diff --git a/src/mol-io/reader/cube/parser.ts b/src/mol-io/reader/cube/parser.ts index 5faeaa1fd3dd33d94bf8d14c910a61e7a34dfe44..c852a39ef27d88a40de13e76de8e25c9d0ffdf70 100644 --- a/src/mol-io/reader/cube/parser.ts +++ b/src/mol-io/reader/cube/parser.ts @@ -52,7 +52,7 @@ const bohrToAngstromFactor = 0.529177210859; function readHeader(tokenizer: Tokenizer) { const headerLines = Tokenizer.readLines(tokenizer, 6); const h = (k: number, l: number) => { - const field = +headerLines[k].trim().split(/\s+/g)[ l ]; + const field = +headerLines[k].trim().split(/\s+/g)[l]; return Number.isNaN(field) ? 0 : field; }; const basis = (i: number) => { diff --git a/src/mol-math/linear-algebra/matrix/matrix.ts b/src/mol-math/linear-algebra/matrix/matrix.ts index bb8f618d41492c44847b8aee9c7938aa27abf477..294c71e83c72c7c28a75363dd3b9a70a3dd7d287 100644 --- a/src/mol-math/linear-algebra/matrix/matrix.ts +++ b/src/mol-math/linear-algebra/matrix/matrix.ts @@ -91,11 +91,11 @@ namespace Matrix { const md = mat.data; const mean = new Array(ncols) as V; - for (let j = 0; j < ncols; ++j) mean[ j ] = 0.0; + for (let j = 0; j < ncols; ++j) mean[j] = 0.0; for (let i = 0, p = 0; i < nrows; ++i) { - for (let j = 0; j < ncols; ++j, ++p) mean[ j ] += md[ p ]; + for (let j = 0; j < ncols; ++j, ++p) mean[j] += md[p]; } - for (let j = 0; j < ncols; ++j) mean[ j ] /= nrows; + for (let j = 0; j < ncols; ++j) mean[j] /= nrows; return mean; } @@ -106,7 +106,7 @@ namespace Matrix { const md = mat.data; for (let i = 0, p = 0; i < nrows; ++i) { - for (let j = 0; j < ncols; ++j, ++p) md[ p ] -= row[ j ]; + for (let j = 0; j < ncols; ++j, ++p) md[p] -= row[j]; } return mat; } diff --git a/src/mol-util/color/color.ts b/src/mol-util/color/color.ts index e90f3a25e4d9d5798b9e80a7cb53c746e619a6b1..931c7658d2829a609b4a15f9f391a3c7918edce5 100644 --- a/src/mol-util/color/color.ts +++ b/src/mol-util/color/color.ts @@ -53,17 +53,17 @@ export namespace Color { /** Copies hex color to rgb array */ export function toArray(hexColor: Color, array: NumberArray, offset: number) { - array[ offset ] = (hexColor >> 16 & 255); - array[ offset + 1 ] = (hexColor >> 8 & 255); - array[ offset + 2 ] = (hexColor & 255); + array[offset] = (hexColor >> 16 & 255); + array[offset + 1] = (hexColor >> 8 & 255); + array[offset + 2] = (hexColor & 255); return array; } /** Copies normalized (0 to 1) hex color to rgb array */ export function toArrayNormalized<T extends NumberArray>(hexColor: Color, array: T, offset: number) { - array[ offset ] = (hexColor >> 16 & 255) / 255; - array[ offset + 1 ] = (hexColor >> 8 & 255) / 255; - array[ offset + 2 ] = (hexColor & 255) / 255; + array[offset] = (hexColor >> 16 & 255) / 255; + array[offset + 1] = (hexColor >> 8 & 255) / 255; + array[offset + 2] = (hexColor & 255) / 255; return array; } diff --git a/src/mol-util/file-info.ts b/src/mol-util/file-info.ts index fcc24240450ae53f2c42bbc618137ecdfea0cbfb..2c8247f367df0ef7a0a74b2502ba7afbb79decbe 100644 --- a/src/mol-util/file-info.ts +++ b/src/mol-util/file-info.ts @@ -51,8 +51,8 @@ export function getFileInfo (file: FileInput): FileInfo { const protocolMatch = path.match(/^(.+):\/\/(.+)$/); if (protocolMatch) { - protocol = protocolMatch[ 1 ].toLowerCase(); - path = protocolMatch[ 2 ] || ''; + protocol = protocolMatch[1].toLowerCase(); + path = protocolMatch[2] || ''; } const dir = path.substring(0, path.lastIndexOf('/') + 1); diff --git a/src/mol-util/polyfill.ts b/src/mol-util/polyfill.ts index aea55bd4a2caa965acef734510b4660abbace36e..a0c9f4147d5ecc82d4989272adf3445553bf3aea 100644 --- a/src/mol-util/polyfill.ts +++ b/src/mol-util/polyfill.ts @@ -32,7 +32,7 @@ if (typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement Object.defineProperty(window.HTMLCanvasElement.prototype, 'toBlob', { value: function (callback: any, type: any, quality: any) { - let bin = window.atob(this.toDataURL(type, quality).split(',')[ 1 ]); + let bin = window.atob(this.toDataURL(type, quality).split(',')[1]); let len = bin.length; let len32 = len >> 2; let a8 = new Uint8Array(len); @@ -51,7 +51,7 @@ if (typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement let tailLength = len & 3; while (tailLength--) { - a8[ j ] = bin.charCodeAt(j++); + a8[j] = bin.charCodeAt(j++); } callback(new window.Blob([a8], { 'type': type || 'image/png' })); @@ -401,12 +401,12 @@ if (typeof window !== 'undefined') { for (let x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = ( - (window as any)[ vendors[ x ] + 'RequestAnimationFrame' ] + (window as any)[vendors[x] + 'RequestAnimationFrame'] ); window.cancelAnimationFrame = ( - (window as any)[ vendors[ x ] + 'CancelAnimationFrame' ] || - (window as any)[ vendors[ x ] + 'CancelRequestAnimationFrame' ] + (window as any)[vendors[x] + 'CancelAnimationFrame'] || + (window as any)[vendors[x] + 'CancelRequestAnimationFrame'] ); } @@ -442,7 +442,7 @@ if (Function.prototype.name === undefined && Object.defineProperty !== undefined Object.defineProperty(Function.prototype, 'name', { get: function () { - return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[ 1 ]; + return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; } }); diff --git a/src/mol-util/zip/deflate.ts b/src/mol-util/zip/deflate.ts index 37d67eee818ec9d0437319a19fbb81e8d30e59ac..e514ef84259c30cdb6d72cfde799a7e012894513 100644 --- a/src/mol-util/zip/deflate.ts +++ b/src/mol-util/zip/deflate.ts @@ -75,7 +75,7 @@ function deflateChunk(ctx: DeflateContext, count: number) { if(mch !== 0) { const len = mch >>> 16, dst = mch & 0xffff; const lgi = _goodIndex(len, U.of0); U.lhst[257 + lgi]++; - const dgi = _goodIndex(dst, U.df0); U.dhst[ dgi]++; ebits += U.exb[lgi] + U.dxb[dgi]; + const dgi = _goodIndex(dst, U.df0); U.dhst[dgi]++; ebits += U.exb[lgi] + U.dxb[dgi]; lits[li] = (len << 23) | (i - cvrd); lits[li + 1] = (dst << 16) | (lgi << 8) | dgi; li += 2; cvrd = i + len; } else {