From 2a7d66b9f7aafbafab4a507fa340bcc8c1238e58 Mon Sep 17 00:00:00 2001 From: Nafis Zaman Date: Fri, 16 Aug 2024 19:15:53 -0700 Subject: [PATCH] Update eslint rules to match Simulator repo --- .eslintrc.js | 44 ++++++++++++++++++++++++++++++++++++++------ src/index.ts | 6 +++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2585557..a64163f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,10 +6,8 @@ module.exports = { }, extends: [ "eslint:recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:import/typescript", "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", ], parser: "@typescript-eslint/parser", parserOptions: { @@ -24,8 +22,42 @@ module.exports = { "import", ], rules: { - "import/no-unresolved": 0, - "indent": ["error", 2], - "object-curly-spacing": ["error", "always"], + // Project-specific ESLint rules + 'array-bracket-spacing': 'error', + 'arrow-spacing': 'error', + 'brace-style': ['error', '1tbs', { 'allowSingleLine': true }], + 'comma-style': 'error', + 'eqeqeq': 'error', + 'indent': ['error', 2, { 'SwitchCase': 1 }], + 'keyword-spacing': 'error', + 'newline-per-chained-call': 'error', + 'no-confusing-arrow': 'error', + 'no-duplicate-imports': 'error', + 'no-else-return': 'error', + 'no-new-wrappers': 'error', + 'no-param-reassign': 'error', + 'no-useless-constructor': 'error', + 'no-whitespace-before-property': 'error', + 'nonblock-statement-body-position': 'error', + 'object-curly-spacing': ['error', 'always'], + 'operator-linebreak': 'error', + 'prefer-arrow-callback': 'error', + 'prefer-const': 'error', + 'prefer-template': 'error', + 'semi': 'error', + 'space-before-blocks': 'error', + 'space-before-function-paren': ['error', { 'named': 'never' }], + 'space-in-parens': 'error', + 'space-infix-ops': 'error', + 'spaced-comment': 'error', + 'template-curly-spacing': 'error', + + // Project-specific ESLint rules for TypeScript + '@typescript-eslint/type-annotation-spacing': 'error', + '@typescript-eslint/prefer-for-of': 'error', + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/explicit-module-boundary-types' : 'off', + '@typescript-eslint/no-floating-promises': ['error', { ignoreIIFE: true }], + '@typescript-eslint/no-unused-vars': ['off'], }, }; diff --git a/src/index.ts b/src/index.ts index 9764634..3af8620 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,7 +41,7 @@ export const unconsentedUserCleanup = onSchedule("every 5 mins", async (event) = logger.info('Processing user', { userId: userId }); // Parse the "sent at" field - const sentAtString = doc.get('legalAcceptance.sentAt'); + const sentAtString: unknown = doc.get('legalAcceptance.sentAt'); if (!sentAtString || typeof sentAtString !== 'string') { logger.error(`'sentAt' string field does not exist in user doc. Skipping user`, { userId: userId }); continue; @@ -69,7 +69,7 @@ export const unconsentedUserCleanup = onSchedule("every 5 mins", async (event) = // if (e && typeof e === 'object' && 'code' in e && e.code === 'auth/user-not-found') { // logger.warn('Failed to delete user because user was not found. Proceeding anyway', { userId: userId }); // } else { - // logger.error(`Failed to delete user: ${e}`, { userId: userId }); + // logger.error(`Failed to delete user: ${JSON.stringify(e)}`, { userId: userId }); // continue; // } // } @@ -79,7 +79,7 @@ export const unconsentedUserCleanup = onSchedule("every 5 mins", async (event) = // await doc.ref.delete(); // logger.info('Successfully deleted doc for user', { userId: userId }); // } catch (e) { - // logger.error(`Failed to delete doc: ${e}`, { userId: userId }); + // logger.error(`Failed to delete doc: ${JSON.stringify(e)}`, { userId: userId }); // continue; // }