From 90b23ac7d1793d67a861e33d609c8637cc855711 Mon Sep 17 00:00:00 2001 From: arunachalam Date: Thu, 25 Jul 2024 15:30:36 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=95=20add=20if=20to=20be=20block,=20se?= =?UTF-8?q?t=20max=20width=20of=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/eslint-config-base/index.js | 69 +++++++++++-------- packages/analytics/src/adapters/adapter.ts | 3 +- .../src/components/DynamicSVG/DynamicSVG.tsx | 3 +- .../src/components/DynamicSVG/hooks/types.ts | 4 +- .../src/components/InspectionGallery/types.ts | 7 +- .../VehicleDynamicWireframe.tsx | 3 +- packages/common/src/PreventExit/store.ts | 3 +- packages/network/src/api/react.ts | 14 ++-- packages/sights/test/build/buildJSON.test.ts | 3 +- packages/types/src/config.ts | 14 ++-- 10 files changed, 72 insertions(+), 51 deletions(-) diff --git a/configs/eslint-config-base/index.js b/configs/eslint-config-base/index.js index 270606fe6..5cf7d21f3 100644 --- a/configs/eslint-config-base/index.js +++ b/configs/eslint-config-base/index.js @@ -5,50 +5,63 @@ const ERROR = 2; module.exports = { root: true, extends: [ - 'airbnb-base', - 'eslint:recommended', - 'plugin:jest/recommended', - 'plugin:import/recommended', - 'plugin:import/errors', - 'plugin:import/warnings', - 'plugin:prettier/recommended', - 'plugin:promise/recommended', + "airbnb-base", + "eslint:recommended", + "plugin:jest/recommended", + "plugin:import/recommended", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:prettier/recommended", + "plugin:promise/recommended", ], - plugins: ['import', 'prettier', 'jest'], + plugins: ["import", "prettier", "jest"], env: { browser: true, es6: true, jest: true, }, settings: { - 'import/resolver': { + "import/resolver": { node: { - extensions: ['.js', '.jsx'], + extensions: [".js", ".jsx"], }, }, }, rules: { - 'prettier/prettier': ERROR, - 'import/prefer-default-export': OFF, - 'import/extensions': OFF, - 'promise/always-return': OFF, - 'no-plusplus': [ERROR, { allowForLoopAfterthoughts: true }], - 'lines-between-class-members': OFF, - 'dot-notation': OFF, - 'indent': OFF, - 'promise/catch-or-return': [ERROR, { allowFinally: true }], - 'import/no-unresolved': [ERROR, { caseSensitive: false }], - 'jest/no-mocks-import': OFF, - 'jest/expect-expect': OFF, + "prettier/prettier": ERROR, + "import/prefer-default-export": OFF, + "import/extensions": OFF, + "promise/always-return": OFF, + "no-plusplus": [ERROR, { allowForLoopAfterthoughts: true }], + "lines-between-class-members": OFF, + "dot-notation": OFF, + indent: OFF, + curly: [ERROR, "all"], + "max-len": [ + ERROR, + { + code: 120, + comments: 120, + ignoreUrls: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + ignoreRegExpLiterals: true, + }, + ], + "capitalized-comments": [ERROR], + "promise/catch-or-return": [ERROR, { allowFinally: true }], + "import/no-unresolved": [ERROR, { caseSensitive: false }], + "jest/no-mocks-import": OFF, + "jest/expect-expect": OFF, }, overrides: [ { - files: ['test/**/*.{js,jsx}'], + files: ["test/**/*.{js,jsx}"], rules: { - 'import/first': OFF, - 'import/order': OFF, - '@typescript-eslint/no-empty-function': OFF, - 'class-methods-use-this': OFF, + "import/first": OFF, + "import/order": OFF, + "@typescript-eslint/no-empty-function": OFF, + "class-methods-use-this": OFF, }, }, ], diff --git a/packages/analytics/src/adapters/adapter.ts b/packages/analytics/src/adapters/adapter.ts index bf1648034..5b087c195 100644 --- a/packages/analytics/src/adapters/adapter.ts +++ b/packages/analytics/src/adapters/adapter.ts @@ -24,7 +24,8 @@ export interface AnalyticsAdapter { resetUser: () => void; /** * Track an event. - * We recommend using the '[object][verb]' format for your event names, where '[object]' is the entity that the behavior relates to, and '[verb]' is the behavior itself. + * We recommend using the '[object][verb]' format for your event names, where '[object]' is the entity that the + * behavior relates to, and '[verb]' is the behavior itself. * For example: `Project Created`, `User Signed Up`, or `Invite Sent`. * * @param name The name of the event. diff --git a/packages/common-ui-web/src/components/DynamicSVG/DynamicSVG.tsx b/packages/common-ui-web/src/components/DynamicSVG/DynamicSVG.tsx index 10af251a1..64747475e 100644 --- a/packages/common-ui-web/src/components/DynamicSVG/DynamicSVG.tsx +++ b/packages/common-ui-web/src/components/DynamicSVG/DynamicSVG.tsx @@ -27,7 +27,8 @@ export interface DynamicSVGProps * import React, { useCallback } from 'react'; * import { DynamicSVG } from '@monkvision/common-ui-web'; * - * const svg = ''; + * const svg = ` + * `; * * // Applies a red fill and an onClick handler on the element with ID "circle1" * function MyCustomSVG() { diff --git a/packages/common-ui-web/src/components/DynamicSVG/hooks/types.ts b/packages/common-ui-web/src/components/DynamicSVG/hooks/types.ts index 1695c5bef..30c25fc9e 100644 --- a/packages/common-ui-web/src/components/DynamicSVG/hooks/types.ts +++ b/packages/common-ui-web/src/components/DynamicSVG/hooks/types.ts @@ -6,8 +6,8 @@ import { SVGProps } from 'react'; */ export interface DynamicSVGCustomizationFunctions { /** - * A callback used to customize SVG tags in a DynamicSVG component based on the HTMLElement itself, or the Elements of the - * groups this element is part of. + * A callback used to customize SVG tags in a DynamicSVG component based on the HTMLElement itself, or the Elements + * of the groups this element is part of. * * @param element The element to apply the custom attributes to. * @param groups SVG group elements this element is part of (the elements are in order). diff --git a/packages/common-ui-web/src/components/InspectionGallery/types.ts b/packages/common-ui-web/src/components/InspectionGallery/types.ts index f8514a6e4..aabce510d 100644 --- a/packages/common-ui-web/src/components/InspectionGallery/types.ts +++ b/packages/common-ui-web/src/components/InspectionGallery/types.ts @@ -104,7 +104,8 @@ export type InspectionGalleryProps = { */ onValidate?: () => void; /** - * Boolean indicating if `Add Damage` feature should be enabled or not. If disabled, the `Add Custom Damage` button will be hidden. + * Boolean indicating if `Add Damage` feature should be enabled or not. If disabled, the `Add Custom Damage` button + * will be hidden. * * @default true */ @@ -127,8 +128,8 @@ export type InspectionGalleryProps = { */ sights: Sight[]; /** - * Boolean indicating if the user should be allowed to skip the retaking of non-compliant pictures before validating - * the inspection. This prop can only be specified if `captureMode` is set to true. + * Boolean indicating if the user should be allowed to skip the retaking of non-compliant pictures before + * validating the inspection. This prop can only be specified if `captureMode` is set to true. * * @default false */ diff --git a/packages/common-ui-web/src/components/VehicleDynamicWireframe/VehicleDynamicWireframe.tsx b/packages/common-ui-web/src/components/VehicleDynamicWireframe/VehicleDynamicWireframe.tsx index d0e89fabc..74a92ab6f 100644 --- a/packages/common-ui-web/src/components/VehicleDynamicWireframe/VehicleDynamicWireframe.tsx +++ b/packages/common-ui-web/src/components/VehicleDynamicWireframe/VehicleDynamicWireframe.tsx @@ -29,7 +29,8 @@ export interface VehicleDynamicWireframeProps { */ onClickPart?: (parts: VehiclePart) => void; /** - * Callback used to customize the display style of each vehicle part on the wireframe. See `DynamicSVGCustomizationFunctions` for more details. + * Callback used to customize the display style of each vehicle part on the wireframe. + * See `DynamicSVGCustomizationFunctions` for more details. * * @see DynamicSVGCustomizationFunctions */ diff --git a/packages/common/src/PreventExit/store.ts b/packages/common/src/PreventExit/store.ts index 5b71caee7..2df92544c 100644 --- a/packages/common/src/PreventExit/store.ts +++ b/packages/common/src/PreventExit/store.ts @@ -11,11 +11,12 @@ function arePreventExitRemaining(): boolean { function publish(id: symbol, preventExit: boolean): void { allPreventExitState[id] = preventExit; - if (!arePreventExitRemaining()) + if (!arePreventExitRemaining()) { window.onbeforeunload = (e) => { e.preventDefault(); return 'prevent-exit'; }; + } } /** diff --git a/packages/network/src/api/react.ts b/packages/network/src/api/react.ts index da5afef92..9024ef5f8 100644 --- a/packages/network/src/api/react.ts +++ b/packages/network/src/api/react.ts @@ -72,19 +72,19 @@ export function useMonkApi(config: MonkApiConfig) { /** * Update the progress status of an inspection task. * - * **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry config - * to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total), with - * exponentially increasing delay between each request (max delay : 1.5s).** + * **Note : This API call is known to sometimes fail for unknown reasons. In order to fix this, we added a retry + * config to this API request : when failing, this request will retry itself up to 4 times (5 API calls in total), + * with exponentially increasing delay between each request (max delay : 1.5s).** * * @param options The options of the request. */ updateTaskStatus: reactify(MonkApi.updateTaskStatus, config, dispatch, handleError), /** - * Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for each - * task provided using the `updateTaskStatus`. + * Start some inspection tasks that were in the NOT_STARTED status. This function actually makes one API call for + * each task provided using the `updateTaskStatus`. * - * **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided in - * the TSDoc of the `updateTaskStatus` function.** + * **Note : This API call is known to sometimes fail for unknown reasons. Please take note of the details provided + * in the TSDoc of the `updateTaskStatus` function.** * * @param options The options of the request. * diff --git a/packages/sights/test/build/buildJSON.test.ts b/packages/sights/test/build/buildJSON.test.ts index 833090ed2..b4da0bb4c 100644 --- a/packages/sights/test/build/buildJSON.test.ts +++ b/packages/sights/test/build/buildJSON.test.ts @@ -240,8 +240,9 @@ describe('JSON builder module', () => { fs.readFileSync = jest .fn() .mockImplementation((path: string, options?: { encoding: BufferEncoding }) => { - if (path.endsWith(`vehicle-key-2-${PartSelectionOrientation.FRONT_LEFT}.svg`)) + if (path.endsWith(`vehicle-key-2-${PartSelectionOrientation.FRONT_LEFT}.svg`)) { throw new Error('File Not found'); + } if (options?.encoding === 'utf-8') { return ` ${resolve(path)} `; } diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index eef9dabd7..8d2b04281 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -50,8 +50,8 @@ export type CaptureAppConfig = CameraConfig & /** * Value indicating if tasks should be started at the end of the inspection : * - If not provided or if value is set to `false`, no tasks will be started. - * - If set to `true`, the tasks described by the `tasksBySight` param (or, if not provided, the default tasks of each - * sight) will be started. + * - If set to `true`, the tasks described by the `tasksBySight` param (or, if not provided, the default tasks of + * each sight) will be started. * - If an array of tasks is provided, the tasks started will be the ones contained in the array. * * @default true @@ -88,7 +88,8 @@ export type CaptureAppConfig = CameraConfig & */ allowSkipRetake?: boolean; /** - * Boolean indicating if `Add Damage` feature should be enabled or not. If disabled, the `Add Damage` button will be hidden. + * Boolean indicating if `Add Damage` feature should be enabled or not. If disabled, the `Add Damage` button will + * be hidden. * * @default true */ @@ -98,7 +99,8 @@ export type CaptureAppConfig = CameraConfig & */ sightGuidelines?: SightGuideline[]; /** - * Boolean indicating whether the sight guideline feature is enabled. If disabled, the guideline text will be hidden. + * Boolean indicating whether the sight guideline feature is enabled. If disabled, the guideline text will be + * hidden. * * @default true */ @@ -116,8 +118,8 @@ export type CaptureAppConfig = CameraConfig & */ allowVehicleTypeSelection: boolean; /** - * Boolean indicating if the application state (such as auth token, inspection ID etc.) should be fetched from the URL - * search params or not. + * Boolean indicating if the application state (such as auth token, inspection ID etc.) should be fetched from the + * URL search params or not. */ fetchFromSearchParams: boolean; /**