From 7b4c62d1c348bd22678931d9d0ef20b6c321dcec Mon Sep 17 00:00:00 2001 From: KernelDeimos <7225168+KernelDeimos@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:26:59 -0400 Subject: [PATCH] lint: minor formatting issue with `catch(e)` The custom eslint pluggin for the formatting rule I have for the expressions in control structures isn't a good fit when the condition is a single variable named by a single character. This happens a lot with `catch`. `catch ( e ) {` has too much spacing, but `catch (e) {` looks relatively normal. --- control-structure-spacing.js | 10 ++++++++++ extensions/whoami/routes.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/control-structure-spacing.js b/control-structure-spacing.js index 92e6f4dcf..7a25796af 100644 --- a/control-structure-spacing.js +++ b/control-structure-spacing.js @@ -46,6 +46,16 @@ export default { const afterOpen = sourceCode.getTokenAfter(openParen); const beforeClose = sourceCode.getTokenBefore(closeParen); + { + const contentBetweenParens = sourceCode.getText().slice(openParen.range[1], closeParen.range[0]); + const isSingleCharVariable = /^\s*[a-zA-Z_$]\s*$/.test(contentBetweenParens); + + // Skip spacing requirements for single character variables + if ( isSingleCharVariable ) { + return; + } + } + // Control structures should have spacing if ( afterOpen && openParen.range[1] === afterOpen.range[0] ) { context.report({ diff --git a/extensions/whoami/routes.js b/extensions/whoami/routes.js index b552fc699..1697c378e 100644 --- a/extensions/whoami/routes.js +++ b/extensions/whoami/routes.js @@ -47,7 +47,7 @@ const whoami_common = ({ is_user, user }) => { epoch = new Date(user.last_activity_ts).getTime(); // round to 1 decimal place epoch = Math.round(epoch / 1000); - } catch(e) { + } catch (e) { console.error('Error parsing last_activity_ts', e); }