Skip to content

Commit

Permalink
fix: optimize warn lint (#23)
Browse files Browse the repository at this point in the history
* fix: optimize warn lint

* fix: text file lint fix
  • Loading branch information
brucetoo authored Mar 8, 2021
1 parent f5923f9 commit be8b31c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export class CustomTooltip extends BaseTooltip {
}

protected renderInfos(infos: string) {
return <Infos infos={'重写info测试'} />;
return <Infos infos={`重写info测试 ${infos}`} />;
}
}
2 changes: 1 addition & 1 deletion packages/s2-core/src/common/tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class BaseTooltip {

protected position: Position = { x: 0, y: 0 }; // tooltips position info

constructor(plot: BaseSpreadSheet, aggregation: Aggregation) {
constructor(plot: BaseSpreadSheet, aggregation?: Aggregation) {
this.spreadsheet = plot;
this.aggregation = aggregation || 'SUM';
}
Expand Down
4 changes: 0 additions & 4 deletions packages/s2-core/src/interaction/row-column-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ export class RowColumnSelection extends HoverInteraction {
let showSortOperations = false;
// tooltip 是否可让鼠标进入
let enterable = true;
// 显示 tooltip 的动作来源
let actionType: ActionType;
if (cell instanceof RowCell) {
// 行选中
actionType = 'rowSelection';
const idx = meta.cellIndex;
if (idx === -1) {
// 多行
Expand All @@ -108,7 +105,6 @@ export class RowColumnSelection extends HoverInteraction {
}
} else if (cell instanceof ColCell) {
// 列选中
actionType = 'columnSelection';
const idx = meta.cellIndex;
if (idx === -1) {
// 多列
Expand Down
9 changes: 1 addition & 8 deletions packages/s2-core/src/sheet-type/base-spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ import {
} from '../common/constant';
import { BaseDataSet } from '../data-set';
import { SpreadsheetFacet } from '../facet';
import {
Conditions,
Fields,
Node,
Totals,
BaseInteraction,
SpreadSheetTheme,
} from '../index';
import { Node, BaseInteraction, SpreadSheetTheme } from '../index';
import { getTheme, registerTheme } from '../theme';
import { BaseTooltip } from '../tooltip';
import { BaseFacet } from '../facet/base-facet';
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default class SpreadSheet extends BaseSpreadSheet {
options,
this.options,
'hierarchyCollapse',
(currentValue) => {
() => {
if (isBoolean(options.hierarchyCollapse)) {
// 如果选择了默认折叠/展开,需要清除之前的折叠状态。
set(this, 'options.style.collapsedRows', {});
Expand All @@ -201,7 +201,7 @@ export default class SpreadSheet extends BaseSpreadSheet {
options,
this.options,
['spreadsheetType', 'valueInCols'],
(currentValue) => {
() => {
this.dataSet = this.initDataSet(options);
},
);
Expand All @@ -217,7 +217,7 @@ export default class SpreadSheet extends BaseSpreadSheet {
options,
this.options,
'style.colCfg.colWidthType',
(currentValue) => {
() => {
set(this, 'options.style.rowCfg.widthByField', {});
set(options, 'style.rowCfg.widthByField', {});
},
Expand All @@ -229,7 +229,7 @@ export default class SpreadSheet extends BaseSpreadSheet {
options,
this.options,
['width', 'height'],
(currentValue) => {
() => {
this.changeSize(options.width, options.height);
},
);
Expand Down
7 changes: 4 additions & 3 deletions packages/s2-core/src/utils/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ export const auto = (

let loop = 0;
let power;
let running = true;

while (true) {
while (running) {
power = powers[loop] as number;

if (n >= power && loop < texts.length) {
n /= power;
} else {
break;
running = false;
}
++loop;
loop += 1;
}

// parseFloat 解决 toFixed 出现很多 0 结尾。
Expand Down
10 changes: 6 additions & 4 deletions packages/s2-core/src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ export const getEllipsisTextInner = (text: any, maxWidth: number, font) => {
return text;
}

let runningStep1 = true;
// 首先通过 step 计算,找出最大的未超出长度的
while (true) {
while (runningStep1) {
// 更新字符串
currentText = leftText.substr(0, STEP);

Expand All @@ -63,7 +64,7 @@ export const getEllipsisTextInner = (text: any, maxWidth: number, font) => {
// 超出剩余宽度,则停止
if (currentWidth + DOT_WIDTH > leftWidth) {
if (currentWidth > leftWidth) {
break;
runningStep1 = false;
}
}

Expand All @@ -79,8 +80,9 @@ export const getEllipsisTextInner = (text: any, maxWidth: number, font) => {
}
}

let runningStep2 = true;
// 最下的最后一个 STEP,使用 1 递增(用二分效果更高)
while (true) {
while (runningStep2) {
// 更新字符串
currentText = leftText.substr(0, 1);

Expand All @@ -89,7 +91,7 @@ export const getEllipsisTextInner = (text: any, maxWidth: number, font) => {

// 超出剩余宽度,则停止
if (currentWidth + DOT_WIDTH > leftWidth) {
break;
runningStep2 = false;
}

r.push(currentText);
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
Expand Down

0 comments on commit be8b31c

Please sign in to comment.