Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🔧 Add additional eslint rules #17348

Merged
merged 6 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions airbyte-webapp/.eslintrc

This file was deleted.

114 changes: 114 additions & 0 deletions airbyte-webapp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -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",
},
},
],
};
2 changes: 1 addition & 1 deletion airbyte-webapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ node {

npm_run_build {
inputs.files commonConfigs
inputs.file '.eslintrc'
inputs.file '.eslintrc.js'
inputs.dir 'public'
inputs.dir 'src'

Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/hooks/useLoadingState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const useLoadingState = (): {
setIsLoading(true);
setShowFeedback(false);

await action();
action();

setIsLoading(false);
setShowFeedback(true);
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/hooks/useTypesafeReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function useTypesafeReducer<StateShape, Actions extends Record<string, (...args:
return function (this: any) {
return dispatcher(
// eslint-disable-next-line prefer-rest-params
actionCreator.apply(this as any, arguments as any as any[])
actionCreator.apply(this, arguments as any as any[])
);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class GoogleAuthService {
}

async updateEmail(email: string, password: string): Promise<void> {
const user = await this.getCurrentUser();
const user = this.getCurrentUser();

if (user) {
await this.reauthenticate(email, password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const RemainingCredits: React.FC<Props> = ({ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const DestinationForm: React.FC<DestinationFormProps> = ({
};

const onSubmitForm = async (values: { name: string; serviceType: string }) => {
await onSubmit({
onSubmit({
...values,
destinationDefinitionId: destinationDefinitionSpecification?.destinationDefinitionId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ const CreateConnectorModal: React.FC<IProps> = ({ onClose, onSubmit, errorMessag
validateOnBlur
validateOnChange
validationSchema={validationSchema}
onSubmit={async (values, { setSubmitting }) => {
await onSubmit(values);
onSubmit={(values, { setSubmitting }) => {
onSubmit(values);
setSubmitting(false);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ const WebHookForm: React.FC<WebHookFormProps> = ({ 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);
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export const SourceForm: React.FC<SourceFormProps> = ({
});
};

const onSubmitForm = async (values: ServiceFormValues) => {
await onSubmit({
const onSubmitForm = (values: ServiceFormValues) => {
onSubmit({
...values,
sourceDefinitionId: sourceDefinitionSpecification?.sourceDefinitionId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/test-utils/testutils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function render<

let renderResult: RenderResult<Q, Container>;
await act(async () => {
renderResult = await rtlRender<Q, Container>(<div>{ui}</div>, { wrapper: Wrapper, ...renderOptions });
renderResult = rtlRender<Q, Container>(<div>{ui}</div>, { wrapper: Wrapper, ...renderOptions });
timroes marked this conversation as resolved.
Show resolved Hide resolved
});

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const ConnectorCard: React.FC<ConnectorCardCreateProps | ConnectorCardEdi

try {
await testConnectorWithTracking();
await onSubmit(values);
onSubmit(values);
setSaved(true);
} catch (e) {
setErrorStatusRequest(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ const ServiceForm: React.FC<ServiceFormProps> = (props) => {
);

const onFormSubmit = useCallback(
async (values: ServiceFormValues) => {
(values: ServiceFormValues) => {
const valuesToSend = getValues(values);
await onSubmit(valuesToSend);
onSubmit(valuesToSend);

clearFormChange(formId);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function useFormikOauthAdapter(connector: ConnectorDefinitionSpecification): {
return acc;
}, {} as Record<string, unknown>);

await run(oauthInputParams);
run(oauthInputParams);
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const PreferencesForm: React.FC<PreferencesFormProps> = ({
validateOnBlur
validateOnChange={false}
validationSchema={preferencesValidationSchema}
onSubmit={async (values) => {
await onSubmit(values);
onSubmit={(values) => {
onSubmit(values);
}}
>
{({ isSubmitting, values, handleChange, setFieldValue, resetForm, isValid, dirty }) => (
Expand Down