From 68fbed3f28c0d74830a69d06d5a23fd3ff2216b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 26 Aug 2024 11:07:53 +0200 Subject: [PATCH] Fix or ignore new checks errors --- .eslintrc.yaml | 5 +++++ buildtools/codeshift-js2ts.js | 2 +- buildtools/svg-viewbox-loader.js | 1 + src/controllers/bootstrap.js | 2 +- src/e2e/mobile.spec.ts | 2 +- src/lidar/Manager.ts | 3 ++- src/lidar/PanelElement.ts | 2 +- src/lidar/Plot.ts | 2 +- src/message/Disclaimer.js | 2 +- src/message/Notification.ts | 8 ++++---- src/message/Notification_OLD.js | 8 ++++---- src/misc/php-date-formatter.js | 2 +- src/profile/d3Elevation.ts | 4 ++-- src/query/Querent.js | 4 ++-- webpack.config.js | 2 ++ 15 files changed, 29 insertions(+), 20 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ff099a0e6559..ef7ce9420208 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -59,6 +59,11 @@ rules: '@typescript-eslint/no-misused-promises': warn '@typescript-eslint/require-await': warn '@typescript-eslint/no-unsafe-argument': warn + '@typescript-eslint/no-unused-vars': warn + '@typescript-eslint/no-unused-expressions': warn + '@typescript-eslint/prefer-promise-reject-errors': warn + # TODO: Remove before release 2.9 + '@typescript-eslint/no-require-imports': warn '@typescript-eslint/no-useless-constructor': error '@typescript-eslint/prefer-for-of': error '@typescript-eslint/prefer-includes': error diff --git a/buildtools/codeshift-js2ts.js b/buildtools/codeshift-js2ts.js index 8f7459ae5d35..b7aaa5a17e55 100644 --- a/buildtools/codeshift-js2ts.js +++ b/buildtools/codeshift-js2ts.js @@ -566,7 +566,7 @@ function visit(indent, node, call) { if (!done) { console.log('Unknown node type'); console.log(node); - throw 'Unknown node type'; + throw new Error('Unknown node type'); } } diff --git a/buildtools/svg-viewbox-loader.js b/buildtools/svg-viewbox-loader.js index 51d75c79f638..39e91b948e3b 100644 --- a/buildtools/svg-viewbox-loader.js +++ b/buildtools/svg-viewbox-loader.js @@ -41,6 +41,7 @@ module.exports = function (source) { let tokens = simpleHTMLTokenizer.tokenize(source); tokens = tokens.map((tag) => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison if (tag.type === 'StartTag' && tag.tagName === 'svg') { let width = undefined; let height = undefined; diff --git a/src/controllers/bootstrap.js b/src/controllers/bootstrap.js index fa0f6650f5c5..fcae74d49ff6 100644 --- a/src/controllers/bootstrap.js +++ b/src/controllers/bootstrap.js @@ -112,7 +112,7 @@ function bootstrap(module) { angular.bootstrap(document, [appName]); }) .catch((error) => { - window.alert(`Failed to get the dynamic: ${error}`); + window.alert(`Failed to get the dynamic: ${error}`); // eslint-disable-line @typescript-eslint/no-base-to-string }); } diff --git a/src/e2e/mobile.spec.ts b/src/e2e/mobile.spec.ts index b582f64fafca..735d0b639bee 100644 --- a/src/e2e/mobile.spec.ts +++ b/src/e2e/mobile.spec.ts @@ -464,7 +464,7 @@ if (Cypress.browser.isHeaded) { cy.wrap(btn) .click({force: true}) .then((btn) => { - expect(btn).to.not.be.visible; + expect(btn).to.not.be.visible; // eslint-disable-line @typescript-eslint/no-unused-expressions // Check the placeholder cy.get('.tt-input').should('have.attr', 'placeholder', 'Search…'); diff --git a/src/lidar/Manager.ts b/src/lidar/Manager.ts index 7861c9b864a3..f503b2edd67b 100644 --- a/src/lidar/Manager.ts +++ b/src/lidar/Manager.ts @@ -421,7 +421,7 @@ export class LidarprofileManager { this.processBuffer_(data, iter, distanceOffset, lastLOD, resetPlot); }) .catch((err: Error) => { - throw `Error on pytree query: ${err.message}`; + throw new Error(`Error on pytree query: ${err.message}`); }); } @@ -470,6 +470,7 @@ export class LidarprofileManager { try { JSON.parse(strHeaderLocal); + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { if (!this.isPlotSetup_) { const canvas: any = d3select(lidarContainerElement.querySelector('.lidar-canvas')); diff --git a/src/lidar/PanelElement.ts b/src/lidar/PanelElement.ts index c51a3d375c04..dfe6e537ee87 100644 --- a/src/lidar/PanelElement.ts +++ b/src/lidar/PanelElement.ts @@ -257,7 +257,7 @@ export default class GmfLidarPanel extends ToolPanelElement { * @param key The key string of the toggled classification. */ toggleVisibility(classification: LidarprofileServerConfigClassification, key: string): void { - classification.visible === 0 ? (classification.visible = 1) : (classification.visible = 0); + classification.visible = classification.visible === 0 ? 1 : 0; this.setClassification(classification, parseInt(key)); } diff --git a/src/lidar/Plot.ts b/src/lidar/Plot.ts index eca67d79d0ed..7fa89435c2d3 100644 --- a/src/lidar/Plot.ts +++ b/src/lidar/Plot.ts @@ -502,7 +502,7 @@ export default class { source.clear(); const lidarPointGeom = new olGeomPoint([p.coords[0], p.coords[1]]); const lidarPointFeature = new olFeature(lidarPointGeom); - if (typeof pointClassification.color !== undefined) { + if (pointClassification.color !== undefined) { lidarPointFeature.setStyle( new olStyleStyle({ image: new olStyleCircle({ diff --git a/src/message/Disclaimer.js b/src/message/Disclaimer.js index e5b725c663ff..5bd6d4145c47 100644 --- a/src/message/Disclaimer.js +++ b/src/message/Disclaimer.js @@ -337,7 +337,7 @@ export class MessageDisclaimerService extends ngeoMessageMessage { jqueryObj.alert('close'); } } else { - console.log(`No disclaimer found for '${message}'.`); + console.log(`No disclaimer found for '${message.msg}'.`); } // (3) Remove message from cache since it's closed now. diff --git a/src/message/Notification.ts b/src/message/Notification.ts index bf132a7a42c7..e7da20d904df 100644 --- a/src/message/Notification.ts +++ b/src/message/Notification.ts @@ -106,16 +106,16 @@ export class MessageNotification extends ngeoMessageMessage { const classNames = ['alert', 'fade', 'show']; switch (type) { - case MessageType.ERROR: + case MessageType.ERROR: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-danger'); break; - case MessageType.INFORMATION: + case MessageType.INFORMATION: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-info'); break; - case MessageType.SUCCESS: + case MessageType.SUCCESS: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-success'); break; - case MessageType.WARNING: + case MessageType.WARNING: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-warning'); break; default: diff --git a/src/message/Notification_OLD.js b/src/message/Notification_OLD.js index 6c1198944a1a..3ce85091931a 100644 --- a/src/message/Notification_OLD.js +++ b/src/message/Notification_OLD.js @@ -109,16 +109,16 @@ export class MessageNotification extends ngeoMessageMessage { const classNames = ['alert', 'fade', 'show']; switch (type) { - case MessageType.ERROR: + case MessageType.ERROR: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-danger'); break; - case MessageType.INFORMATION: + case MessageType.INFORMATION: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-info'); break; - case MessageType.SUCCESS: + case MessageType.SUCCESS: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-success'); break; - case MessageType.WARNING: + case MessageType.WARNING: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison classNames.push('alert-warning'); break; default: diff --git a/src/misc/php-date-formatter.js b/src/misc/php-date-formatter.js index 1227ff0efa49..145634cb325c 100644 --- a/src/misc/php-date-formatter.js +++ b/src/misc/php-date-formatter.js @@ -79,7 +79,7 @@ function _compare(str1, str2) { * @returns {string} */ function _lpad(value, length, chr) { - const val = value.toString(); + const val = value.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string chr = chr || '0'; return val.length < length ? _lpad(chr + val, length) : val; } diff --git a/src/profile/d3Elevation.ts b/src/profile/d3Elevation.ts index c38f0dfd7da9..3eb04507cbe3 100644 --- a/src/profile/d3Elevation.ts +++ b/src/profile/d3Elevation.ts @@ -337,7 +337,7 @@ function d3Elevation( .attr('dy', '.75em') .attr('transform', 'rotate(-90)') .style('fill', 'grey') - .text(`${yAxisLabel} [m]`); // eslint-disable-line @typescript-eslint/restrict-template-expressions + .text(`${yAxisLabel} [m]`); // eslint-disable-line @typescript-eslint/restrict-template-expressions,@typescript-eslint/no-base-to-string gEnter .append('g') @@ -447,7 +447,7 @@ function d3Elevation( g.select('.x.axis').transition().call(xAxis); g.select('.x.label') - .text(`${xAxisLabel} [${xUnits}]`) // eslint-disable-line @typescript-eslint/restrict-template-expressions + .text(`${xAxisLabel} [${xUnits}]`) // eslint-disable-line @typescript-eslint/restrict-template-expressions,@typescript-eslint/no-base-to-string .style('fill', 'grey') .style('shape-rendering', 'crispEdges'); diff --git a/src/query/Querent.js b/src/query/Querent.js index 1bfab83960c8..ec6223944339 100644 --- a/src/query/Querent.js +++ b/src/query/Querent.js @@ -265,8 +265,8 @@ export class Querent { */ wfsDescribeFeatureType(dataSource) { if (!dataSource.supportsAttributes) { - throw `The data source must support WFS, have a single OGCLayer that - is queryable in order to issue WFS DescribeFeatureType requests`; + throw new Error(`The data source must support WFS, have a single OGCLayer that + is queryable in order to issue WFS DescribeFeatureType requests`); } if (!dataSource.wfsUrl) { throw new Error('Missing WFS URL'); diff --git a/webpack.config.js b/webpack.config.js index 05a27404bceb..512a53c30a6c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -19,6 +19,8 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/* eslint-disable @typescript-eslint/no-require-imports */ + const {merge} = require('webpack-merge'); module.exports = (env, args) => {