Skip to content

Commit

Permalink
chore: fix eslint rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Dec 20, 2021
1 parent eb7c8d5 commit 6fff078
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Expand Up @@ -104,6 +104,9 @@ module.exports = {
'class-methods-use-this': 'off',
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
'max-classes-per-file': ['error', 4],
'function-call-argument-newline': 'off',
// change default-param-last to on, but there are several breaking changes or default params to add.
'default-param-last': 'off',
},
globals: {
__DEBUG__: false,
Expand Down
1 change: 1 addition & 0 deletions examples/js/Scale.js
Expand Up @@ -13,6 +13,7 @@ function roundPixelsFromMeters(view, pixelSize) {

// Round the metric distance :
distanceMeters = Math.floor(distanceMeters);
// eslint-disable-next-line prefer-exponentiation-operator
var digit = Math.pow(10, distanceMeters.toString().length - 1);
distanceMeters = Math.round(distanceMeters / digit) * digit;

Expand Down
6 changes: 3 additions & 3 deletions src/Converter/Feature2Mesh.js
Expand Up @@ -4,9 +4,9 @@ import { FEATURE_TYPES } from 'Core/Feature';
import { deprecatedFeature2MeshOptions } from 'Core/Deprecated/Undeprecator';

const _color = new THREE.Color();
const maxValueUint8 = Math.pow(2, 8) - 1;
const maxValueUint16 = Math.pow(2, 16) - 1;
const maxValueUint32 = Math.pow(2, 32) - 1;
const maxValueUint8 = 2 ** 8 - 1;
const maxValueUint16 = 2 ** 16 - 1;
const maxValueUint32 = 2 ** 32 - 1;

function toColor(color) {
if (color) {
Expand Down
2 changes: 1 addition & 1 deletion src/Layer/TiledGeometryLayer.js
Expand Up @@ -407,7 +407,7 @@ class TiledGeometryLayer extends GeometryLayer {
const offsetScale = nodeLayer.offsetScales[0];
const ratio = offsetScale.z;
// ratio is node size / texture size
if (ratio < 1 / Math.pow(2, this.maxDeltaElevationLevel)) {
if (ratio < 1 / 2 ** this.maxDeltaElevationLevel) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Process/LayeredMaterialNodeProcessing.js
Expand Up @@ -3,7 +3,7 @@ import LayerUpdateState from 'Layer/LayerUpdateState';
import handlingError from 'Process/handlerNodeError';

export const SIZE_TEXTURE_TILE = 256;
export const SIZE_DIAGONAL_TEXTURE = Math.pow(2 * (SIZE_TEXTURE_TILE * SIZE_TEXTURE_TILE), 0.5);
export const SIZE_DIAGONAL_TEXTURE = (2 * (SIZE_TEXTURE_TILE * SIZE_TEXTURE_TILE)) ** 0.5;

function materialCommandQueuePriorityFunction(material) {
// We know that 'node' is visible because commands can only be
Expand Down
1 change: 0 additions & 1 deletion src/Renderer/OBB.js
Expand Up @@ -25,7 +25,6 @@ class OBB extends THREE.Object3D {
this.box3D = new THREE.Box3(min.clone(), max.clone());
this.natBox = this.box3D.clone();
this.z = { min: 0, max: 0, scale: 1.0 };
return this;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Renderer/Shader/ShaderUtils.js
@@ -1,5 +1,7 @@
const rePosition = new RegExp('gl_Position.*(?![^]*gl_Position)');
const reMain = new RegExp('[^\\w]*main[^\\w]*(void)?[^\\w]*{');
const pattern_gl_Position = 'gl_Position.*(?![^]*gl_Position)';
const pattern_Main = '[^\\w]*main[^\\w]*(void)?[^\\w]*{';
const rePosition = new RegExp(pattern_gl_Position);
const reMain = new RegExp(pattern_Main);

export default {
patchMaterialForLogDepthSupport(material) {
Expand Down
1 change: 1 addition & 0 deletions test/functional/.eslintrc.js
Expand Up @@ -59,5 +59,6 @@ module.exports = {
'max-len': 'off',
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
'prefer-object-spread': 'off',
'function-paren-newline': 'off',
},
};
4 changes: 2 additions & 2 deletions test/unit/CameraUtils.js
Expand Up @@ -139,7 +139,7 @@ describe('Camera utils unit test', function () {
subExtent.set(0, 10, 0, 5);
CameraUtils.transformCameraToLookAtTarget(view, camera3D, subExtent);
assert.ok(
(camera3D.top - camera3D.bottom) / camera3D.zoom - subExtent.planarDimensions().x / 1.5 < Math.pow(10, -14),
(camera3D.top - camera3D.bottom) / camera3D.zoom - subExtent.planarDimensions().x / 1.5 < 10 ** -14,
);
assert.equal(
(camera3D.right - camera3D.left) / camera3D.zoom,
Expand All @@ -154,7 +154,7 @@ describe('Camera utils unit test', function () {
camera3D.updateMatrixWorld(true);
assert.ok(
CameraUtils.getCameraTransformOptionsFromExtent(view, camera3D, subExtent).range -
subExtent.planarDimensions().y / (2 * Math.tan(THREE.Math.degToRad(camera3D.fov) / 2)) < Math.pow(10, -14),
subExtent.planarDimensions().y / (2 * Math.tan(THREE.Math.degToRad(camera3D.fov) / 2)) < 10 ** -14,
);
});
});
4 changes: 2 additions & 2 deletions test/unit/bootstrap.js
Expand Up @@ -36,7 +36,7 @@ class DOMElement {
document.documentElement = this;

Object.defineProperty(this, 'onload', {
set: f => f(),
set: (f) => { f(); },
});
}

Expand Down Expand Up @@ -101,7 +101,7 @@ global.document = {
img.width = 10;
img.height = 10;
Object.defineProperty(img, 'src', {
set: () => img.emitEvent('load'),
set: () => { img.emitEvent('load'); },
});
return img;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/globeview.js
Expand Up @@ -104,7 +104,7 @@ describe('GlobeView', function () {
assert.ok(
CameraUtils.getTransformCameraLookingAtTarget(extentViewer, camera3D).range -
size.x / (2 * Math.tan(THREE.Math.degToRad(camera3D.fov) / 2))
< Math.pow(10, -6),
< 10 ** -6,
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/layeredmaterialnodeprocessing.js
Expand Up @@ -105,7 +105,7 @@ describe('updateLayeredMaterialNodeImagery', function () {
});

it('tile should not request texture with level > layer.source.zoom.max', () => {
const countTexture = Math.pow(2, 15);
const countTexture = 2 ** 15;
const newExtent = new Extent('EPSG:4326', 0, 180 / countTexture, 0, 180 / countTexture);
const tile = new TileMesh(geom, material, layer, newExtent, 15);
// Emulate a situation where tile inherited a level 1 texture
Expand Down
2 changes: 1 addition & 1 deletion test/unit/tilemesh.js
Expand Up @@ -34,7 +34,7 @@ describe('TileMesh', function () {
for (let i = 1; i < 4; i++) {
tree[i] = [];
// four child per parent
for (let j = 0; j < Math.pow(4, i); j++) {
for (let j = 0; j < 4 ** i; j++) {
const tile = new FakeTileMesh(i, tree[i - 1][~~(j / 4)]);
tree[i].push(tile);
}
Expand Down

0 comments on commit 6fff078

Please sign in to comment.