From f2ef27f78c356f8dabec45933190904e1f1902ea Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Fri, 23 Oct 2020 14:03:50 -0400 Subject: [PATCH] Enable no-implicit-coercion eslint rule for strings --- .eslintrc | 1 + modules/osm/note.js | 2 +- modules/services/streetside.js | 8 +++++--- modules/ui/sections/validation_rules.js | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index a7d98196d..0cb7ec158 100644 --- a/.eslintrc +++ b/.eslintrc @@ -43,6 +43,7 @@ "no-extra-label": "error", "no-floating-decimal": "error", "no-global-assign": "error", + "no-implicit-coercion": ["warn", { "boolean": false, "number": false }], "no-implied-eval": "error", "no-invalid-this": "off", "no-iterator": "error", diff --git a/modules/osm/note.js b/modules/osm/note.js index e8c56f657..18bf426d3 100644 --- a/modules/osm/note.js +++ b/modules/osm/note.js @@ -37,7 +37,7 @@ Object.assign(osmNote.prototype, { } if (!this.id) { - this.id = osmNote.id() + ''; // as string + this.id = osmNote.id().toString(); } return this; diff --git a/modules/services/streetside.js b/modules/services/streetside.js index 554c3c0a6..094062fb1 100644 --- a/modules/services/streetside.js +++ b/modules/services/streetside.js @@ -479,7 +479,8 @@ export default { if (!window.pannellum) return; if (_pannellumViewer) return; - const sceneID = ++_currScene + ''; + _currScene += 1; + const sceneID = _currScene.toString(); const options = { 'default': { firstScene: sceneID }, scenes: {} @@ -873,14 +874,15 @@ export default { that.initViewer(); } else { // make a new scene - let sceneID = ++_currScene + ''; + _currScene += 1; + let sceneID = _currScene.toString(); _pannellumViewer .addScene(sceneID, _sceneOptions) .loadScene(sceneID); // remove previous scene if (_currScene > 2) { - sceneID = (_currScene - 1) + ''; + sceneID = (_currScene - 1).toString(); _pannellumViewer .removeScene(sceneID); } diff --git a/modules/ui/sections/validation_rules.js b/modules/ui/sections/validation_rules.js index 91e0ea246..fd49f1412 100644 --- a/modules/ui/sections/validation_rules.js +++ b/modules/ui/sections/validation_rules.js @@ -121,7 +121,7 @@ export function uiSectionValidationRules(context) { // user-configurable square threshold var degStr = prefs('validate-square-degrees'); if (degStr === null) { - degStr = '' + DEFAULTSQUARE; + degStr = DEFAULTSQUARE.toString(); } var span = items.selectAll('.square-degrees'); @@ -132,8 +132,8 @@ export function uiSectionValidationRules(context) { input.enter() .append('input') .attr('type', 'number') - .attr('min', '' + MINSQUARE) - .attr('max', '' + MAXSQUARE) + .attr('min', MINSQUARE.toString()) + .attr('max', MAXSQUARE.toString()) .attr('step', '0.5') .attr('class', 'square-degrees-input') .call(utilNoAuto) @@ -167,7 +167,7 @@ export function uiSectionValidationRules(context) { } degNum = Math.round(degNum * 10 ) / 10; // round to 1 decimal - degStr = '' + degNum; + degStr = degNum.toString(); input .property('value', degStr);