TWNTY-3794 - ESLint rule: only take explicit boolean predicates in if statements (#4354)

* ESLint rule: only take explicit boolean predicates in if statements

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Merge main

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Fix frontend linter errors

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Fix jest

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Refactor according to review

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Refactor according to review

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

* Fix lint on new code

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>
This commit is contained in:
gitstart-app[bot]
2024-03-09 10:48:19 +01:00
committed by GitHub
parent 40bea0d95e
commit 17511be0cf
164 changed files with 655 additions and 367 deletions

View File

@ -95,7 +95,7 @@ export const UploadFlow = ({ nextStep }: UploadFlowProps) => {
const isSingleSheet = workbook.SheetNames.length === 1;
if (isSingleSheet) {
if (
maxRecords &&
maxRecords > 0 &&
exceedsMaxRecords(
workbook.Sheets[workbook.SheetNames[0]],
maxRecords,
@ -147,7 +147,7 @@ export const UploadFlow = ({ nextStep }: UploadFlowProps) => {
sheetNames={state.workbook.SheetNames}
onContinue={async (sheetName) => {
if (
maxRecords &&
maxRecords > 0 &&
exceedsMaxRecords(state.workbook.Sheets[sheetName], maxRecords)
) {
errorToast(

View File

@ -14,6 +14,7 @@ import { useDialogManager } from '@/ui/feedback/dialog-manager/hooks/useDialogMa
import { Button } from '@/ui/input/button/components/Button';
import { Toggle } from '@/ui/input/components/Toggle';
import { Modal } from '@/ui/layout/modal/components/Modal';
import { isNonNullable } from '~/utils/isNonNullable';
import { generateColumns } from './components/columns';
import { Meta } from './types';
@ -94,7 +95,7 @@ export const ValidationStep = <T extends string>({
);
const deleteSelectedRows = () => {
if (selectedRows.size) {
if (selectedRows.size > 0) {
const newData = data.filter((value) => !selectedRows.has(value.__index));
updateData(newData);
setSelectedRows(new Set());
@ -129,7 +130,7 @@ export const ValidationStep = <T extends string>({
const tableData = useMemo(() => {
if (filterByErrors) {
return data.filter((value) => {
if (value?.__errors) {
if (isNonNullable(value?.__errors)) {
return Object.values(value.__errors)?.filter(
(err) => err.level === 'error',
).length;
@ -146,7 +147,7 @@ export const ValidationStep = <T extends string>({
const calculatedData = data.reduce(
(acc, value) => {
const { __index, __errors, ...values } = value;
if (__errors) {
if (isNonNullable(__errors)) {
for (const key in __errors) {
if (__errors[key].level === 'error') {
acc.invalidData.push(values as unknown as Data<T>);
@ -165,7 +166,7 @@ export const ValidationStep = <T extends string>({
};
const onContinue = () => {
const invalidData = data.find((value) => {
if (value?.__errors) {
if (isNonNullable(value?.__errors)) {
return !!Object.values(value.__errors)?.filter(
(err) => err.level === 'error',
).length;

View File

@ -9,6 +9,7 @@ import { AppTooltip } from '@/ui/display/tooltip/AppTooltip';
import { Checkbox, CheckboxVariant } from '@/ui/input/components/Checkbox';
import { TextInput } from '@/ui/input/components/TextInput';
import { Toggle } from '@/ui/input/components/Toggle';
import { isNonNullable } from '~/utils/isNonNullable';
import { Meta } from '../types';
@ -207,7 +208,7 @@ export const generateColumns = <T extends string>(
);
}
if (row.__errors?.[columnKey]) {
if (isNonNullable(row.__errors?.[columnKey])) {
return (
<>
{component}