From 6e057f07f9371b5b27dc35e989d6e6155d63f283 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 4 May 2023 23:45:03 -0400 Subject: [PATCH] Add prefer string starts/ends with eslint rule --- .eslintrc.js | 3 ++- src/components/metadataEditor/metadataEditor.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c089d3ac0e..c1a86d8904 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -245,7 +245,8 @@ module.exports = { 'Windows': 'readonly' }, rules: { - '@typescript-eslint/no-floating-promises': ['warn'] + '@typescript-eslint/no-floating-promises': ['warn'], + '@typescript-eslint/prefer-string-starts-ends-with': ['error'] } }, // TypeScript source files diff --git a/src/components/metadataEditor/metadataEditor.js b/src/components/metadataEditor/metadataEditor.js index dfe7a99237..b21c615cdd 100644 --- a/src/components/metadataEditor/metadataEditor.js +++ b/src/components/metadataEditor/metadataEditor.js @@ -108,7 +108,7 @@ function getDateValue(form, element, property) { const parts = date.toISOString().split('T'); // If the date is the same, preserve the time - if (parts[0].indexOf(val) === 0) { + if (parts[0].startsWith(val)) { const iso = parts[1]; val += 'T' + iso;