mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-02 13:09:39 -05:00
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.
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user