From 34df410b1cf91882ffa3ac8eac5d9e4cf7e520aa Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Wed, 7 Aug 2019 19:18:36 +0800 Subject: [PATCH] fix(lint): lint warning --- .eslintrc | 1 + package.json | 3 +- rollup.config.js | 4 +-- src/attr/base.js | 2 +- src/component/popup.js | 2 +- src/core/controller/mapping.js | 13 +++---- src/core/controller/tile_mapping.js | 5 --- src/core/scene.js | 2 +- src/core/worker.js | 53 ----------------------------- src/geom/buffer/buffer.js | 2 +- src/geom/buffer/heatmap/grid_3d.js | 6 ++-- src/geom/material/lineMaterial.js | 2 +- src/geom/shape/point.js | 3 -- src/geom/shape/polygon.js | 2 -- src/layer/tile/image_tile.js | 2 +- src/layer/tile/tile.js | 2 +- src/layer/tile/tile_layer.js | 4 +-- src/layer/tile/vector_tile.js | 4 +-- src/layer/tile/vector_tile_mesh.js | 4 +-- src/scale/base.js | 18 ---------- src/source/parser/geojson.js | 2 +- src/source/source_cache.js | 4 +-- src/util/polyline-normals copy.js | 6 ++-- src/util/polyline-normals.js | 6 ++-- 24 files changed, 36 insertions(+), 116 deletions(-) delete mode 100644 src/core/worker.js diff --git a/.eslintrc b/.eslintrc index 60d0640fff..2650277bb0 100755 --- a/.eslintrc +++ b/.eslintrc @@ -44,6 +44,7 @@ "error", "never" ], + "jsdoc/require-param": 0, "linebreak-style": [ 0 ] diff --git a/package.json b/package.json index 6bf7116a56..16540a6840 100755 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "shelljs": "~0.7.8", "string-replace-loader": "~1.3.0", "torchjs": "~2.1.0", - "uglify-js": "~3.1.10", + "uglify-js": "~3.1.10" }, "scripts": { "build-dev": "rollup -c --environment BUILD:dev", @@ -130,7 +130,6 @@ "simple-statistics": "^7.0.1", "supercluster": "^6.0.1", "three": "^0.101.1", - "venn.js": "^0.2.20", "viewport-mercator-project": "^5.2.0", "webworkify-webpack": "^2.1.3", "wolfy87-eventemitter": "~5.2.4" diff --git a/rollup.config.js b/rollup.config.js index f0d12db60b..5ea4e2c523 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,8 +14,8 @@ const production = BUILD === 'production'; const outputFile = !production ? 'build/L7.js' : minified - ? 'build/L7-min.js' - : 'build/L7-unminified.js'; + ? 'build/L7-min.js' + : 'build/L7-unminified.js'; const config = [ { diff --git a/src/attr/base.js b/src/attr/base.js index 8da8dcca0c..79a0f2da2d 100644 --- a/src/attr/base.js +++ b/src/attr/base.js @@ -156,7 +156,7 @@ class AttributeBase { /** * 映射数据 - * @param {*} param1...paramn 多个数值 + * @param {*} params 多个数值 * @return {Array} 映射的值组成的数组 */ mapping(...params) { diff --git a/src/component/popup.js b/src/component/popup.js index e7314c86d3..22e99f69e1 100644 --- a/src/component/popup.js +++ b/src/component/popup.js @@ -37,7 +37,7 @@ export default class Popup extends Base { this._container.appendChild(this._content); if (this.get('className')) { this.get('className').split(' ').forEach(name => - this._container.classList.add(name)); + this._container.classList.add(name)); } } if (this.get('maxWidth') && this._container.style.maxWidth !== this.get('maxWidth')) { diff --git a/src/core/controller/mapping.js b/src/core/controller/mapping.js index 5020431735..5f17adfcbd 100644 --- a/src/core/controller/mapping.js +++ b/src/core/controller/mapping.js @@ -3,7 +3,7 @@ import Global from '../../global'; import ScaleController from './scale'; import Attr from '../../attr/index'; export default class Mapping { - /** 初始化mapping + /** 初始化mapping * 初始化mapping * @param {*} cfg 配置 * @param {*} cfg.layer layer对象 @@ -14,16 +14,19 @@ export default class Mapping { if (!this.mesh) this.mesh = this.layer; this._init(); } + _init() { this._initControllers(); this._initTileAttrs(); this._mapping(); } + update() { this.mesh.set('scales', {}); this._initTileAttrs(); this._updateMaping(); } + _initControllers() { const scalesOption = this.layer.get('scaleOptions'); const scaleController = new ScaleController({ @@ -33,6 +36,7 @@ export default class Mapping { }); this.mesh.set('scaleController', scaleController); } + _createScale(field) { const scales = this.mesh.get('scales'); this._initControllers(); // scale更新 @@ -43,6 +47,7 @@ export default class Mapping { } return scale; } + createScale(field) { const data = this.mesh.layerSource.data.dataArray; const scales = this.mesh.get('scales'); @@ -72,6 +77,7 @@ export default class Mapping { const values = attr.mapping(...params); return values; } + _mapping() { const attrs = this.mesh.get('attrs'); const mappedData = []; @@ -112,11 +118,6 @@ export default class Mapping { this.mesh.layerData = mappedData; } - /** - * 更新数据maping - * @param {*} layerSource 数据源 - * @param {*} layer map - */ _updateMaping() { const attrs = this.mesh.get('attrs'); diff --git a/src/core/controller/tile_mapping.js b/src/core/controller/tile_mapping.js index f8e70c1b3c..fed4dc7622 100644 --- a/src/core/controller/tile_mapping.js +++ b/src/core/controller/tile_mapping.js @@ -107,11 +107,6 @@ export default class TileMapping extends Base { this.layerData = mappedData; } - /** - * 更新数据maping - * @param {*} layerSource 数据源 - * @param {*} layer map - */ _updateMaping() { const attrs = this.get('attrs'); diff --git a/src/core/scene.js b/src/core/scene.js index e3ebb388f4..14dec56845 100644 --- a/src/core/scene.js +++ b/src/core/scene.js @@ -182,7 +182,7 @@ export default class Scene extends Base { this.map.off('mapmove', this._updateRender); this.map.off('camerachange', this._updateRender); } - // control + // control addControl(ctr) { this.get('controlController').addControl(ctr); diff --git a/src/core/worker.js b/src/core/worker.js deleted file mode 100644 index 8d23b7e603..0000000000 --- a/src/core/worker.js +++ /dev/null @@ -1,53 +0,0 @@ -class WorkerPool { - constructor(workerCount) { - this.workerCount = workerCount || Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1); - this.workers = []; // worker线程池 - this.workerQueue = []; // 任务队列 - this._initWorker(); // 初始化线程池 - } - _initWorker() { - while (this.workers.length < this.workerCount) { - this.workers.push(new Worker()); - } - } - runTask(payload) { - return new Promise((resolve, reject) => { - if (this.workers.length > 0) { - const worker = this.workers.shift(); // 从线程池取出一个worker - worker.postMessage(payload); // 向线程发送数据 - const workerCallback = e => { - resolve(e.data); // 成功则返回数据 - // 移除事件监听 - worker.removeEventListener('message', workerCallback); - // 重新放回线程池 - this.workers.push(worker); - // 如果任务队列的数据还有则从任务队列继续取数据执行任务 - if (this.workerQueue.length > 0) { - const queueData = this.workerQueue.shift(); - this.runTask(queueData.payload).then(data => { - queueData.resolve(data); - }); - } - }; - // 监听worker事件 - worker.addEventListener('message', workerCallback); - worker.addEventListener('error', e => { - reject('filename:' + e.filename + '\nmessage:' + e.message + '\nlineno:' + e.lineno); - }); - } else { - // 如果线程池都被占用,则将数据丢入任务队列,并保存对应的resolve和reject - this.workerQueue.push({ - payload, - resolve, - reject - }); - } - }); - } - release() { - this.workers.forEach(worker => { - worker.terminate(); - }); - } -} -export default WorkerPool; diff --git a/src/geom/buffer/buffer.js b/src/geom/buffer/buffer.js index 95b08d231a..86ea4294d1 100644 --- a/src/geom/buffer/buffer.js +++ b/src/geom/buffer/buffer.js @@ -112,7 +112,7 @@ export default class BufferBase extends Base { prePoint[0], prePoint[1], 0, nextPoint[0], nextPoint[1], 0 ], - positionOffset * 3); + positionOffset * 3); const indexArray = [ 1, 2, 0, 3, 2, 1 ].map(v => { return v + positionOffset; }); if (this.get('uv')) { this.attributes.uv.set([ 0.1, 0, 0, 0, 0.1, size / 2000, 0, size / 2000 ], positionOffset * 2); diff --git a/src/geom/buffer/heatmap/grid_3d.js b/src/geom/buffer/heatmap/grid_3d.js index 01b1e0bc51..71e0c68b87 100644 --- a/src/geom/buffer/heatmap/grid_3d.js +++ b/src/geom/buffer/heatmap/grid_3d.js @@ -41,7 +41,7 @@ export default class Grid3D extends BufferBase { this._encodeArray(feature, 4); this.attributes.positions.set([ x, y, size, x, y, size, x, y, size, x, y, size ], this._offset * 3); this.attributes.miters.set([ -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1 ], this._offset * 3); - this.attributes.normals.set([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ], this._offset * 3); // top normal + this.attributes.normals.set([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ], this._offset * 3); // top normal const indexArray = [ 0, 2, 1, 2, 3, 1 ].map(v => { return v + this._offset; }); this.indexArray.set(indexArray, this._offset * 1.5); this._offset += 4; @@ -60,7 +60,7 @@ export default class Grid3D extends BufferBase { -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // left 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // top 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 // right - ], this._offset * 3); // top normal + ], this._offset * 3); // top normal for (let i = 0; i < 4; i++) { this.attributes.positions.set([ x, y, 1, x, y, 1, x, y, 1, x, y, 1 ], this._offset * 3); @@ -77,7 +77,7 @@ export default class Grid3D extends BufferBase { prePoint[0], prePoint[1], 0, nextPoint[0], nextPoint[1], 0 ], - positionOffset * 3); + positionOffset * 3); const indexArray = [ 0, 1, 2, 1, 3, 2 ].map(v => { return v + positionOffset; }); if (this.get('uv')) { // temp 点亮城市demo diff --git a/src/geom/material/lineMaterial.js b/src/geom/material/lineMaterial.js index 8ff74a6a78..47ab63fd7c 100644 --- a/src/geom/material/lineMaterial.js +++ b/src/geom/material/lineMaterial.js @@ -16,7 +16,7 @@ export function LineMaterial(options) { vertexShader: vs, fragmentShader: fs, transparent: true - // blending: THREE.AdditiveBlending + // blending: THREE.AdditiveBlending }); return material; } diff --git a/src/geom/shape/point.js b/src/geom/shape/point.js index 7a5349d87b..031389f1a6 100644 --- a/src/geom/shape/point.js +++ b/src/geom/shape/point.js @@ -11,7 +11,6 @@ export function circle(type) { } /** * @param {enum} type 渲染类型 - * @param {boolean} extrude 是否进行高度拉伸 * @return {object} 顶点坐标和索引坐标 */ export function triangle(type) { @@ -21,7 +20,6 @@ export function triangle(type) { /** * @param {enum} type 渲染类型 - * @param {boolean} extrude 是否进行高度拉伸 * @return {object} 顶点坐标和索引坐标 */ export function diamond(type) { @@ -35,7 +33,6 @@ export function square(type) { /** * @param {enum} type 渲染类型 - * @param {boolean} extrude 是否进行高度拉伸 * @return {object} 顶点坐标和索引坐标 */ export function hexagon(type) { diff --git a/src/geom/shape/polygon.js b/src/geom/shape/polygon.js index 289f7a45c4..6b6eef6907 100644 --- a/src/geom/shape/polygon.js +++ b/src/geom/shape/polygon.js @@ -2,7 +2,6 @@ import extrudePolygon from '../extrude'; /** * 计算平面的 polygon的顶点坐标和索引 * @param {Array} points 顶点坐标 - * @param {*} extrude 是否拉伸 * @return {object} 顶点坐标和顶点索引 */ export function fill(points) { @@ -12,7 +11,6 @@ export function fill(points) { /** * 计算 extrude 的 polygon的顶点坐标和索引 * @param {Array} points 顶点坐标 - * @param {*} extrude 是否拉伸 * @return {object} 顶点坐标和顶点索引 */ export function extrude(points) { diff --git a/src/layer/tile/image_tile.js b/src/layer/tile/image_tile.js index 73c7c335e6..1888fa4c99 100644 --- a/src/layer/tile/image_tile.js +++ b/src/layer/tile/image_tile.js @@ -7,7 +7,7 @@ export default class ImageTile extends Tile { // Making this asynchronous really speeds up the LOD framerate setTimeout(() => { if (!this._mesh) { - // this._mesh = this._createMesh(); + // this._mesh = this._createMesh(); this._requestTile(); } }, 0); diff --git a/src/layer/tile/tile.js b/src/layer/tile/tile.js index 7c862018f2..71b2552a3b 100644 --- a/src/layer/tile/tile.js +++ b/src/layer/tile/tile.js @@ -80,7 +80,7 @@ export default class Tile extends Base { return urlParams[key]; }); } - // 经纬度范围转瓦片范围 + // 经纬度范围转瓦片范围 _tileBounds(lnglatBound) { const ne = this.layer.scene.project([ lnglatBound.getNorthEast().lng, lnglatBound.getNorthEast().lat ]); const sw = this.layer.scene.project([ lnglatBound.getSouthWest().lng, lnglatBound.getSouthWest().lat ]); diff --git a/src/layer/tile/tile_layer.js b/src/layer/tile/tile_layer.js index 84c3e9a7d3..52c22485d0 100644 --- a/src/layer/tile/tile_layer.js +++ b/src/layer/tile/tile_layer.js @@ -116,7 +116,7 @@ export default class TileLayer extends Layer { const tileRange = this._pxBoundsToTileRange(pixelBounds); const margin = this.get('keepBuffer'); this.noPruneRange = new Bounds(tileRange.getBottomLeft().subtract([ margin, -margin ]), - tileRange.getTopRight().add([ margin, -margin ])); + tileRange.getTopRight().add([ margin, -margin ])); if (!(isFinite(tileRange.min.x) && isFinite(tileRange.min.y) && isFinite(tileRange.max.x) && @@ -424,7 +424,7 @@ export default class TileLayer extends Layer { if (!this._tiles.children.length > 0 || !this._object3D.visible) { return; } - // 更新数据颜色 过滤 filter + // 更新数据颜色 过滤 filter if (!Util.isEqual(preAttrs.color, nextAttrs.color) || !Util.isEqual(preAttrs.filter, nextAttrs.filter)) { this._tileCache.setNeedUpdate(); this._tiles.children.forEach(tile => { diff --git a/src/layer/tile/vector_tile.js b/src/layer/tile/vector_tile.js index a8defd052c..39def90153 100644 --- a/src/layer/tile/vector_tile.js +++ b/src/layer/tile/vector_tile.js @@ -58,9 +58,9 @@ export default class VectorTile extends Tile { context.depthMask(false); renderer.clearDepth(); - // only render where stencil is set to 1 + // only render where stencil is set to 1 - context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1 + context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1 context.stencilOp(context.KEEP, context.KEEP, context.KEEP); } _tileMaskMesh() { diff --git a/src/layer/tile/vector_tile_mesh.js b/src/layer/tile/vector_tile_mesh.js index 531b33a25a..afb66aaf33 100644 --- a/src/layer/tile/vector_tile_mesh.js +++ b/src/layer/tile/vector_tile_mesh.js @@ -79,9 +79,9 @@ export default class VectorTileMesh { context.depthMask(false); renderer.clearDepth(); - // only render where stencil is set to 1 + // only render where stencil is set to 1 - context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1 + context.stencilFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1 context.stencilOp(context.KEEP, context.KEEP, context.KEEP); } _tileMaskMesh() { diff --git a/src/scale/base.js b/src/scale/base.js index 91e5c148c7..2a5ab814b2 100644 --- a/src/scale/base.js +++ b/src/scale/base.js @@ -64,23 +64,6 @@ class Base { } - /** - * 获取该度量的ticks,返回的是多个对象, - * - text: tick 的文本 - * - value: 对应的度量转换后的值 - * - * [ - * {text: 0,value:0} - * {text: 1,value:0.2} - * {text: 2,value:0.4} - * {text: 3,value:0.6} - * {text: 4,value:0.8} - * {text: 5,value:1} - * ] - * - * @param {Number} count 输出tick的个数的近似值,默认是 10 - * @return {Array} 返回 ticks 数组 - */ getTicks() { const self = this; const ticks = self.ticks; @@ -172,7 +155,6 @@ class Base { /** * 更改度量的属性信息 * @param {Object} info 属性信息 - * @chainable * @return {Scale} 返回自身的引用 */ change(info) { diff --git a/src/source/parser/geojson.js b/src/source/parser/geojson.js index ac70b2fbdf..6ccf286b0c 100644 --- a/src/source/parser/geojson.js +++ b/src/source/parser/geojson.js @@ -3,7 +3,7 @@ import { getCoords } from '@turf/invariant'; import { djb2hash } from '../../util/bkdr-hash'; import rewind from '@mapbox/geojson-rewind'; export default function geoJSON(data, cfg) { - // 矢量瓦片图层不做 rewind + // 矢量瓦片图层不做 rewind rewind(data, true); const resultData = []; diff --git a/src/source/source_cache.js b/src/source/source_cache.js index 3f1c0d3898..4deb0ecce6 100644 --- a/src/source/source_cache.js +++ b/src/source/source_cache.js @@ -122,7 +122,7 @@ export default class SouceCache extends Base { _calculateTileIDs() { this._tileMap = {}; this.updateTileList = []; - const zoom = Math.floor(this.scene.getZoom()); // - window.window.devicePixelRatio + 1; // zoom - 1 + const zoom = Math.floor(this.scene.getZoom()); // - window.window.devicePixelRatio + 1; // zoom - 1 const minSourceZoom = this.get('minZoom'); const maxSourceZoom = this.get('maxZoom'); this.tileZoom = zoom > maxSourceZoom ? maxSourceZoom : zoom; @@ -300,7 +300,7 @@ export default class SouceCache extends Base { } } } - // 地图拾取 + // 地图拾取 _addPickMesh(layer, meshObj) { if (this.type === 'image') { return; diff --git a/src/util/polyline-normals copy.js b/src/util/polyline-normals copy.js index 1be6aa15fe..b84b4b0f84 100644 --- a/src/util/polyline-normals copy.js +++ b/src/util/polyline-normals copy.js @@ -69,9 +69,9 @@ export default function(points, closed, indexOffset) { attrIndex.push([ index + 0, index + 2, index + 1 ]); - // no miter, simple segment + // no miter, simple segment if (!next) { - // reset normal + // reset normal normal(_normal, lineA); extrusions(attrPos, out, cur, _normal, 1); attrDistance.push(d, d); @@ -97,7 +97,7 @@ export default function(points, closed, indexOffset) { attrDistance.push(d, d); attrIndex.push( _lastFlip === 1 ? [ index + 1, index + 3, index + 2 ] - : [ index, index + 2, index + 3 ] + : [ index, index + 2, index + 3 ] ); // 避免在 Material 中使用 THREE.DoubleSide diff --git a/src/util/polyline-normals.js b/src/util/polyline-normals.js index 25288ea32c..b3cd09a3aa 100644 --- a/src/util/polyline-normals.js +++ b/src/util/polyline-normals.js @@ -71,9 +71,9 @@ export default function(points, closed, indexOffset) { attrIndex.push(index + 0, index + 2, index + 1); - // no miter, simple segment + // no miter, simple segment if (!next) { - // reset normal + // reset normal normal(_normal, lineA); extrusions(attrPos, out, miters, cur, _normal, 1); attrDistance.push(d, d); @@ -98,7 +98,7 @@ export default function(points, closed, indexOffset) { extrusions(attrPos, out, miters, cur, _normal, 1); attrDistance.push(d, d); const indexData = _lastFlip === 1 ? [ index + 1, index + 3, index + 2 ] - : [ index, index + 2, index + 3 ]; + : [ index, index + 2, index + 3 ]; attrIndex.push(...indexData); // 避免在 Material 中使用 THREE.DoubleSide