diff --git a/airbyte-webapp/.eslintrc b/airbyte-webapp/.eslintrc deleted file mode 100644 index 42ab74d3eb6d..000000000000 --- a/airbyte-webapp/.eslintrc +++ /dev/null @@ -1,101 +0,0 @@ -{ - "extends": [ - "react-app", - "plugin:@typescript-eslint/recommended", - "plugin:jest/recommended", - "prettier", - "plugin:prettier/recommended", - "plugin:css-modules/recommended", - "plugin:jsx-a11y/recommended" - ], - "plugins": ["react", "@typescript-eslint", "prettier", "unused-imports", "css-modules", "jsx-a11y"], - "parserOptions": { - "ecmaVersion": 2020, - "sourceType": "module", - "ecmaFeatures": { - "jsx": true - } - }, - "rules": { - "jsx-a11y/label-has-associated-control": "error", - "curly": "warn", - "css-modules/no-undef-class": "off", - "css-modules/no-unused-class": ["error", { "camelCase": true }], - "dot-location": "warn", - "dot-notation": "warn", - "eqeqeq": "error", - "prettier/prettier": "warn", - "unused-imports/no-unused-imports": "warn", - "no-else-return": "warn", - "no-lonely-if": "warn", - "no-inner-declarations": "off", - "no-unused-vars": "off", - "no-useless-computed-key": "warn", - "no-useless-return": "warn", - "no-var": "warn", - "object-shorthand": ["warn", "always"], - "prefer-arrow-callback": "warn", - "prefer-const": "warn", - "prefer-destructuring": ["warn", { "AssignmentExpression": { "array": true } }], - "prefer-object-spread": "warn", - "prefer-template": "warn", - "spaced-comment": ["warn", "always", { "markers": ["/"] }], - "yoda": "warn", - "import/order": [ - "warn", - { - "newlines-between": "always", - "groups": ["type", "builtin", "external", "internal", ["parent", "sibling"], "index"], - "pathGroupsExcludedImportTypes": ["builtin"], - "pathGroups": [ - { - "pattern": "components{/**,}", - "group": "internal" - }, - { - "pattern": "+(config|core|hooks|locales|packages|pages|services|types|utils|views){/**,}", - "group": "internal", - "position": "after" - } - ], - "alphabetize": { - "order": "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */, - "caseInsensitive": true /* ignore case. Options: [true, false] */ - } - } - ], - "@typescript-eslint/array-type": ["warn", { "default": "array-simple" }], - "@typescript-eslint/ban-ts-comment": [ - "warn", - { - "ts-expect-error": "allow-with-description" - } - ], - "@typescript-eslint/ban-types": "warn", - "@typescript-eslint/consistent-indexed-object-style": ["warn", "record"], - "@typescript-eslint/consistent-type-definitions": ["warn", "interface"], - "@typescript-eslint/no-unused-vars": "warn", - "react/function-component-definition": [ - "warn", - { - "namedComponents": "arrow-function", - "unnamedComponents": "arrow-function" - } - ], - "jest/consistent-test-it": ["warn", { "fn": "it", "withinDescribe": "it" }], - "react/jsx-boolean-value": "warn", - "react/jsx-curly-brace-presence": "warn", - "react/jsx-fragments": "warn", - "react/jsx-no-useless-fragment": ["warn", { "allowExpressions": true }], - "react/self-closing-comp": "warn" - }, - "parser": "@typescript-eslint/parser", - "overrides": [ - { - "files": ["scripts/**/*"], - "rules": { - "@typescript-eslint/no-var-requires": "off" - } - } - ] -} diff --git a/airbyte-webapp/.eslintrc.js b/airbyte-webapp/.eslintrc.js new file mode 100644 index 000000000000..3b2ad8b82f07 --- /dev/null +++ b/airbyte-webapp/.eslintrc.js @@ -0,0 +1,114 @@ +module.exports = { + extends: [ + "react-app", + "plugin:@typescript-eslint/recommended", + "plugin:jest/recommended", + "prettier", + "plugin:prettier/recommended", + "plugin:css-modules/recommended", + "plugin:jsx-a11y/recommended", + ], + plugins: ["react", "@typescript-eslint", "prettier", "unused-imports", "css-modules", "jsx-a11y"], + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + rules: { + "jsx-a11y/label-has-associated-control": "error", + curly: "warn", + "css-modules/no-undef-class": "off", + "css-modules/no-unused-class": ["error", { camelCase: true }], + "dot-location": "warn", + "dot-notation": "warn", + eqeqeq: "error", + "prettier/prettier": "warn", + "unused-imports/no-unused-imports": "warn", + "no-else-return": "warn", + "no-lonely-if": "warn", + "no-inner-declarations": "off", + "no-unused-vars": "off", + "no-useless-computed-key": "warn", + "no-useless-return": "warn", + "no-var": "warn", + "object-shorthand": ["warn", "always"], + "prefer-arrow-callback": "warn", + "prefer-const": "warn", + "prefer-destructuring": ["warn", { AssignmentExpression: { array: true } }], + "prefer-object-spread": "warn", + "prefer-template": "warn", + "spaced-comment": ["warn", "always", { markers: ["/"] }], + yoda: "warn", + "import/order": [ + "warn", + { + "newlines-between": "always", + groups: ["type", "builtin", "external", "internal", ["parent", "sibling"], "index"], + pathGroupsExcludedImportTypes: ["builtin"], + pathGroups: [ + { + pattern: "components{/**,}", + group: "internal", + }, + { + pattern: "+(config|core|hooks|locales|packages|pages|services|types|utils|views){/**,}", + group: "internal", + position: "after", + }, + ], + alphabetize: { + order: "asc" /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */, + caseInsensitive: true /* ignore case. Options: [true, false] */, + }, + }, + ], + "@typescript-eslint/array-type": ["warn", { default: "array-simple" }], + "@typescript-eslint/ban-ts-comment": [ + "warn", + { + "ts-expect-error": "allow-with-description", + }, + ], + "@typescript-eslint/ban-types": "warn", + "@typescript-eslint/consistent-indexed-object-style": ["warn", "record"], + "@typescript-eslint/consistent-type-definitions": ["warn", "interface"], + "@typescript-eslint/no-unused-vars": "warn", + "react/function-component-definition": [ + "warn", + { + namedComponents: "arrow-function", + unnamedComponents: "arrow-function", + }, + ], + "jest/consistent-test-it": ["warn", { fn: "it", withinDescribe: "it" }], + "react/jsx-boolean-value": "warn", + "react/jsx-curly-brace-presence": "warn", + "react/jsx-fragments": "warn", + "react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }], + "react/self-closing-comp": "warn", + }, + parser: "@typescript-eslint/parser", + overrides: [ + { + files: ["scripts/**/*"], + rules: { + "@typescript-eslint/no-var-requires": "off", + }, + }, + { + // Only applies to files in src. Rules should be in here that are requiring type information + // and thus require the below parserOptions. + files: ["src/**/*"], + parserOptions: { + tsconfigRootDir: __dirname, + project: "./tsconfig.json", + }, + rules: { + "@typescript-eslint/await-thenable": "warn", + "@typescript-eslint/no-unnecessary-type-assertion": "warn", + }, + }, + ], +}; diff --git a/airbyte-webapp/build.gradle b/airbyte-webapp/build.gradle index 79d12834e23d..cb773a1d4542 100644 --- a/airbyte-webapp/build.gradle +++ b/airbyte-webapp/build.gradle @@ -22,7 +22,7 @@ node { npm_run_build { inputs.files commonConfigs - inputs.file '.eslintrc' + inputs.file '.eslintrc.js' inputs.dir 'public' inputs.dir 'src' diff --git a/airbyte-webapp/src/hooks/useLoadingState.tsx b/airbyte-webapp/src/hooks/useLoadingState.tsx index c5ab8a2e1001..cb002923d061 100644 --- a/airbyte-webapp/src/hooks/useLoadingState.tsx +++ b/airbyte-webapp/src/hooks/useLoadingState.tsx @@ -26,7 +26,7 @@ const useLoadingState = (): { setIsLoading(true); setShowFeedback(false); - await action(); + action(); setIsLoading(false); setShowFeedback(true); diff --git a/airbyte-webapp/src/hooks/useTypesafeReducer.ts b/airbyte-webapp/src/hooks/useTypesafeReducer.ts index 9cd34532496d..886c8860ddc2 100644 --- a/airbyte-webapp/src/hooks/useTypesafeReducer.ts +++ b/airbyte-webapp/src/hooks/useTypesafeReducer.ts @@ -13,7 +13,7 @@ function useTypesafeReducer { - const user = await this.getCurrentUser(); + const user = this.getCurrentUser(); if (user) { await this.reauthenticate(email, password); diff --git a/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/RemainingCredits.tsx b/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/RemainingCredits.tsx index 6a61d38c8248..7bee5c9ef446 100644 --- a/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/RemainingCredits.tsx +++ b/airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/RemainingCredits.tsx @@ -109,7 +109,7 @@ const RemainingCredits: React.FC = ({ selfServiceCheckoutEnabled }) => { successUrl: successUrl.href, cancelUrl: window.location.href, }); - await analytics.track(Namespace.CREDITS, Action.CHECKOUT_START, { + analytics.track(Namespace.CREDITS, Action.CHECKOUT_START, { actionDescription: "Checkout Start", }); // Forward to stripe as soon as we created a checkout session successfully diff --git a/airbyte-webapp/src/pages/DestinationPage/pages/CreateDestinationPage/components/DestinationForm.tsx b/airbyte-webapp/src/pages/DestinationPage/pages/CreateDestinationPage/components/DestinationForm.tsx index 3ed793080431..7820398759b0 100644 --- a/airbyte-webapp/src/pages/DestinationPage/pages/CreateDestinationPage/components/DestinationForm.tsx +++ b/airbyte-webapp/src/pages/DestinationPage/pages/CreateDestinationPage/components/DestinationForm.tsx @@ -73,7 +73,7 @@ export const DestinationForm: React.FC = ({ }; const onSubmitForm = async (values: { name: string; serviceType: string }) => { - await onSubmit({ + onSubmit({ ...values, destinationDefinitionId: destinationDefinitionSpecification?.destinationDefinitionId, }); diff --git a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnectorModal.tsx b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnectorModal.tsx index 61bbeb1c16e3..680f05e22dfd 100644 --- a/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnectorModal.tsx +++ b/airbyte-webapp/src/pages/SettingsPage/pages/ConnectorsPage/components/CreateConnectorModal.tsx @@ -117,8 +117,8 @@ const CreateConnectorModal: React.FC = ({ onClose, onSubmit, errorMessag validateOnBlur validateOnChange validationSchema={validationSchema} - onSubmit={async (values, { setSubmitting }) => { - await onSubmit(values); + onSubmit={(values, { setSubmitting }) => { + onSubmit(values); setSubmitting(false); }} > diff --git a/airbyte-webapp/src/pages/SettingsPage/pages/NotificationPage/components/WebHookForm.tsx b/airbyte-webapp/src/pages/SettingsPage/pages/NotificationPage/components/WebHookForm.tsx index 9027b267fc9c..bfb6bdeb2f1b 100644 --- a/airbyte-webapp/src/pages/SettingsPage/pages/NotificationPage/components/WebHookForm.tsx +++ b/airbyte-webapp/src/pages/SettingsPage/pages/NotificationPage/components/WebHookForm.tsx @@ -97,11 +97,11 @@ const WebHookForm: React.FC = ({ webhook, onSubmit, successMes validateOnBlur validateOnChange={false} validationSchema={webhookValidationSchema} - onSubmit={async (values: WebhookPayload) => { + onSubmit={(values: WebhookPayload) => { if (equal(webhook, values)) { - await onTest(values); + onTest(values); } else { - await onSubmit(values); + onSubmit(values); } }} > diff --git a/airbyte-webapp/src/pages/SourcesPage/pages/CreateSourcePage/components/SourceForm.tsx b/airbyte-webapp/src/pages/SourcesPage/pages/CreateSourcePage/components/SourceForm.tsx index 83005ce12988..3715618b0c1e 100644 --- a/airbyte-webapp/src/pages/SourcesPage/pages/CreateSourcePage/components/SourceForm.tsx +++ b/airbyte-webapp/src/pages/SourcesPage/pages/CreateSourcePage/components/SourceForm.tsx @@ -69,8 +69,8 @@ export const SourceForm: React.FC = ({ }); }; - const onSubmitForm = async (values: ServiceFormValues) => { - await onSubmit({ + const onSubmitForm = (values: ServiceFormValues) => { + onSubmit({ ...values, sourceDefinitionId: sourceDefinitionSpecification?.sourceDefinitionId, }); diff --git a/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx b/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx index ebde26c29202..8a7010a58300 100644 --- a/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx +++ b/airbyte-webapp/src/services/workspaces/WorkspacesService.tsx @@ -38,7 +38,7 @@ const useSelectWorkspace = (): ((workspace?: string | null | Workspace) => void) } else { navigate(`/${RoutePaths.Workspaces}/${workspace}`); } - await queryClient.removeQueries(SCOPE_WORKSPACE); + queryClient.removeQueries(SCOPE_WORKSPACE); }, [navigate, queryClient] ); diff --git a/airbyte-webapp/src/test-utils/testutils.tsx b/airbyte-webapp/src/test-utils/testutils.tsx index f330e0cb569b..77172f9af3bb 100644 --- a/airbyte-webapp/src/test-utils/testutils.tsx +++ b/airbyte-webapp/src/test-utils/testutils.tsx @@ -50,7 +50,7 @@ export async function render< let renderResult: RenderResult; await act(async () => { - renderResult = await rtlRender(
{ui}
, { wrapper: Wrapper, ...renderOptions }); + renderResult = rtlRender(
{ui}
, { wrapper: Wrapper, ...renderOptions }); }); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx b/airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx index 4228ed84afcc..afad0341865a 100644 --- a/airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx +++ b/airbyte-webapp/src/views/Connector/ConnectorCard/ConnectorCard.tsx @@ -89,7 +89,7 @@ export const ConnectorCard: React.FC = (props) => { ); const onFormSubmit = useCallback( - async (values: ServiceFormValues) => { + (values: ServiceFormValues) => { const valuesToSend = getValues(values); - await onSubmit(valuesToSend); + onSubmit(valuesToSend); clearFormChange(formId); }, diff --git a/airbyte-webapp/src/views/Connector/ServiceForm/components/Sections/auth/useOauthFlowAdapter.tsx b/airbyte-webapp/src/views/Connector/ServiceForm/components/Sections/auth/useOauthFlowAdapter.tsx index 72c35e878ac3..0c4ce0f4eb8d 100644 --- a/airbyte-webapp/src/views/Connector/ServiceForm/components/Sections/auth/useOauthFlowAdapter.tsx +++ b/airbyte-webapp/src/views/Connector/ServiceForm/components/Sections/auth/useOauthFlowAdapter.tsx @@ -87,7 +87,7 @@ function useFormikOauthAdapter(connector: ConnectorDefinitionSpecification): { return acc; }, {} as Record); - await run(oauthInputParams); + run(oauthInputParams); }, }; } diff --git a/airbyte-webapp/src/views/Settings/PreferencesForm/PreferencesForm.tsx b/airbyte-webapp/src/views/Settings/PreferencesForm/PreferencesForm.tsx index d286eaa5adea..bac20190b0aa 100644 --- a/airbyte-webapp/src/views/Settings/PreferencesForm/PreferencesForm.tsx +++ b/airbyte-webapp/src/views/Settings/PreferencesForm/PreferencesForm.tsx @@ -83,8 +83,8 @@ const PreferencesForm: React.FC = ({ validateOnBlur validateOnChange={false} validationSchema={preferencesValidationSchema} - onSubmit={async (values) => { - await onSubmit(values); + onSubmit={(values) => { + onSubmit(values); }} > {({ isSubmitting, values, handleChange, setFieldValue, resetForm, isValid, dirty }) => (