Skip to content

Commit eafc5fc

Browse files
cmdcolinclaude
andcommitted
re-enable eslint rules and fix violations
Re-enable 17 previously disabled rules that now have zero violations. Fix node: protocol imports, top-level await, for-of loops, ternary style. Add eqeqeq rule for strict equality. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c4f835e commit eafc5fc

21 files changed

Lines changed: 54 additions & 78 deletions

eslint.config.mjs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default defineConfig(
2424
eslintPluginUnicorn.configs.recommended,
2525
{
2626
rules: {
27-
'no-empty': 'off',
27+
eqeqeq: 'error',
2828
'no-console': [
2929
'warn',
3030
{
@@ -39,15 +39,9 @@ export default defineConfig(
3939
'error',
4040
{ 'ts-expect-error': 'allow-with-description', 'ts-ignore': true },
4141
],
42-
'@typescript-eslint/no-explicit-any': 'warn',
42+
'@typescript-eslint/no-explicit-any': 'error',
4343
'@typescript-eslint/no-non-null-assertion': 'off',
44-
'@typescript-eslint/no-unsafe-member-access': 'off',
45-
'@typescript-eslint/no-unsafe-argument': 'off',
46-
'@typescript-eslint/no-unsafe-assignment': 'off',
47-
'@typescript-eslint/no-unsafe-call': 'off',
48-
'@typescript-eslint/no-unsafe-return': 'off',
49-
'@typescript-eslint/require-await': 'off',
50-
'@typescript-eslint/restrict-template-expressions': 'off',
44+
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
5145

5246
'@typescript-eslint/no-unused-vars': [
5347
'warn',
@@ -60,18 +54,6 @@ export default defineConfig(
6054

6155
'unicorn/filename-case': 'off',
6256
'unicorn/prevent-abbreviations': 'off',
63-
'unicorn/no-null': 'off',
64-
'unicorn/no-process-exit': 'off',
65-
'unicorn/prefer-module': 'off',
66-
'unicorn/prefer-top-level-await': 'off',
67-
'unicorn/no-array-for-each': 'off',
68-
'unicorn/no-for-loop': 'off',
69-
'unicorn/prefer-spread': 'off',
70-
'unicorn/consistent-function-scoping': 'off',
71-
'unicorn/prefer-node-protocol': 'off',
72-
'unicorn/no-nested-ternary': 'off',
73-
'unicorn/no-useless-undefined': 'off',
74-
'unicorn/prefer-ternary': 'off',
7557

7658
'import/extensions': ['error', 'ignorePackages'],
7759
'import/no-unresolved': 'off',

src/TrixInputTransform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Transform } from 'stream'
1+
import { Transform } from 'node:stream'
22

33
export class TrixInputTransform extends Transform {
44
_transform(chunk: Buffer, _encoding: unknown, done: () => void) {

src/TrixOutputTransform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Transform } from 'stream'
1+
import { Transform } from 'node:stream'
22

33
function elt(buff: string[], current: string) {
44
return current + buff.map((b, i) => ` ${b},${i + 1}`).join('') + '\n'

src/bin.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ if (!file) {
88
console.log('usage: ixixx file.txt [out.ix] [out.ixx]')
99
process.exit(1)
1010
}
11-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
12-
;(async () => {
13-
try {
14-
await ixIxx(file, out1, out2)
15-
} catch (error) {
16-
console.error(error)
17-
process.exit(1)
18-
}
19-
})()
11+
try {
12+
await ixIxx(file, out1, out2)
13+
} catch (error) {
14+
console.error(error)
15+
process.exit(1)
16+
}

src/externalSort.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import fs from 'fs'
2-
import path from 'path'
3-
import { pipeline } from 'stream/promises'
1+
import fs from 'node:fs'
2+
import path from 'node:path'
3+
import { pipeline } from 'node:stream/promises'
44

5-
import type { Readable, Writable } from 'stream'
5+
import type { Readable, Writable } from 'node:stream'
66

77
const EOF = Symbol('EOF')
88

@@ -92,7 +92,7 @@ function compare(a: string | typeof EOF, b: string | typeof EOF): number {
9292
if (b === EOF) {
9393
return -1
9494
}
95-
return a < b ? -1 : a > b ? 1 : 0
95+
return a < b ? -1 : (a > b ? 1 : 0)
9696
}
9797

9898
function heapify(harr: HeapItem[], i: number, heapSize: number) {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeIx, makeIxStream } from './makeIx.ts'
22
import { makeIxx } from './makeIxx.ts'
33

4-
import type { Readable } from 'stream'
4+
import type { Readable } from 'node:stream'
55

66
// this file (index.ts) is a translation of ixIxx.c from ucscGenomeBrowser/kent
77
// the license of that file is reproduced below

src/makeIx.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { spawn } from 'child_process'
2-
import fs from 'fs'
3-
import { PassThrough } from 'stream'
4-
import { pipeline } from 'stream/promises'
1+
import { spawn } from 'node:child_process'
2+
import fs from 'node:fs'
3+
import { PassThrough } from 'node:stream'
4+
import { pipeline } from 'node:stream/promises'
55

66
import { sync as commandExistsSync } from 'command-exists'
77
import split2 from 'split2'
@@ -10,7 +10,7 @@ import { TrixInputTransform } from './TrixInputTransform.ts'
1010
import { TrixOutputTransform } from './TrixOutputTransform.ts'
1111
import { sortLinesExternal } from './sortLines.ts'
1212

13-
import type { Readable } from 'stream'
13+
import type { Readable } from 'node:stream'
1414

1515
const isWin =
1616
typeof process === 'undefined' ? false : process.platform === 'win32'
@@ -73,11 +73,9 @@ export async function makeIxStream(
7373
fileStream: Readable,
7474
outIxFilename: string,
7575
) {
76-
if (useExternalSort) {
77-
await makeIxWithExternalSort(fileStream, outIxFilename)
78-
} else {
79-
await makeIxWithJsSort(fileStream, outIxFilename)
80-
}
76+
await (useExternalSort
77+
? makeIxWithExternalSort(fileStream, outIxFilename)
78+
: makeIxWithJsSort(fileStream, outIxFilename))
8179
}
8280

8381
export async function makeIx(inFile: string, outIndex: string) {

src/makeIxx.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { once } from 'events'
2-
import fs from 'fs'
3-
import readline from 'readline'
4-
import { finished } from 'stream/promises'
1+
import { once } from 'node:events'
2+
import fs from 'node:fs'
3+
import readline from 'node:readline'
4+
import { finished } from 'node:stream/promises'
55

66
import { optimizePrefixSize } from './optimizePrefixSize.ts'
77
import { binSize, getPrefix } from './util.ts'

src/optimizePrefixSize.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs'
2-
import readline from 'readline'
1+
import fs from 'node:fs'
2+
import readline from 'node:readline'
33

44
import { binSize, getPrefix } from './util.ts'
55

@@ -63,9 +63,8 @@ export async function optimizePrefixSize(inIx: string) {
6363
const spaceIdx = line.indexOf(' ')
6464
const word = spaceIdx === -1 ? line : line.slice(0, spaceIdx)
6565

66-
for (let i = 0; i < stats.length; i++) {
66+
for (const [i, s] of stats.entries()) {
6767
const prefixSize = MIN_PREFIX + i
68-
const s = stats[i]!
6968
const curPrefix = getPrefix(word, prefixSize)
7069

7170
if (curPrefix !== s.lastPrefix) {
@@ -87,8 +86,8 @@ export async function optimizePrefixSize(inIx: string) {
8786
}
8887

8988
// Find first prefix size that meets heuristics
90-
for (let i = 0; i < stats.length; i++) {
91-
if (meetsHeuristics(stats[i]!, bytes)) {
89+
for (const [i, s] of stats.entries()) {
90+
if (meetsHeuristics(s, bytes)) {
9291
return MIN_PREFIX + i
9392
}
9493
}

src/sortLines.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import fs from 'fs'
1+
import fs from 'node:fs'
22

33
import tmp from 'tmp'
44

55
import { externalSort } from './externalSort.ts'
66

7-
import type { Readable, Writable } from 'stream'
7+
import type { Readable, Writable } from 'node:stream'
88

99
/**
1010
* Sort lines from input stream and write to output stream using external merge sort.

0 commit comments

Comments
 (0)