Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 29, 2024
1 parent e2cd381 commit 729a220
Show file tree
Hide file tree
Showing 13 changed files with 1,235 additions and 723 deletions.
16 changes: 0 additions & 16 deletions .eslintrc.json

This file was deleted.

124 changes: 84 additions & 40 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,56 +1,100 @@
import prettier from 'eslint-plugin-prettier'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
import eslint from '@eslint/js'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import tseslint from 'typescript-eslint'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

export default [
...compat.extends(
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:prettier/recommended',
'plugin:unicorn/recommended',
),
export default tseslint.config(
{
ignores: [
'webpack.config.js',
'dist/*',
'esm/*',
'example/*',
'eslint.config.mjs',
],
},
{
plugins: {
prettier,
'@typescript-eslint': typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
project: './tsconfig.lint.json',
project: ['./tsconfig.lint.json'],
tsconfigRootDir: import.meta.dirname,
},
},
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylisticTypeChecked,
...tseslint.configs.strictTypeChecked,

eslintPluginUnicorn.configs['flat/recommended'],
{
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],

'no-underscore-dangle': 0,
curly: 'error',
'unicorn/prefer-node-protocol': 0,
'unicorn/numeric-separators-style': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/no-new-array': 0,
'unicorn/filename-case': 0,
'@typescript-eslint/restrict-template-expressions': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/ban-ts-comment': 0,
semi: ['error', 'never'],
'unicorn/no-new-array': 'off',
'unicorn/no-empty-file': 'off',
'unicorn/prefer-type-error': 'off',
'unicorn/prefer-modern-math-apis': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/no-unreadable-array-destructuring': 'off',
'unicorn/no-abusive-eslint-disable': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/number-literal-case': 'off',
'unicorn/prefer-add-event-listener': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-lonely-if': 'off',
'unicorn/consistent-destructuring': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-optional-catch-binding': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/no-null': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/filename-case': 'off',
'unicorn/catch-error-name': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/numeric-separators-style': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/explicit-length-check': 'off',
'unicorn/prefer-regexp-test': 'off',
'unicorn/relative-url-style': 'off',
'unicorn/prefer-math-trunc': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/switch-case-braces': 'off',
'unicorn/prefer-switch': 'off',
'unicorn/better-regex': 'off',
'unicorn/no-for-loop': 'off',
'unicorn/escape-case': 'off',
'unicorn/prefer-number-properties': 'off',
'unicorn/no-process-exit': 'off',
'unicorn/prefer-at': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-empty': 'off',
},
},
]
)
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"src"
],
"scripts": {
"test": "jest",
"lint": "eslint --report-unused-disable-directives --max-warnings 0 src test",
"test": "vitest",
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
"clean": "rimraf dist esm",
"prebuild": "npm run clean",
"build:esm": "tsc --target es2018 --outDir esm",
"build:es5": "tsc --target es2015 --module commonjs --outDir dist",
"build": "npm run build:esm && npm run build:es5",
"prepublishOnly": "npm test && npm run build",
"prepublishOnly": "npm test --run && npm run build",
"postversion": "git push --follow-tags"
},
"keywords": [
Expand All @@ -42,27 +42,25 @@
},
"devDependencies": {
"@types/es6-promisify": "^6.0.0",
"@types/jest": "^29.5.2",
"@types/long": "^4.0.1",
"@types/node": "^20.14.11",
"@types/node": "^22.10.1",
"@types/pako": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^54.0.0",
"jest": "^29.5.0",
"eslint-plugin-unicorn": "^56.0.1",
"prettier": "^3.2.5",
"rimraf": "^6.0.1",
"ts-jest": "^29.1.0",
"typescript": "^5.1.3"
"typescript": "^5.1.3",
"typescript-eslint": "^8.16.0",
"vitest": "^2.1.6"
},
"publishConfig": {
"access": "public"
},
"browser": {
"./esm/unzip.js": "./esm/unzip-pako.js"
"./esm/unzip.js": "./esm/unzip-pako.js",
"./dist/unzip.js": "./dist/unzip-pako.js"
}
}
1 change: 1 addition & 0 deletions src/bgzFilehandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class BgzFilehandle {
// read the last block's ISIZE (see gzip RFC),
// and add it to its uncompressedPosition
const ret = await this.gzi.getLastBlock()
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!ret) {
throw new Error('no blocks')
}
Expand Down
1 change: 1 addition & 0 deletions src/gziIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default class GziIndex {
// read starts in and extend forward from that
const compare = (entry: number[], nextEntry: number[]) => {
const uncompressedPosition = entry[UNCOMPRESSED_POSITION]
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const nextUncompressedPosition = nextEntry
? nextEntry[UNCOMPRESSED_POSITION]
: Infinity
Expand Down
25 changes: 10 additions & 15 deletions src/unzip-pako.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Chunk {
// in a browser.
//
//
// eslint-disable-next-line @typescript-eslint/require-await

async function unzip(inputData: Buffer) {
try {
let strm
Expand All @@ -31,18 +31,16 @@ async function unzip(inputData: Buffer) {
inflator = new Inflate()
//@ts-ignore
;({ strm } = inflator)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument

inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) {
throw new Error(inflator.msg)
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
pos += strm.next_in
chunks[i] = inflator.result as Uint8Array
totalSize += chunks[i].length
i += 1
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} while (strm.avail_in)

const result = new Uint8Array(totalSize)
Expand All @@ -53,7 +51,7 @@ async function unzip(inputData: Buffer) {
return Buffer.from(result)
} catch (error) {
//cleanup error message
if (/incorrect header check/.test(`${error}`)) {
if (`${error}`.includes('incorrect header check')) {
throw new Error(
'problem decompressing block: incorrect gzip header check',
)
Expand All @@ -65,7 +63,7 @@ async function unzip(inputData: Buffer) {
// similar to pakounzip, except it does extra counting to return the positions
// of compressed and decompressed data offsets
//
// eslint-disable-next-line @typescript-eslint/require-await

async function unzipChunk(inputData: Buffer) {
try {
let strm
Expand All @@ -79,7 +77,7 @@ async function unzipChunk(inputData: Buffer) {
const inflator = new Inflate()
// @ts-ignore
;({ strm } = inflator)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument

inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) {
throw new Error(inflator.msg)
Expand All @@ -91,17 +89,15 @@ async function unzipChunk(inputData: Buffer) {
cpositions.push(cpos)
dpositions.push(dpos)

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
cpos += strm.next_in
dpos += buffer.length
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} while (strm.avail_in)

const buffer = Buffer.concat(blocks)
return { buffer, cpositions, dpositions }
} catch (error) {
//cleanup error message
if (/incorrect header check/.test(`${error}`)) {
if (`${error}`.includes('incorrect header check')) {
throw new Error(
'problem decompressing block: incorrect gzip header check',
)
Expand All @@ -113,7 +109,7 @@ async function unzipChunk(inputData: Buffer) {
// similar to unzipChunk above but slices (0,minv.dataPosition) and
// (maxv.dataPosition,end) off
//
// eslint-disable-next-line @typescript-eslint/require-await

async function unzipChunkSlice(inputData: Buffer, chunk: Chunk) {
try {
let strm
Expand All @@ -131,7 +127,7 @@ async function unzipChunkSlice(inputData: Buffer, chunk: Chunk) {
const inflator = new Inflate()
// @ts-ignore
;({ strm } = inflator)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument

inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) {
throw new Error(inflator.msg)
Expand All @@ -149,7 +145,7 @@ async function unzipChunkSlice(inputData: Buffer, chunk: Chunk) {
len = chunks[0].length
}
const origCpos = cpos
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access

cpos += strm.next_in
dpos += len

Expand All @@ -172,7 +168,6 @@ async function unzipChunkSlice(inputData: Buffer, chunk: Chunk) {
}
totalSize += chunks[i].length
i++
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} while (strm.avail_in)

const result = new Uint8Array(totalSize)
Expand All @@ -185,7 +180,7 @@ async function unzipChunkSlice(inputData: Buffer, chunk: Chunk) {
return { buffer, cpositions, dpositions }
} catch (error) {
//cleanup error message
if (/incorrect header check/.test(`${error}`)) {
if (`${error}`.includes('incorrect header check')) {
throw new Error(
'problem decompressing block: incorrect gzip header check',
)
Expand Down
1 change: 1 addition & 0 deletions src/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const gunzip = promisify(zlib.gunzip)
function nodeUnzip(input: Buffer): Promise<Buffer> {
//@ts-ignore
return gunzip(input, {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
finishFlush: (zlib.constants || zlib).Z_SYNC_FLUSH,
})
}
Expand Down
Loading

0 comments on commit 729a220

Please sign in to comment.