From e068bf043c9a44c83d996cb1dfc0e7415c054f7b Mon Sep 17 00:00:00 2001 From: Shashank Agarwal <53386582+Corbe30@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:02:29 +0000 Subject: [PATCH] removed: unnecessary null checks --- packages/core/src/modules/ConditionFormat.ts | 24 +++++++++---------- packages/core/src/modules/dataVerification.ts | 12 +++++----- .../src/components/DataVerification/index.tsx | 16 ++++++------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/core/src/modules/ConditionFormat.ts b/packages/core/src/modules/ConditionFormat.ts index 5a371139..8b93bd79 100644 --- a/packages/core/src/modules/ConditionFormat.ts +++ b/packages/core/src/modules/ConditionFormat.ts @@ -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; @@ -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; @@ -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; diff --git a/packages/core/src/modules/dataVerification.ts b/packages/core/src/modules/dataVerification.ts index 7aebb97f..689f6bf9 100644 --- a/packages/core/src/modules/dataVerification.ts +++ b/packages/core/src/modules/dataVerification.ts @@ -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]; @@ -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; diff --git a/packages/react/src/components/DataVerification/index.tsx b/packages/react/src/components/DataVerification/index.tsx index 7b452b76..0ae2dee6 100644 --- a/packages/react/src/components/DataVerification/index.tsx +++ b/packages/react/src/components/DataVerification/index.tsx @@ -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 || @@ -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) {