Skip to content

Commit 5edde42

Browse files
cmdcolinclaude
andcommitted
Replace eslint-plugin-import with eslint-plugin-import-x
Modern fork with better performance and fewer dependencies. Updates eslint config to use import-x rules. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent 12ddec7 commit 5edde42

22 files changed

Lines changed: 497 additions & 1406 deletions

eslint.config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import eslint from '@eslint/js'
22
import { defineConfig } from 'eslint/config'
3-
import importPlugin from 'eslint-plugin-import'
3+
import importPlugin from 'eslint-plugin-import-x'
44
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
55
import tseslint from 'typescript-eslint'
66

@@ -110,9 +110,9 @@ export default defineConfig(
110110
},
111111
],
112112

113-
'import/no-unresolved': 'off',
114-
'import/extensions': ['error', 'ignorePackages'],
115-
'import/order': [
113+
'import-x/no-unresolved': 'off',
114+
'import-x/extensions': ['error', 'ignorePackages'],
115+
'import-x/order': [
116116
'error',
117117
{
118118
named: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"buffer": "^6.0.3",
6767
"documentation": "^14.0.3",
6868
"eslint": "^10.2.1",
69-
"eslint-plugin-import": "^2.32.0",
69+
"eslint-plugin-import-x": "^4.16.2",
7070
"eslint-plugin-unicorn": "^64.0.0",
7171
"mock-fs": "^5.5.0",
7272
"prettier": "^3.8.3",

pnpm-lock.yaml

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

src/craiIndex.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ type ParsedIndex = Record<string, Slice[] | undefined>
2020
function addRecordToIndex(index: ParsedIndex, record: number[]) {
2121
const [seqId, start, span, containerStart, sliceStart, sliceBytes] = record
2222

23-
const s = seqId!
23+
const s = seqId
2424
if (!index[s]) {
2525
index[s] = []
2626
}
2727

2828
index[s].push({
29-
start: start!,
30-
span: span!,
31-
containerStart: containerStart!,
32-
sliceStart: sliceStart!,
33-
sliceBytes: sliceBytes!,
29+
start: start,
30+
span: span,
31+
containerStart: containerStart,
32+
sliceStart: sliceStart,
33+
sliceBytes: sliceBytes,
3434
})
3535
}
3636

src/cramFile/codecs/beta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function decodeBetaInline(
4646

4747
// Fast path: reading exactly 8 bits when byte-aligned
4848
if (numBits === 8 && bitPosition === 7) {
49-
const val = data[bytePosition]!
49+
const val = data[bytePosition]
5050
cursor.bytePosition = bytePosition + 1
5151
return val - offset
5252
}
@@ -55,7 +55,7 @@ function decodeBetaInline(
5555
let val = 0
5656
for (let i = 0; i < numBits; i++) {
5757
val <<= 1
58-
val |= (data[bytePosition]! >> bitPosition) & 1
58+
val |= (data[bytePosition] >> bitPosition) & 1
5959
bitPosition -= 1
6060
if (bitPosition < 0) {
6161
bytePosition += 1

src/cramFile/codecs/external.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@ export function batchDecodeItf8(buffer: Uint8Array) {
1717
const len = buffer.length
1818

1919
while (pos < len) {
20-
const b0 = buffer[pos]!
20+
const b0 = buffer[pos]
2121
if (b0 < 0x80) {
2222
result[count++] = b0
2323
pos += 1
2424
} else if (b0 < 0xc0) {
25-
result[count++] = ((b0 & 0x3f) << 8) | buffer[pos + 1]!
25+
result[count++] = ((b0 & 0x3f) << 8) | buffer[pos + 1]
2626
pos += 2
2727
} else if (b0 < 0xe0) {
2828
result[count++] =
29-
((b0 & 0x1f) << 16) | (buffer[pos + 1]! << 8) | buffer[pos + 2]!
29+
((b0 & 0x1f) << 16) | (buffer[pos + 1] << 8) | buffer[pos + 2]
3030
pos += 3
3131
} else if (b0 < 0xf0) {
3232
result[count++] =
3333
((b0 & 0x0f) << 24) |
34-
(buffer[pos + 1]! << 16) |
35-
(buffer[pos + 2]! << 8) |
36-
buffer[pos + 3]!
34+
(buffer[pos + 1] << 16) |
35+
(buffer[pos + 2] << 8) |
36+
buffer[pos + 3]
3737
pos += 4
3838
} else {
3939
result[count++] =
4040
((b0 & 0x0f) << 28) |
41-
(buffer[pos + 1]! << 20) |
42-
(buffer[pos + 2]! << 12) |
43-
(buffer[pos + 3]! << 4) |
44-
(buffer[pos + 4]! & 0x0f)
41+
(buffer[pos + 1] << 20) |
42+
(buffer[pos + 2] << 12) |
43+
(buffer[pos + 3] << 4) |
44+
(buffer[pos + 4] & 0x0f)
4545
pos += 5
4646
}
4747
}
@@ -54,39 +54,39 @@ export function parseItf8(
5454
cursor: { bytePosition: number },
5555
) {
5656
const offset = cursor.bytePosition
57-
const countFlags = buffer[offset]!
57+
const countFlags = buffer[offset]
5858
if (countFlags < 0x80) {
5959
cursor.bytePosition = offset + 1
6060
return countFlags
6161
}
6262
if (countFlags < 0xc0) {
6363
cursor.bytePosition = offset + 2
64-
return ((countFlags & 0x3f) << 8) | buffer[offset + 1]!
64+
return ((countFlags & 0x3f) << 8) | buffer[offset + 1]
6565
}
6666
if (countFlags < 0xe0) {
6767
cursor.bytePosition = offset + 3
6868
return (
6969
((countFlags & 0x1f) << 16) |
70-
(buffer[offset + 1]! << 8) |
71-
buffer[offset + 2]!
70+
(buffer[offset + 1] << 8) |
71+
buffer[offset + 2]
7272
)
7373
}
7474
if (countFlags < 0xf0) {
7575
cursor.bytePosition = offset + 4
7676
return (
7777
((countFlags & 0x0f) << 24) |
78-
(buffer[offset + 1]! << 16) |
79-
(buffer[offset + 2]! << 8) |
80-
buffer[offset + 3]!
78+
(buffer[offset + 1] << 16) |
79+
(buffer[offset + 2] << 8) |
80+
buffer[offset + 3]
8181
)
8282
}
8383
cursor.bytePosition = offset + 5
8484
return (
8585
((countFlags & 0x0f) << 28) |
86-
(buffer[offset + 1]! << 20) |
87-
(buffer[offset + 2]! << 12) |
88-
(buffer[offset + 3]! << 4) |
89-
(buffer[offset + 4]! & 0x0f)
86+
(buffer[offset + 1] << 20) |
87+
(buffer[offset + 2] << 12) |
88+
(buffer[offset + 3] << 4) |
89+
(buffer[offset + 4] & 0x0f)
9090
)
9191
}
9292

@@ -118,7 +118,7 @@ export default class ExternalCodec extends CramCodec<
118118
if (this.dataType === 'int') {
119119
const preDecoded = cursors.preDecodedIntBlocks?.get(this.blockContentId)
120120
if (preDecoded) {
121-
return preDecoded.values[preDecoded.index++]!
121+
return preDecoded.values[preDecoded.index++]
122122
}
123123
const contentBlock = blocksByContentId[this.blockContentId]
124124
if (!contentBlock) {
@@ -137,7 +137,7 @@ export default class ExternalCodec extends CramCodec<
137137
'attempted to read beyond end of block. this file seems truncated.',
138138
)
139139
}
140-
return contentBlock.content[cursor.bytePosition++]!
140+
return contentBlock.content[cursor.bytePosition++]
141141
}
142142
}
143143

src/cramFile/codecs/gamma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function decodeGammaInline(
4848
// Inline single-bit reads for the while loop
4949
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
5050
while (true) {
51-
const bit = (data[bytePosition]! >> bitPosition) & 1
51+
const bit = (data[bytePosition] >> bitPosition) & 1
5252
bitPosition -= 1
5353
if (bitPosition < 0) {
5454
bytePosition += 1
@@ -67,7 +67,7 @@ function decodeGammaInline(
6767
// Optimized multi-bit read
6868
for (let i = 0; i < bitsToRead; i++) {
6969
readBits <<= 1
70-
readBits |= (data[bytePosition]! >> bitPosition) & 1
70+
readBits |= (data[bytePosition] >> bitPosition) & 1
7171
bitPosition -= 1
7272
if (bitPosition < 0) {
7373
bytePosition += 1

src/cramFile/codecs/getBits.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export function getBits(
1818

1919
// Fast path: reading exactly 8 bits when byte-aligned
2020
if (numBits === 8 && cursor.bitPosition === 7) {
21-
const val = data[cursor.bytePosition]!
21+
const val = data[cursor.bytePosition]
2222
cursor.bytePosition += 1
2323
return val
2424
}
2525

2626
// Fast path: reading exactly 1 bit
2727
if (numBits === 1) {
28-
const val = (data[cursor.bytePosition]! >> cursor.bitPosition) & 1
28+
const val = (data[cursor.bytePosition] >> cursor.bitPosition) & 1
2929
cursor.bitPosition -= 1
3030
if (cursor.bitPosition < 0) {
3131
cursor.bytePosition += 1
@@ -38,7 +38,7 @@ export function getBits(
3838
let val = 0
3939
for (let dlen = numBits; dlen; dlen--) {
4040
val <<= 1
41-
val |= (data[cursor.bytePosition]! >> cursor.bitPosition) & 1
41+
val |= (data[cursor.bytePosition] >> cursor.bitPosition) & 1
4242
cursor.bitPosition -= 1
4343
if (cursor.bitPosition < 0) {
4444
cursor.bytePosition += 1

src/cramFile/codecs/huffman.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function getBitsInline(
1717

1818
// Fast path for single bit (common in huffman)
1919
if (numBits === 1) {
20-
const val = (data[bytePosition]! >> bitPosition) & 1
20+
const val = (data[bytePosition] >> bitPosition) & 1
2121
bitPosition -= 1
2222
if (bitPosition < 0) {
2323
bytePosition += 1
@@ -32,7 +32,7 @@ function getBitsInline(
3232
let val = 0
3333
for (let i = 0; i < numBits; i++) {
3434
val <<= 1
35-
val |= (data[bytePosition]! >> bitPosition) & 1
35+
val |= (data[bytePosition] >> bitPosition) & 1
3636
bitPosition -= 1
3737
if (bitPosition < 0) {
3838
bytePosition += 1
@@ -87,7 +87,7 @@ export default class HuffmanIntCodec extends CramCodec<
8787
// degenerate zero-length huffman code: special-case the decoding.
8888
// empty codeBook (no codes at all) is also valid for unused data series;
8989
// decode() will throw 'Huffman symbol not found' if such a codec is used.
90-
if (this.sortedCodes.length > 0 && this.sortedCodes[0]!.bitLength === 0) {
90+
if (this.sortedCodes.length > 0 && this.sortedCodes[0].bitLength === 0) {
9191
this._decode = this._decodeZeroLengthCode
9292
}
9393
}
@@ -99,8 +99,8 @@ export default class HuffmanIntCodec extends CramCodec<
9999
)
100100
for (let i = 0; i < this.parameters.numCodes; i++) {
101101
codes[i] = {
102-
symbol: this.parameters.symbols[i]!,
103-
bitLength: this.parameters.bitLengths[i]!,
102+
symbol: this.parameters.symbols[i],
103+
bitLength: this.parameters.bitLengths[i],
104104
}
105105
}
106106
// sort the codes by bit length and symbol value
@@ -113,7 +113,7 @@ export default class HuffmanIntCodec extends CramCodec<
113113
if (!this.codeBook[code.bitLength]) {
114114
this.codeBook[code.bitLength] = []
115115
}
116-
this.codeBook[code.bitLength]!.push(code.symbol)
116+
this.codeBook[code.bitLength].push(code.symbol)
117117
})
118118
}
119119

@@ -159,7 +159,7 @@ export default class HuffmanIntCodec extends CramCodec<
159159

160160
this.bitCodeToValue = new Array(maxBitCode + 1).fill(-1)
161161
for (let i = 0; i < this.sortedBitCodes.length; i += 1) {
162-
this.bitCodeToValue[this.sortedCodes[i]!.bitCode] = i
162+
this.bitCodeToValue[this.sortedCodes[i].bitCode] = i
163163
}
164164
}
165165

@@ -178,7 +178,7 @@ export default class HuffmanIntCodec extends CramCodec<
178178

179179
// the special case for zero-length codes
180180
_decodeZeroLengthCode() {
181-
return this.sortedCodes[0]!.value
181+
return this.sortedCodes[0].value
182182
}
183183

184184
_decode(_slice: CramSlice, coreDataBlock: CramFileBlock, coreCursor: Cursor) {
@@ -187,22 +187,22 @@ export default class HuffmanIntCodec extends CramCodec<
187187
let prevLen = 0
188188
let bits = 0
189189
for (let i = 0; i < this.sortedCodes.length; i += 1) {
190-
const length = this.sortedCodes[i]!.bitLength
190+
const length = this.sortedCodes[i].bitLength
191191
const bitsToRead = length - prevLen
192192
if (bitsToRead > 0) {
193193
bits <<= bitsToRead
194194
bits |= getBitsInline(input, coreCursor, bitsToRead)
195195
}
196196
prevLen = length
197197
{
198-
const index = this.bitCodeToValue[bits]!
198+
const index = this.bitCodeToValue[bits]
199199
if (index > -1 && this.sortedBitLengthsByBitCode[index] === length) {
200-
return this.sortedValuesByBitCode[index]!
200+
return this.sortedValuesByBitCode[index]
201201
}
202202

203203
for (
204204
let j = i;
205-
this.sortedCodes[j + 1]!.bitLength === length &&
205+
this.sortedCodes[j + 1].bitLength === length &&
206206
j < this.sortedCodes.length;
207207
j += 1
208208
) {

src/cramFile/codecs/subexp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function decodeSubexpInline(
4848
let numLeadingOnes = 0
4949
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
5050
while (true) {
51-
const bit = (data[bytePosition]! >> bitPosition) & 1
51+
const bit = (data[bytePosition] >> bitPosition) & 1
5252
bitPosition -= 1
5353
if (bitPosition < 0) {
5454
bytePosition += 1
@@ -67,7 +67,7 @@ function decodeSubexpInline(
6767
let bits = 0
6868
for (let i = 0; i < b; i++) {
6969
bits <<= 1
70-
bits |= (data[bytePosition]! >> bitPosition) & 1
70+
bits |= (data[bytePosition] >> bitPosition) & 1
7171
bitPosition -= 1
7272
if (bitPosition < 0) {
7373
bytePosition += 1

0 commit comments

Comments
 (0)