Skip to content

Commit 9daa4f7

Browse files
fix eslint errors
1 parent 231b3c5 commit 9daa4f7

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"editor.defaultFormatter": "esbenp.prettier-vscode"
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"[javascript]": {
4+
"editor.formatOnPaste": true,
5+
"editor.formatOnSave": true,
6+
},
7+
"editor.formatOnPaste": true,
8+
"editor.formatOnSave": true,
39
}

eslint.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const prettier = require('eslint-plugin-prettier');
2+
const trunOffPrettier = require('eslint-config-prettier');
23
const globals = require('globals');
34
const babelParser = require('@babel/eslint-parser');
45
const path = require('path');
@@ -20,10 +21,11 @@ const GLOBALS_BROWSER_FIX = Object.assign({}, globals.browser, {
2021
delete GLOBALS_BROWSER_FIX['AudioWorkletGlobalScope '];
2122

2223
module.exports = [
23-
...compat.extends('eslint:recommended', 'plugin:prettier/recommended'),
24+
...compat.extends('eslint:recommended', 'plugin:prettier/recommended', 'prettier'),
2425
{
2526
plugins: {
2627
prettier,
28+
trunOffPrettier,
2729
},
2830

2931
languageOptions: {
@@ -35,8 +37,7 @@ module.exports = [
3537

3638
parser: babelParser,
3739
ecmaVersion: 12,
38-
sourceType: 'commonjs',
39-
40+
sourceType: 'module',
4041
parserOptions: {
4142
ecmaFeatures: {
4243
//jsx: true,

src/api.factory.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @param {String} [options.tabDisplay="inline-flex"] - default value is "inline-flex". would be display of tab elements
88
* @param {String} [options.containerDisplay="flex"] - default value is "flex". would be display of container element
99
*/
10-
export const Api = function (options) {
10+
export const Api = function () {
1111
const arg = arguments;
1212
this._setOptions(arg[1]);
1313
this._tablistEl = null;
14-
const { getElManagementIns } = arg[0]();
14+
const {getElManagementIns} = arg[0]();
1515
this._getElManagementIns = getElManagementIns;
1616
this._tabs = null;
1717
this._tabsCount = null;
@@ -63,11 +63,11 @@ Api.prototype = {
6363
_hideTabs: function (firstHiddenTabIndex, selectedTabInfo, includeSelectedTab) {
6464
const hiddenTabs = [];
6565
this._options.containerElement.style.display = 'none';
66-
const { index: selectedTabIndex } = selectedTabInfo;
66+
const {index: selectedTabIndex} = selectedTabInfo;
6767
for (let i = firstHiddenTabIndex, tabsCount = this._tabsCount; i < tabsCount; i++) {
6868
if (includeSelectedTab || i !== selectedTabIndex) {
6969
this._tabs[i].style.display = 'none';
70-
hiddenTabs.push({ el: this._tabs[i], index: i });
70+
hiddenTabs.push({el: this._tabs[i], index: i});
7171
}
7272
}
7373
this._showBtn();
@@ -79,12 +79,12 @@ Api.prototype = {
7979
const el = index >= 0 ? tabs[index] : null;
8080
const overflow = el
8181
? this.els
82-
.getDistance(el)
83-
.sub(this.els.getEl(this._options.tablistElement).getSpacing(this._btnPositionRelativeToTablist))
84-
.sub(this.els.getEl(this._options.buttonElement).getFullSize()).value <= 0
82+
.getDistance(el)
83+
.sub(this.els.getEl(this._options.tablistElement).getSpacing(this._btnPositionRelativeToTablist))
84+
.sub(this.els.getEl(this._options.buttonElement).getFullSize()).value <= 0
8585
: false;
8686
const overflowFullSize = overflow ? this.els.getEl(el).getFullSize() : 0;
87-
return { index, overflowFullSize };
87+
return {index, overflowFullSize};
8888
},
8989
_validateTabsCount: function () {
9090
this._tabs = this._tablistEl.children;
@@ -112,16 +112,19 @@ Api.prototype = {
112112
if (this._checkOverflow(_lastTab) === false) {
113113
return [];
114114
}
115-
const selectedTabInfo = this._setBtnPositionRelativeToTablist(isVertical, direction)._getSelectedTabInfo(this._tabs, selectedTabIndex);
115+
const selectedTabInfo = this._setBtnPositionRelativeToTablist(isVertical, direction)._getSelectedTabInfo(
116+
this._tabs,
117+
selectedTabIndex,
118+
);
116119
return this._validateSliderMinSize(selectedTabInfo)
117120
? this._hideTabs(
118-
this._findFirstHiddenTabIndexFactory(
121+
this._findFirstHiddenTabIndexFactory(
122+
selectedTabInfo,
123+
this._getSearchBoundries(selectedTabInfo),
124+
this._getOrder(this._tabs[0], _lastTab),
125+
),
119126
selectedTabInfo,
120-
this._getSearchBoundries(selectedTabInfo),
121-
this._getOrder(this._tabs[0], _lastTab),
122-
),
123-
selectedTabInfo,
124-
)
127+
)
125128
: this._hideTabs(0, selectedTabInfo, true);
126129
},
127130
_validateSliderMinSize: function (selectedTabInfo) {
@@ -139,7 +142,7 @@ Api.prototype = {
139142
: 'desc';
140143
},
141144
_getSearchBoundries: function (selectedTabInfo) {
142-
const { overflowFullSize, index: pivotIndex } = selectedTabInfo;
145+
const {overflowFullSize, index: pivotIndex} = selectedTabInfo;
143146
//if selected tab is not existed
144147
if (pivotIndex < 0) {
145148
return [0, this._tabsCount - 2];
@@ -181,7 +184,8 @@ Api.prototype = {
181184
/** set _btnPositionRelativeToTablist and _btnReversePositionRelativeToTablist */
182185
_setBtnPositionRelativeToTablist: function (isVertical, dir) {
183186
if (!this._btnPositionRelativeToTablist) {
184-
let pos = '', reversePos = '';
187+
let pos = '',
188+
reversePos = '';
185189
if (isVertical == true) {
186190
pos = 'Bottom'; //the Button is rendered below the Tablist
187191
reversePos = 'Top';

src/distanceFrom.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export const constructor = function DistanceFrom(deps, { baseEl, isVertical, dir }) {
2-
deps.Base.call(this, { isVertical });
1+
export const constructor = function DistanceFrom(deps, {baseEl, isVertical, dir}) {
2+
deps.Base.call(this, {isVertical});
33
this.baseEl = baseEl;
44
this._distanceFactory(isVertical, dir);
55
};

src/el.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function El({ el, sizeDimension, sizeDirections }) {
1+
export default function El({el, sizeDimension, sizeDirections}) {
22
this._el = el;
33
/**would be width|height */
44
this._sizeDimension = sizeDimension;
@@ -14,7 +14,7 @@ El.prototype = {
1414
},
1515
/**
1616
* including padding, border and margin
17-
* @param {"Right"|"Bottom"|"Left"|"Top"} dir
17+
* @param {"Right"|"Bottom"|"Left"|"Top"} dir
1818
* @returns {Number}
1919
*/
2020
getSpacing: function (dir) {

0 commit comments

Comments
 (0)