Skip to content

Commit

Permalink
style: fix all eslint errors (#491)
Browse files Browse the repository at this point in the history
affects: @gio-design/components
  • Loading branch information
jack0pan authored Nov 19, 2020
1 parent e611653 commit 6f5d6c4
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 125 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"build:website": "yarn workspace website build",
"build-storybook": "yarn workspace @gio-design/components build-storybook",
"g:icons": "yarn workspace @gio-design/icons generate",
"lint:components": "eslint packages/components/src --ext .js,.jsx,.ts,.tsx",
"lint:components": "eslint packages/components/src --ext .ts,.tsx",
"lint:style": "stylelint 'packages/components/src/**/*.{css,less}' --syntax less",
"test": "yarn workspace @gio-design/components test",
"version": "npx lerna version --no-private --no-git-tag-version",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Banner: React.FC<BannerProps> = (props: BannerProps) => {
!visible && `${prefixCls}-close`
)}
>
<div className={className(`${prefixCls}-content`, button && `${prefixCls}-content-button`)}> {content}</div>
<div className={className(`${prefixCls}-content`, button && `${prefixCls}-content-button`)}>{content}</div>
<div className={className(`${prefixCls}-button`)}>{button}</div>
<div
className={className(`${prefixCls}-closeIcon`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Testing Banner', () => {

it('props content', () => {
const stringwrapper = mount(<Banner type="normal" content="content" />).children();
expect(stringwrapper.childAt(0).text()).toBe(' content');
expect(stringwrapper.childAt(0).text()).toBe('content');
const nodeWrapper = mount(<Banner content={<div>content</div>} />).children();
expect(nodeWrapper.childAt(0).type()).toBe('div');
});
Expand All @@ -34,12 +34,10 @@ describe('Testing Banner', () => {
expect(mount(<Banner type="alert" />).exists('.gio-banner-alert')).toBe(true);
});

it('can be click to close',() => {
it('can be click to close', () => {
const closeMock = jest.fn();
const wrapper = mount(
<Banner onClose={closeMock}>关闭</Banner>
)
const wrapper = mount(<Banner onClose={closeMock}>关闭</Banner>);
wrapper.find('.gio-banner-closeIcon').simulate('click');
expect(closeMock).toBeCalled();
})
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ exports[`Testing Banner should be stable 1`] = `
>
<div
className="gio-banner-content"
>
</div>
/>
<div
className="gio-banner-button"
/>
Expand Down
9 changes: 1 addition & 8 deletions packages/components/src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import Group from './Group';
import withGroupedOptions from './utils/withGroupedOptions';
import { SelectListProps } from './interface';

interface State {
value: any | any[];
}

class SelectList extends React.Component<SelectListProps & ConfigConsumerProps, State> {
class SelectList extends React.Component<SelectListProps & ConfigConsumerProps> {
public static defaultProps: Partial<SelectListProps & ConfigConsumerProps> = {
disabledOptions: [],
isMultiple: false,
Expand All @@ -23,9 +19,6 @@ class SelectList extends React.Component<SelectListProps & ConfigConsumerProps,
public constructor(props: SelectListProps & ConfigConsumerProps) {
super(props);
this.ref = React.createRef();
this.state = {
value: null,
};
}

private getPopupContainer = () => this.ref.current as HTMLElement;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/components/table/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { PaginationProps } from '../pagination/interface';
import { CheckboxProps } from '../checkbox/interface';

export type AlignType = 'left' | 'center' | 'right';
export type SortOrder = 'descend' | 'ascend' | null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import renderSwitcherIcon from '../tree/iconUtil';
import SizeContext from '../config-provider/SizeContext';
import { TreeSelectProps } from './interface';

class TreeSelect<T> extends React.Component<TreeSelectProps<T>, {}> {
class TreeSelect<T> extends React.Component<TreeSelectProps<T>> {
public static TreeNode = TreeNode;

public static SHOW_ALL: typeof SHOW_ALL = SHOW_ALL;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/utils/composeRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const composeRef = <T>(...refs: React.Ref<T>[]): React.RefCallback<T> => (node:
if (typeof ref === 'function') {
ref(node);
} else if (typeof ref === 'object' && ref && 'current' in ref) {
// eslint-disable-next-line no-param-reassign
(ref as any).current = node;
}
});
Expand Down
7 changes: 4 additions & 3 deletions packages/components/src/utils/hooks/useDebounceLoading.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { useState, useCallback, useEffect } from 'react';
import { debounce } from 'lodash';

const useDebounceLoading = (loading: boolean, delay: number) => {
const useDebounceLoading = (loading: boolean, delay: number): boolean => {
const [shouldLoading, setShouldLoading] = useState<boolean>(loading);
// eslint-disable-next-line react-hooks/exhaustive-deps
const debounceFunc = useCallback(
debounce((_loading: boolean) => setShouldLoading(_loading), delay),
[delay],
[delay]
);
useEffect(() => {
if (shouldLoading && !loading) {
debounceFunc.cancel();
}
debounceFunc(loading);
}, [loading]);
}, [debounceFunc, loading, shouldLoading]);

return shouldLoading;
};
Expand Down
63 changes: 0 additions & 63 deletions packages/components/src/utils/hooks/useHover.ts

This file was deleted.

39 changes: 0 additions & 39 deletions packages/components/src/utils/hooks/useToggle.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/components/src/utils/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/prefer-default-export */
import { act } from 'react-dom/test-utils';

export async function waitForComponentToPaint(wrapper: any, amount = 500) {
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/utils/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const tupleNum = <T extends number[]>(...args: T) => args;
* Extract the type of an element of an array/tuple without performing indexing
*/
// eslint-disable-next-line no-shadow
// eslint-disable-next-line @typescript-eslint/no-shadow
export type ElementOf<T> = T extends (infer E)[] ? E : T extends readonly (infer E)[] ? E : never;

/**
Expand Down

1 comment on commit 6f5d6c4

@vercel
Copy link

@vercel vercel bot commented on 6f5d6c4 Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.