Skip to content

Commit

Permalink
chore: cleanup eslint rules (flyteorg#272)
Browse files Browse the repository at this point in the history
Signed-off-by: Nastya Rusina <[email protected]>
  • Loading branch information
anrusina authored Jan 31, 2022
1 parent 77a30fa commit 54272a3
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 54 deletions.
21 changes: 15 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ module.exports = {
'prettier/@typescript-eslint'
],
rules: {
'no-case-declarations': 'warn',
// Rules we don't want to be enabled
'no-unused-vars': 'off', // disabled to let "@typescript-eslint/no-unused-vars" do it's job
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_' }
],
'jest/no-mocks-import': 'off',
'jest/valid-title': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off'

// temporarily disabled
'@typescript-eslint/no-var-requires': 'off', // 27
'@typescript-eslint/ban-types': 'warn', // 62
'@typescript-eslint/no-empty-function': 'warn', // 60
'@typescript-eslint/explicit-module-boundary-types': 'off', // 296
'@typescript-eslint/no-explicit-any': 'warn', // 134
'@typescript-eslint/no-non-null-assertion': 'warn', // 59
'react-hooks/exhaustive-deps': 'warn' // 24
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,6 @@ export const NodeExecutionDetailsPanelContent: React.FC<NodeExecutionDetailsProp
const commonStyles = useCommonStyles();
const styles = useStyles();
const detailsQuery = useNodeExecutionDetails(nodeExecution);
const displayId = detailsQuery.data ? (
detailsQuery.data.displayId
) : (
<Skeleton />
);
const displayName = detailsQuery.data ? (
detailsQuery.data.displayName
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('ExecutionDetailsAppBarContent', () => {

it('renders an overflow menu', async () => {
const { getByLabelText } = renderContent();
await waitFor(() => getByLabelText(commonLabels.moreOptionsButton));
expect(getByLabelText(commonLabels.moreOptionsButton)).toBeTruthy();
});

describe('in overflow menu', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ describe('RelaunchExecutionForm', () => {

it('passes original execution as a referenceExecution', async () => {
const { getByText } = renderForm();
await waitFor(() => getByText(mockContentString));
await waitFor(() => expect(getByText(mockContentString)).toBeDefined());
checkLaunchFormProps({
referenceExecutionId: execution.id
referenceExecutionId: expect.objectContaining(execution.id)
});
});

Expand Down Expand Up @@ -152,9 +152,11 @@ describe('RelaunchExecutionForm', () => {

it('passes workflowId to LaunchForm', async () => {
const { getByText } = renderForm();
await waitFor(() => getByText(mockContentString));
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
workflowId: execution.closure.workflowId
workflowId: expect.objectContaining(
execution.closure.workflowId
)
});
});

Expand Down Expand Up @@ -256,10 +258,12 @@ describe('RelaunchExecutionForm', () => {
});

it('passes taskId to LaunchForm', async () => {
const { getByText } = renderForm();
await waitFor(() => getByText(mockContentString));
renderForm();
await waitFor(() => {
/**/
});
checkLaunchFormProps({
taskId: execution.spec.launchPlan
taskId: expect.objectContaining(execution.spec.launchPlan)
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('NodeExecutionsTable', () => {
});
});

describe('without isParentNode flag, using taskNodeMetadata ', () => {
describe('without isParentNode flag, using taskNodeMetadata', () => {
let fixture: ReturnType<typeof dynamicPythonTaskWorkflow.generate>;
beforeEach(() => {
fixture = dynamicPythonTaskWorkflow.generate();
Expand Down
2 changes: 0 additions & 2 deletions src/components/Executions/useNodeExecutionDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { fetchWorkflow } from 'components/Workflow/workflowQueries';
import { Identifier } from 'models/Common/types';
import { NodeExecution } from 'models/Execution/types';
import { CompiledNode } from 'models/Node/types';
import { TaskType } from 'models/Task/constants';
import { TaskTemplate } from 'models/Task/types';
import { CompiledWorkflow, Workflow } from 'models/Workflow/types';
import { QueryClient, useQuery, useQueryClient } from 'react-query';
import { taskTypeToNodeExecutionDisplayType } from './constants';
import { fetchTaskExecutionList } from './taskExecutionQueries';
import {
CompiledBranchNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { Admin } from 'flyteidl';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import Accordion from '@material-ui/core/Accordion';
import AccordionSummary from '@material-ui/core/AccordionSummary';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Launch/LaunchForm/SimpleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { InputProps, InputType } from './types';
import { UnsupportedInput } from './UnsupportedInput';
import { getLaunchInputId } from './utils';

const useStyles = makeStyles(theme => ({
const useStyles = makeStyles(() => ({
formControl: {
minWidth: '100%'
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Launch/LaunchForm/StructInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const StructInput: React.FC<InputProps> = props => {
jsonFormRenderable && value ? JSON.parse(value as string) : {}
);

const onFormChange = ({ formData }, e) => {
const onFormChange = ({ formData }, _e) => {
onChange(JSON.stringify(formData));
setParamData(formData);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('Launch/inputHelpers/utils', () => {
];

cases.forEach(([description, value, expected]) =>
// eslint-disable-next-line jest/valid-title
it(description, () => expect(typeIsSupported(value)).toBe(expected))
);
});
Expand Down
9 changes: 2 additions & 7 deletions src/components/Launch/LaunchForm/test/LaunchTaskForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ import { APIContext } from 'components/data/apiContext';
import { mockAPIContextValue } from 'components/data/__mocks__/apiContext';
import { muiTheme } from 'components/Theme/muiTheme';
import { Core } from 'flyteidl';
import { cloneDeep, get } from 'lodash';
import { cloneDeep } from 'lodash';
import { RequestConfig } from 'models/AdminEntity/types';
import {
Identifier,
NamedEntityIdentifier,
Variable
} from 'models/Common/types';
import {
createWorkflowExecution,
CreateWorkflowExecutionArguments
} from 'models/Execution/api';
import { createWorkflowExecution } from 'models/Execution/api';
import { getTask, listTasks } from 'models/Task/api';
import { Task } from 'models/Task/types';
import { createMockTaskClosure } from 'models/__mocks__/taskData';
Expand Down Expand Up @@ -50,11 +47,9 @@ import {
} from '../__mocks__/mockInputs';
import {
binaryInputName,
booleanInputName,
floatInputName,
iamRoleString,
integerInputName,
k8sServiceAccountString,
stringInputName
} from './constants';
import { createMockObjects } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Launch/LaunchForm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function formatLabelWithType(label: string, type: InputTypeDefinition) {
export function versionsToSearchableSelectorOptions(
items: SearchableVersion[]
): SearchableSelectorOption<Identifier>[] {
return items.map<SearchableSelectorOption<Identifier>>((item, index) => ({
return items.map<SearchableSelectorOption<Identifier>>((item, _index) => ({
data: item.id,
id: item.id.version,
name: item.id.version,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Literals/Scalar/ProtobufStructValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const RenderedProtobufValue: React.FC<{
switch (value.kind) {
case 'nullValue':
return <PrintValue label={label} value={<NoneTypeValue />} />;
case 'listValue':
case 'listValue': {
const list = value.listValue as ProtobufListValue;
return (
<>
Expand All @@ -38,6 +38,7 @@ const RenderedProtobufValue: React.FC<{
/>
</>
);
}
case 'structValue':
return (
<>
Expand Down
7 changes: 1 addition & 6 deletions src/components/Notifications/SystemStatusBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ButtonBase, SvgIcon, Typography } from '@material-ui/core';
import { ButtonBase, Typography } from '@material-ui/core';
import Paper from '@material-ui/core/Paper';
import { makeStyles, Theme } from '@material-ui/core/styles';
import Close from '@material-ui/icons/Close';
Expand Down Expand Up @@ -69,11 +69,6 @@ const useStyles = makeStyles((theme: Theme) => ({
}
}));

interface StatusConstantValues {
color: string;
IconComponent: typeof SvgIcon;
}

const InfoIcon = () => (
<Info data-testid="info-icon" htmlColor={infoIconColor} />
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Shimmer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles(() => ({
animate: {
height: 10,
animation: '$shimmer 4s infinite linear',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button } from '@material-ui/core';
import { action } from '@storybook/addon-actions';
import { storiesOf } from '@storybook/react';
import { basicStoryContainer } from '__stories__/decorators';
import * as React from 'react';
Expand Down
9 changes: 8 additions & 1 deletion src/components/common/test/MoreOptionsMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('MoreOptionsMenu', () => {
};

it('shows menu when button is clicked', async () => {
await getMenu(renderMenu());
const menuEl = await getMenu(renderMenu());
expect(getByText(menuEl, options[0].label)).toBeInTheDocument();
});

it('renders element for each option', async () => {
Expand All @@ -58,15 +59,21 @@ describe('MoreOptionsMenu', () => {
it('hides menu when item is selected', async () => {
const result = renderMenu();
const menuEl = await getMenu(result);
expect(getByText(menuEl, options[0].label)).toBeInTheDocument();

const itemEl = getByText(menuEl, options[0].label);
fireEvent.click(itemEl);
await waitForElementToBeRemoved(menuEl);
expect(getByText(menuEl, options[0].label)).not.toBeInTheDocument();
});

it('hides menu on escape', async () => {
const result = renderMenu();
const menuEl = await getMenu(result);
expect(getByText(menuEl, options[0].label)).toBeInTheDocument();

fireEvent.keyDown(menuEl, { key: 'Escape', code: 'Escape' });
await waitForElementToBeRemoved(menuEl);
expect(getByText(menuEl, options[0].label)).not.toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions src/components/common/test/SearchableList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('SearchableList', () => {
? `should match ${expectedValues} with input ${input}`
: `should have no matches for input ${input}`;

// eslint-disable-next-line jest/valid-title
it(expectString, () => {
const {
getByRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const ReactFlowCustomTaskNode = ({ data }: any) => {
fontSize: '.3rem'
};

const handleClick = e => {
const handleClick = _e => {
setSelectedNode(true);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/__mocks__/fetchableData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { State } from 'xstate';
import { FetchableData, FetchFn, fetchStates } from '../types';
import { FetchableData, fetchStates } from '../types';

export function createMockFetchable<T>(
value: any,
Expand Down
1 change: 0 additions & 1 deletion src/components/hooks/test/useFetchableData.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
act,
fireEvent,
getByLabelText,
render,
Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('hooks/utils', () => {

it('assigns parent workflow id to subworkflow nodes', () => {
const nodes = extractAndIdentifyNodes(workflow);
subWorkflow.template.nodes.forEach(node =>
subWorkflow.template.nodes.forEach(_node =>
expect(nodes).toContainEqual(
expect.objectContaining({
id: {
Expand Down
4 changes: 0 additions & 4 deletions src/models/AdminEntity/AdminEntity.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import axios, { AxiosRequestConfig, Method } from 'axios';
import { env } from 'common/env';
import { toBoolean } from 'common/utils';

import { generateAdminApiQuery } from './AdminApiQuery';

import { transformRequestError } from './transformRequestError';
import {
AdminEntityTransformer,
Expand Down
1 change: 0 additions & 1 deletion src/models/Graph/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CompiledNode } from 'models/Node/types';
import { NodeExecution } from 'models/Execution/types';
import { TaskTemplate } from 'models/Task/types';

Expand Down
1 change: 0 additions & 1 deletion src/models/Node/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Core } from 'flyteidl';
import { Alias, Binding, Identifier } from 'models/Common/types';
import { TaskTemplate } from 'models/Task/types';

/** A graph node indicating a subworkflow execution */
export type WorkflowNode = Core.IWorkflowNode;
Expand Down

0 comments on commit 54272a3

Please sign in to comment.