Skip to content

Commit aef6e96

Browse files
resolve eslint error
1 parent aa5163b commit aef6e96

21 files changed

+127
-110
lines changed

example/basic/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import './App.css';
23
import Basic from './com/basic/index.js';
34
import 'react-dyn-tabs/style/react-dyn-tabs.css';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import React from 'react';
2-
export default function (props) {
2+
export default function EagerPanel1() {
33
return <p>{'eager tab content 1'}</p>;
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import React from 'react';
2-
export default function (props) {
2+
export default function EagerPanel2() {
33
return <p>{'eager tab content 2'}</p>;
44
}

example/basic/com/basic/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import React from 'react';
33
import useDynTabs from 'react-dyn-tabs';
44
import service from './service/index.js';
55
import './index.css';
6-
export default function (props) {
6+
export default function Basic() {
77
const options = service.getLocalData();
8-
const [Tablist, Panellist, api] = useDynTabs(options);
8+
const [Tablist, Panellist, ready] = useDynTabs(options);
99
return (
1010
<>
1111
<Tablist></Tablist>

src/index.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useState} from 'react';
1+
import React from 'react';
22
import {render, unmountComponentAtNode} from 'react-dom';
33
import useDynTabs from './index.js';
44
import {act} from 'react-dom/test-utils';
@@ -35,7 +35,7 @@ beforeEach(() => {
3535
beforeSelect: jest.fn(function () {}),
3636
onDestroy: jest.fn(function () {}),
3737
};
38-
App = function (props) {
38+
App = function App() {
3939
const [Tablist, Panellist, readyFunction] = useDynTabs(op);
4040
ready = readyFunction;
4141
readyFunction((instanceParam) => {
@@ -72,8 +72,8 @@ describe('apply multiple actions : ', () => {
7272
expect.assertions(1);
7373
renderApp();
7474
return act(() => {
75-
return instance.select('2').then((result) => {
76-
return instance.close('2').then((result) => {
75+
return instance.select('2').then(() => {
76+
return instance.close('2').then(() => {
7777
expect(document.querySelector('[tab-id="1"]').className.includes('rc-dyn-tabs-selected')).toBe(true);
7878
});
7979
});
@@ -82,7 +82,7 @@ describe('apply multiple actions : ', () => {
8282
test('opening new tab and closing selected tab', () => {
8383
let _api;
8484
act(() => {
85-
const App = function (props) {
85+
const App = function () {
8686
const [Tablist, Panellist, api] = useDynTabs(op);
8787
_api = api;
8888
return (
@@ -122,13 +122,13 @@ describe('apply multiple actions : ', () => {
122122
return (
123123
<a {...props.tabProps}>
124124
{props.children}
125-
{props.hasOwnProperty('iconProps') && <span {...props.iconProps}></span>}
125+
{Object.prototype.hasOwnProperty.call(props, 'iconProps') && <span {...props.iconProps}></span>}
126126
</a>
127127
);
128128
});
129129
instance.one('onInit', function () {
130130
this.setTab('1', {
131-
panelComponent: function (props) {
131+
panelComponent: function panelComponent() {
132132
return <div id="updatedPanel1"></div>;
133133
},
134134
}).refresh();
@@ -215,7 +215,7 @@ describe('select method : ', () => {
215215
expect.assertions(2);
216216
renderApp();
217217
return act(() => {
218-
return instance.select('1').then((result) => {
218+
return instance.select('1').then(() => {
219219
expect(op.onChange.mock.calls.length === 0).toBe(true);
220220
expect(op.onInit.mock.calls.length === 2).toBe(true);
221221
});
@@ -225,7 +225,7 @@ describe('select method : ', () => {
225225
expect.assertions(4);
226226
renderApp();
227227
return act(() => {
228-
return instance.select('3').then((result) => {
228+
return instance.select('3').then(() => {
229229
expect(document.querySelector('.rc-dyn-tabs-selected') == null).toBe(true);
230230
expect(instance.getCopyData().selectedTabID === '3').toBe(true);
231231
expect(op.onChange.mock.calls.length === 1).toBe(true);
@@ -268,7 +268,7 @@ describe('close method : ', () => {
268268
expect.assertions(2);
269269
renderApp();
270270
return act(() => {
271-
return instance.close('4').then((result) => {
271+
return instance.close('4').then(() => {
272272
expect(op.onChange.mock.calls.length === 0).toBe(true);
273273
expect(op.onInit.mock.calls.length === 2).toBe(true);
274274
});
@@ -320,7 +320,7 @@ describe('open method : ', () => {
320320
expect.assertions(3);
321321
renderApp();
322322
return act(() => {
323-
return instance.open(op.tabs[0]).then((result) => {
323+
return instance.open(op.tabs[0]).then(() => {
324324
expect(op.onChange.mock.calls.length === 0).toBe(true);
325325
expect(op.onInit.mock.calls.length === 2).toBe(true);
326326
expect(instance.getCopyData().openTabIDs.length === 2).toBe(true);
@@ -362,7 +362,7 @@ describe('ready function : ', () => {
362362
ready((instance) => {
363363
instance.one('onLoad', onLoad).one('onInit', onInit);
364364
});
365-
return instance.refresh().then((result) => {
365+
return instance.refresh().then(() => {
366366
expect(op.onLoad.mock.calls.length === 1).toBe(true);
367367
expect(op.onInit.mock.calls.length === 2).toBe(true);
368368
expect(onInit.mock.calls.length === 1).toBe(true);

src/panel/panel.test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,30 @@ let container = document.createElement('div'),
77
realUseContext;
88
const getDefaultApi = () => ({
99
tabs: [
10-
{id: '1', title: 'tab1', panelComponent: (props) => <p>{props.api.getTab(props.id).title + ' panel'}</p>},
10+
{
11+
id: '1',
12+
title: 'tab1',
13+
panelComponent: function panelComponent1(props) {
14+
return <p>{props.api.getTab(props.id).title + ' panel'}</p>;
15+
},
16+
},
1117
{
1218
id: '2',
1319
title: 'tab2',
1420
disable: true,
15-
panelComponent: (props) => <p>{props.api.getTab(props.id).title + ' panel'}</p>,
21+
panelComponent: function panelComponent3(props) {
22+
return <p>{props.api.getTab(props.id).title + ' panel'}</p>;
23+
},
1624
},
1725
{id: '3', title: 'tab3'},
1826
{
1927
id: '4',
2028
title: 'tab4',
21-
panelComponent: (props) => {
29+
panelComponent: function panelComponent4(props) {
2230
let panelContent = 'panel 4 is ';
2331
props.isSelected || (panelContent = panelContent + 'not ');
2432
panelContent = panelContent + 'selected';
25-
return <div class="custom-panel">{panelContent}</div>;
33+
return <div className="custom-panel">{panelContent}</div>;
2634
},
2735
},
2836
{id: '5', title: 'tab5', panelComponent: <span>panel 6</span>},
@@ -84,7 +92,7 @@ describe('panel structure : ', () => {
8492
{id: '1', title: 'tab1'},
8593
{id: '2', title: 'tab2'},
8694
],
87-
defaultPanelComponent: (props) => {
95+
defaultPanelComponent: function defaultPanelComponent(props) {
8896
const panelContent = props.api.getTab(props.id).title + ' panel';
8997
const className = props.isSelected ? 'custom-panel-selected' : 'custom-panel-none-selected';
9098
return <span className={className}>{panelContent}</span>;
@@ -108,7 +116,7 @@ describe('panel structure : ', () => {
108116
],
109117
direction: 'rtl',
110118
accessibility: false,
111-
defaultPanelComponent: (props) => {
119+
defaultPanelComponent: function defaultPanelComponent(props) {
112120
const panelContent = props.api.getTab(props.id).title + ' panel';
113121
const className = props.isSelected ? 'custom-panel-selected' : 'custom-panel-none-selected';
114122
return <span className={className}>{panelContent}</span>;

src/panelList/panelList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {memo} from 'react';
22
import Panel from '../panel/panel.js';
33
import {ApiContext, StateContext} from '../utils/context.js';
44
const PanelList = memo(
5-
function PanelList(props) {
5+
function PanelList() {
66
const {openTabIDs, selectedTabID} = React.useContext(StateContext),
77
api = React.useContext(ApiContext),
88
setting = api.optionsManager.setting,

src/tab/defaulTabInner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const DefaulTabInner = function (props) {
33
return (
44
<button {...props.tabProps}>
55
{props.children}
6-
{props.hasOwnProperty('iconProps') && <span {...props.iconProps}></span>}
6+
{Object.prototype.hasOwnProperty.call(props, 'iconProps') && <span {...props.iconProps}></span>}
77
</button>
88
);
99
};

src/tab/tab.test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, {useState} from 'react';
2-
import {render, unmountComponentAtNode} from 'react-dom';
1+
import React from 'react';
2+
import {unmountComponentAtNode} from 'react-dom';
33
import Tab from './tab';
4-
import {act} from 'react-dom/test-utils';
54
import renderer from 'react-test-renderer';
65
import DefaultTabInner from './defaulTabInner.js';
76
import Api from '../utils/api/api.js';
@@ -12,7 +11,13 @@ const getDefaultApi = () => ({
1211
{id: '1', title: 'tab1', tooltip: 'tab1 tootltip', closable: false},
1312
{id: '2', title: 'tab2', iconClass: 'ui-icon ui-icon-disk'},
1413
{id: '3', title: 'tab3', disable: true},
15-
{id: '4', title: 'tab4', panelComponent: (props) => <div>tab4</div>},
14+
{
15+
id: '4',
16+
title: 'tab4',
17+
panelComponent: function panelComponent4() {
18+
return <div>tab4</div>;
19+
},
20+
},
1621
],
1722
});
1823
const setMockUseContext = (op = {}) => {

src/tabList/tabList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ApiContext, StateContext} from '../utils/context.js';
33
import Tab from '../tab/tab.js';
44
import tablistPropsManager from './tablistPropsManager.js';
55
const TabList = memo(
6-
function TabList(props) {
6+
function TabList() {
77
const {openTabIDs, selectedTabID} = React.useContext(StateContext),
88
api = React.useContext(ApiContext),
99
tablistProps = tablistPropsManager({api});

0 commit comments

Comments
 (0)