Skip to content

Commit 6c406e4

Browse files
tolokobanloris-maru
authored andcommitted
Fix all lint issues (#324)
All the lint errors have been fixed. We should now prevent Github from merging if the linter has not been successful.
1 parent 3ea9b1d commit 6c406e4

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

package-lock.json

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/explore-section/Circuit/global/Columns.tsx

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { ColumnsType } from 'antd/es/table';
1+
import { ColumnsType, ColumnType } from 'antd/es/table';
22
import Link from 'next/link';
3-
import { Key, SyntheticEvent } from 'react';
3+
import { Key, ReactEventHandler, SyntheticEvent } from 'react';
44
import { ResizeCallbackData } from 'react-resizable';
55
import { CircuitSchemaProps } from '../type';
66

77
import { ChevronRight } from '@/components/icons';
88
import { classNames } from '@/util/utils';
9+
import { ensureNumber } from '@/util/type-guards';
910

1011
export type ResizableColumnType = ColumnsType<CircuitSchemaProps>[number] & {
1112
onHeaderCell?: (column: ResizableColumnType) => React.HTMLAttributes<HTMLElement> & {
@@ -14,6 +15,10 @@ export type ResizableColumnType = ColumnsType<CircuitSchemaProps>[number] & {
1415
};
1516
};
1617

18+
type HeaderCellHandler = ReactEventHandler<any> &
19+
ReactEventHandler<HTMLElement> &
20+
((e: SyntheticEvent, data: ResizeCallbackData) => void);
21+
1722
const columns = (
1823
expandedRowKeys: Key | Key[],
1924
calculateSubcircuitsForParent: (row: CircuitSchemaProps) => number,
@@ -29,9 +34,9 @@ const columns = (
2934
{record.name}
3035
</Link>
3136
),
32-
onHeaderCell: (column) => ({
33-
width: column.width ?? 150,
34-
onResize: handleResize(column.key as string),
37+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
38+
width: ensureNumber(column.width, 150),
39+
onResize: handleResize(column.key as string) as HeaderCellHandler,
3540
}),
3641
},
3742
{
@@ -65,9 +70,9 @@ const columns = (
6570
</button>
6671
);
6772
},
68-
onHeaderCell: (column) => ({
69-
width: column.width ?? 150,
70-
onResize: handleResize(column.key as string),
73+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
74+
width: ensureNumber(column.width, 150),
75+
onResize: handleResize(column.key as string) as HeaderCellHandler,
7176
}),
7277
},
7378
{
@@ -77,9 +82,9 @@ const columns = (
7782
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
7883
<div className="text-ellipsis whitespace-nowrap font-normal">{record.description}</div>
7984
),
80-
onHeaderCell: (column) => ({
81-
width: column.width ?? 150,
82-
onResize: handleResize(column.key as string),
85+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
86+
width: ensureNumber(column.width, 150),
87+
onResize: handleResize(column.key as string) as HeaderCellHandler,
8388
}),
8489
},
8590
{
@@ -89,9 +94,9 @@ const columns = (
8994
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
9095
<div className="whitespace-nowrap font-normal">{record.brainRegion}</div>
9196
),
92-
onHeaderCell: (column) => ({
93-
width: column.width ?? 150,
94-
onResize: handleResize(column.key as string),
97+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
98+
width: ensureNumber(column.width, 150),
99+
onResize: handleResize(column.key as string) as HeaderCellHandler,
95100
}),
96101
},
97102
{
@@ -101,9 +106,9 @@ const columns = (
101106
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
102107
<div className="whitespace-nowrap font-normal">{record.numberOfNeurons}</div>
103108
),
104-
onHeaderCell: (column) => ({
105-
width: column.width ?? 150,
106-
onResize: handleResize(column.key as string),
109+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
110+
width: ensureNumber(column.width, 150),
111+
onResize: handleResize(column.key as string) as HeaderCellHandler,
107112
}),
108113
},
109114
{
@@ -113,9 +118,9 @@ const columns = (
113118
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
114119
<div className="whitespace-nowrap font-normal">{record.species}</div>
115120
),
116-
onHeaderCell: (column) => ({
117-
width: column.width ?? 150,
118-
onResize: handleResize(column.key as string),
121+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
122+
width: ensureNumber(column.width, 150),
123+
onResize: handleResize(column.key as string) as HeaderCellHandler,
119124
}),
120125
},
121126
{
@@ -125,9 +130,9 @@ const columns = (
125130
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
126131
<div className="whitespace-nowrap font-normal">{record.metadata.contributorSimple}</div>
127132
),
128-
onHeaderCell: (column) => ({
129-
width: column.width ?? 150,
130-
onResize: handleResize(column.key as string),
133+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
134+
width: ensureNumber(column.width, 150),
135+
onResize: handleResize(column.key as string) as HeaderCellHandler,
131136
}),
132137
},
133138
{
@@ -137,9 +142,9 @@ const columns = (
137142
render: (_value: any, record: CircuitSchemaProps, _index: number) => (
138143
<div className="whitespace-nowrap font-normal">{record.metadata.registrationDate}</div>
139144
),
140-
onHeaderCell: (column) => ({
141-
width: column.width ?? 150,
142-
onResize: handleResize(column.key as string),
145+
onHeaderCell: (column: ColumnType<CircuitSchemaProps>) => ({
146+
width: ensureNumber(column.width, 150),
147+
onResize: handleResize(column.key as string) as HeaderCellHandler,
143148
}),
144149
},
145150
];

src/components/explore-section/Circuit/utils/filter-circuits.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export const filterCircuits = (
1212
(circuit.name?.toLowerCase().includes(lowerCaseQuery) ?? false) ||
1313
(circuit.brainRegion?.toLowerCase().includes(lowerCaseQuery) ?? false);
1414

15-
const filteredSubcircuits = circuit.subcircuit
16-
? filterCircuits(circuit.subcircuit, query)
15+
const filteredSubcircuits = circuit.subcircuits
16+
? filterCircuits(circuit.subcircuits, query)
1717
: [];
1818

1919
if (matches || filteredSubcircuits.length > 0) {
@@ -25,5 +25,5 @@ export const filterCircuits = (
2525

2626
return null;
2727
})
28-
.filter((circuit): circuit is CircuitSchemaProps => circuit !== null);
28+
.filter((circuit) => circuit !== null);
2929
};

0 commit comments

Comments
 (0)