Skip to content

Commit

Permalink
removed: unnecessary null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Corbe30 committed Dec 16, 2024
1 parent 20f3b66 commit e068bf0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
24 changes: 12 additions & 12 deletions packages/core/src/modules/ConditionFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export function setConditionRules(
const rangeArr = getRangeByTxt(ctx, v);
// 判断条件值是不是选区
if (rangeArr.length > 1) {
const r1 = rangeArr?.[0]?.row[0];
const r2 = rangeArr?.[0]?.row[1];
const c1 = rangeArr?.[0]?.column[0];
const c2 = rangeArr?.[0]?.column[1];
const r1 = rangeArr[0]?.row[0];
const r2 = rangeArr[0]?.row[1];
const c1 = rangeArr[0]?.column[0];
const c2 = rangeArr[0]?.column[1];
if (r1 === r2 && c1 === c2) {
const d = getFlowdata(ctx);
if (!d || _.isNil(r1) || _.isNil(c1)) return;
Expand Down Expand Up @@ -97,10 +97,10 @@ export function setConditionRules(
return;
}
if (rangeArr1.length === 1) {
const r1 = rangeArr1?.[0]?.row[0];
const r2 = rangeArr1?.[0]?.row[1];
const c1 = rangeArr1?.[0]?.column[0];
const c2 = rangeArr1?.[0]?.column[1];
const r1 = rangeArr1[0]?.row[0];
const r2 = rangeArr1[0]?.row[1];
const c1 = rangeArr1[0]?.column[0];
const c2 = rangeArr1[0]?.column[1];
if (r1 === r2 && c1 === c2) {
const d = getFlowdata(ctx);
if (!d || _.isNil(r1) || _.isNil(c1)) return;
Expand All @@ -127,10 +127,10 @@ export function setConditionRules(
return;
}
if (rangeArr2.length === 1) {
const r1 = rangeArr2?.[0]?.row[0];
const r2 = rangeArr2?.[0]?.row[1];
const c1 = rangeArr2?.[0]?.column[0];
const c2 = rangeArr2?.[0]?.column[1];
const r1 = rangeArr2[0]?.row[0];
const r2 = rangeArr2[0]?.row[1];
const c1 = rangeArr2[0]?.column[0];
const c2 = rangeArr2[0]?.column[1];
if (r1 === r2 && c1 === c2) {
const d = getFlowdata(ctx);
if (!d || _.isNil(r1) || _.isNil(c1)) return;
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/modules/dataVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export function dataRangeSelection(
ctx.luckysheetCellUpdate = [row_index, col_index];

const range = getRangeByTxt(ctx, rangT);
const r = range?.[0]?.row;
const c = range?.[0]?.column;
const r = range[0]?.row;
const c = range[0]?.column;
if (_.isNil(r) || _.isNil(c)) return;
const row_pre = rowLocationByIndex(r[0], ctx.visibledatarow)[0];
const row = rowLocationByIndex(r[1], ctx.visibledatarow)[1];
Expand Down Expand Up @@ -858,10 +858,10 @@ export function confirmMessage(
ctx.warnDialog = generalDialog.noSeletionError;
return false;
}
let str = range?.[range.length - 1]?.row[0];
let edr = range?.[range.length - 1]?.row[1];
let stc = range?.[range.length - 1]?.column[0];
let edc = range?.[range.length - 1]?.column[1];
let str = range[range.length - 1]?.row[0];
let edr = range[range.length - 1]?.row[1];
let stc = range[range.length - 1]?.column[0];
let edc = range[range.length - 1]?.column[1];
const d = getFlowdata(ctx);
if (!d || _.isNil(str) || _.isNil(edr) || _.isNil(stc) || _.isNil(edc))
return false;
Expand Down
16 changes: 8 additions & 8 deletions packages/react/src/components/DataVerification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ const DataVerification: React.FC = () => {
getSheetIndex(ctx, ctx.currentSheetId) as number
].dataVerification ?? {};

const str = range?.[range.length - 1]?.row[0];
const edr = range?.[range.length - 1]?.row[1];
const stc = range?.[range.length - 1]?.column[0];
const edc = range?.[range.length - 1]?.column[1];
const str = range[range.length - 1]?.row[0];
const edr = range[range.length - 1]?.row[1];
const stc = range[range.length - 1]?.column[0];
const edc = range[range.length - 1]?.column[1];
const d = getFlowdata(ctx);
if (
!d ||
Expand Down Expand Up @@ -124,10 +124,10 @@ const DataVerification: React.FC = () => {
const currentDataVerification =
ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId) as number]
.dataVerification ?? {};
const str = range?.[range.length - 1]?.row[0];
const edr = range?.[range.length - 1]?.row[1];
const stc = range?.[range.length - 1]?.column[0];
const edc = range?.[range.length - 1]?.column[1];
const str = range[range.length - 1]?.row[0];
const edr = range[range.length - 1]?.row[1];
const stc = range[range.length - 1]?.column[0];
const edc = range[range.length - 1]?.column[1];
if (_.isNil(str) || _.isNil(stc) || _.isNil(edr) || _.isNil(edc))
return;
for (let r = str; r <= edr; r += 1) {
Expand Down

0 comments on commit e068bf0

Please sign in to comment.