Skip to content

Commit

Permalink
Switch tslint to biome
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Sep 2, 2024
1 parent 2203cf6 commit 6285e31
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 249 deletions.
56 changes: 56 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"correctness": {
"noConstantCondition": "warn",
"noUnusedImports": "error"
},
"style": {
"noParameterAssign": "off",
"useConst": "error"
},
"recommended": true,
"complexity": {
"useSimpleNumberKeys": "off", // In some files we want to use hexadecimal keys
"noForEach": "off"
},
"suspicious": {
"noEmptyBlockStatements": "error",
"noControlCharactersInRegex": "off"
},
"nursery": {
"noRestrictedImports": {
"level": "error",
"options": {
"paths": {
"node:buffer": "Use Uint8Array instead of Buffer"
}
}
},
"useConsistentBuiltinInstantiation": "error",
"useThrowNewError": "error",
"useThrowOnlyError": "error",
"useErrorMessage": "error"
}
}
},
"files": {
"ignoreUnknown": true,
"ignore": [
"./coverage",
"./yarn",
"./lib/**/*.d.ts",
"./lib/**/*.js",
"./test/**/*.d.ts",
"./test/**/*.js"
]
}
}
180 changes: 0 additions & 180 deletions lib/chunked-file-data.ts

This file was deleted.

5 changes: 2 additions & 3 deletions lib/http-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import initDebug from 'debug';

import { IHeadRequestInfo, IRangeRequestResponse, IRangeRequestClient } from '@tokenizer/range';
import type { IHeadRequestInfo, IRangeRequestResponse, IRangeRequestClient } from '@tokenizer/range';
import { ResponseInfo } from './response-info.js'; // Add 'fetch' API for node.js

const debug = initDebug('streaming-http-token-reader:http-client');
Expand Down Expand Up @@ -48,9 +48,8 @@ export class HttpClient implements IRangeRequestClient {
if (response.response.ok) {
if (this.config.resolveUrl) this.resolvedUrl = response.response.url;
return response.toRangeRequestResponse();
} else {
throw new Error(`Unexpected HTTP response status=${response.response.status}`);
}
throw new Error(`Unexpected HTTP response status=${response.response.status}`);
}

}
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient, HttpClientConfig } from './http-client.js';
import { HttpClient, type HttpClientConfig } from './http-client.js';
import * as rangeTokenizer from '@tokenizer/range';
import { type ITokenizer } from 'strtok3';
import type { ITokenizer } from 'strtok3';

export { HttpClient, HttpClientConfig } from './http-client.js';

Expand Down
2 changes: 1 addition & 1 deletion lib/response-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class ResponseInfo {

private getContentLength(): number | undefined {
const contentLength = this.response.headers.get('Content-Length');
return contentLength ? parseInt(contentLength, 10) : undefined;
return contentLength ? Number.parseInt(contentLength, 10) : undefined;
}

public getAcceptRangesHeaderValue(): string | null {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@
"clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map' coverage",
"compile-lib": "tsc -p lib/tsconfig.json",
"compile-test": "tsc -p test/tsconfig.json",
"compile": "npm run compile-lib && yarn run compile-test",
"compile": "yarn run compile-lib && yarn run compile-test",
"prepublishOnly": "yarn run build",
"build": "npm run clean && yarn run compile",
"lint": "tslint 'lib/**/*.ts' --exclude 'lib/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
"build": "yarn run clean && yarn run compile",
"lint-ts": "biome check",
"lint": "yarn run lint-ts",
"karma": "karma start karma.conf.cjs",
"test": "mocha",
"karma-once": "karma start --browsers ChromeHeadless --single-run karma.conf.cjs",
"karma-headless": "karma start --single-run --reporters coverage-istanbul,spec,progress"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@music-metadata/test-audio": "^0.1.0",
"@types/chai": "^4.3.16",
"@types/debug": "^4.1.12",
Expand All @@ -75,7 +77,6 @@
"music-metadata": "^10.0.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tslint": "^6.1.3",
"typescript": "^5.5.3",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4"
Expand Down
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { parseFromTokenizer, type IOptions, type IAudioMetadata } from 'music-metadata';

import { type IRangeRequestConfig } from '@tokenizer/range';
import type { IRangeRequestConfig } from '@tokenizer/range';
import { makeTokenizer } from '../lib/index.js';
import { type IProvider, netBlocVol24, providers } from '@music-metadata/test-audio';
import { assert, expect } from 'chai';
Expand Down
Loading

0 comments on commit 6285e31

Please sign in to comment.