Skip to content

Commit 22f0637

Browse files
cmdcolinclaude
andcommitted
Fix lint errors: add mjs/cjs ignores, replace any types with proper types in IndexData and CSI constructor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6db51b7 commit 22f0637

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

eslint.config.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default defineConfig(
1515
'profile*',
1616
'example/*',
1717
'eslint.config.mjs',
18+
'*.mjs',
19+
'*.cjs',
1820
],
1921
},
2022
{
@@ -61,9 +63,8 @@ export default defineConfig(
6163
ignoreRestSiblings: true,
6264
},
6365
],
64-
'@typescript-eslint/no-explicit-any': 'off',
65-
'@typescript-eslint/explicit-module-boundary-types': 'off',
66-
'@typescript-eslint/ban-ts-comment': 'off',
66+
'@typescript-eslint/no-explicit-any': 'warn',
67+
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description', 'ts-ignore': true }],
6768
'@typescript-eslint/no-non-null-assertion': 'off',
6869
'@typescript-eslint/restrict-template-expressions': 'off',
6970
'@typescript-eslint/no-unsafe-member-access': 'off',
@@ -72,7 +73,7 @@ export default defineConfig(
7273
'@typescript-eslint/no-unsafe-call': 'off',
7374
'@typescript-eslint/no-unsafe-return': 'off',
7475
'@typescript-eslint/prefer-nullish-coalescing': 'off',
75-
'@typescript-eslint/no-deprecated': 'off',
76+
'@typescript-eslint/no-deprecated': 'warn',
7677
'@typescript-eslint/restrict-plus-operands': 'off',
7778
'no-empty': 'off',
7879

src/csi.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { optimizeChunks } from './util.ts'
77
import VirtualOffset, { fromBytes } from './virtualOffset.ts'
88

99
import type { Options } from './indexFile.ts'
10+
import type { GenericFilehandle } from 'generic-filehandle2'
1011

1112
const CSI1_MAGIC = 21582659 // CSI\1
1213
const CSI2_MAGIC = 38359875 // CSI\2
@@ -28,7 +29,7 @@ export default class CSI extends IndexFile {
2829
private maxBinNumber: number
2930
private depth: number
3031
private minShift: number
31-
constructor(args: any) {
32+
constructor(args: { filehandle: GenericFilehandle }) {
3233
super(args)
3334
this.maxBinNumber = 0
3435
this.depth = 0
@@ -44,7 +45,7 @@ export default class CSI extends IndexFile {
4445
if (!idx) {
4546
return -1
4647
}
47-
const { stats } = indexData.indices[refId]
48+
const { stats } = idx
4849
if (stats) {
4950
return stats.lineCount
5051
}
@@ -202,8 +203,9 @@ export default class CSI extends IndexFile {
202203
// Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned
203204
for (const [start, end] of overlappingBins) {
204205
for (let bin = start; bin <= end; bin++) {
205-
if (ba.binIndex[bin]) {
206-
for (const c of ba.binIndex[bin]) {
206+
const binChunks = ba.binIndex[bin]
207+
if (binChunks) {
208+
for (const c of binChunks) {
207209
chunks.push(new Chunk(c.minv, c.maxv, bin))
208210
}
209211
}

src/indexFile.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ export interface IndexData {
1414
columnNumbers: { ref: number; start: number; end: number }
1515
coordinateType: string
1616
format: string
17-
[key: string]: any
17+
indices: { binIndex: Record<number | string, Chunk[]>; stats?: { lineCount: number }; linearIndex?: VirtualOffset[] }[]
18+
maxRefLength: number
19+
skipLines?: number
20+
maxBinNumber?: number
21+
maxBlockSize: number
22+
firstDataLine?: VirtualOffset
23+
refCount?: number
24+
csi?: boolean
25+
csiVersion?: number
26+
depth?: number
1827
}
1928

2029
export default abstract class IndexFile {

src/tbi.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class TabixIndex extends IndexFile {
3939
if (!idx) {
4040
return -1
4141
}
42-
return indexData.indices[refId].stats?.lineCount ?? -1
42+
return idx.stats?.lineCount ?? -1
4343
}
4444

4545
// fetch and parse the index
@@ -181,11 +181,12 @@ export default class TabixIndex extends IndexFile {
181181
return []
182182
}
183183

184+
const linearIndex = ba.linearIndex ?? []
184185
const minOffset =
185-
ba.linearIndex.length > 0
186-
? ba.linearIndex[
187-
min >> TAD_LIDX_SHIFT >= ba.linearIndex.length
188-
? ba.linearIndex.length - 1
186+
linearIndex.length > 0
187+
? linearIndex[
188+
min >> TAD_LIDX_SHIFT >= linearIndex.length
189+
? linearIndex.length - 1
189190
: min >> TAD_LIDX_SHIFT
190191
]
191192
: new VirtualOffset(0, 0)
@@ -201,8 +202,9 @@ export default class TabixIndex extends IndexFile {
201202
// Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned
202203
for (const [start, end] of overlappingBins) {
203204
for (let bin = start; bin <= end; bin++) {
204-
if (ba.binIndex[bin]) {
205-
for (const c of ba.binIndex[bin]) {
205+
const binChunks = ba.binIndex[bin]
206+
if (binChunks) {
207+
for (const c of binChunks) {
206208
chunks.push(new Chunk(c.minv, c.maxv, bin))
207209
}
208210
}
@@ -211,12 +213,12 @@ export default class TabixIndex extends IndexFile {
211213

212214
// Use the linear index to find minimum file position of chunks that could
213215
// contain alignments in the region
214-
const nintv = ba.linearIndex.length
216+
const nintv = linearIndex.length
215217
let lowest: VirtualOffset | undefined
216218
const minLin = Math.min(min >> 14, nintv - 1)
217219
const maxLin = Math.min(max >> 14, nintv - 1)
218220
for (let i = minLin; i <= maxLin; ++i) {
219-
const vp = ba.linearIndex[i]
221+
const vp = linearIndex[i]
220222
if (vp && (!lowest || vp.compareTo(lowest) < 0)) {
221223
lowest = vp
222224
}

0 commit comments

Comments
 (0)