Skip to content

Commit

Permalink
Update husky, simplify configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
surilindur committed Mar 24, 2024
1 parent 5084c1a commit 6fd87f5
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 182 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.husky/_
.yarn
coverage
dist
node_modules
index.js
index.js.map
index.d.ts
lib/*.js
lib/*.js.map
lib/*.d.ts
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint && yarn build && yarn test
17 changes: 1 addition & 16 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,8 @@ module.exports = config([
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname,
project: [ './tsconfig.eslint.json' ],
project: [ 'tsconfig.eslint.json' ],
},
},
},
{
files: [ '**/*.ts', 'webpack.config.js' ],
rules: {
'import/no-nodejs-modules': 'off',
// The naming convention rules complain about the public static properties, as well
'ts/naming-convention': 'off',
},
},
{
// The readme contains examples with console logging
files: [ 'README.md/*' ],
rules: {
'no-console': 'off',
},
},
]);
9 changes: 5 additions & 4 deletions lib/ReadableFromWeb.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Readable, type ReadableOptions } from 'readable-stream';

class ReadableFromWeb<R> extends Readable {
private readonly reader: ReadableStreamDefaultReader<R>;
class ReadableFromWeb<T> extends Readable {
private readonly reader: ReadableStreamDefaultReader<T>;
private readerClosed: boolean;

public constructor(stream: ReadableStream<R>, options?: ReadableOptions) {
public constructor(stream: ReadableStream<T>, options?: ReadableOptions) {
super(options);
this.reader = stream.getReader();
this.readerClosed = false;
Expand All @@ -16,6 +16,7 @@ class ReadableFromWeb<R> extends Readable {
});
}

// eslint-disable-next-line ts/naming-convention
public _read(): void {
this.reader.read()
.then(chunk => this.push(chunk.done ? null : chunk.value))
Expand All @@ -34,7 +35,7 @@ class ReadableFromWeb<R> extends Readable {
}
}

function readableFromWeb<R>(stream: ReadableStream<R>, options?: ReadableOptions): Readable {
function readableFromWeb<T>(stream: ReadableStream<T>, options?: ReadableOptions): Readable {
return new ReadableFromWeb(stream, options);
}

Expand Down
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@comunica/readable-from-web",
"name": "readable-from-web",
"type": "commonjs",
"version": "1.0.0",
"packageManager": "[email protected]",
Expand All @@ -20,7 +20,8 @@
"scripts": {
"lint": "eslint .",
"build": "tsc",
"test": "jest"
"test": "jest",
"prepare": "husky"
},
"dependencies": {
"readable-stream": "^4.0.0"
Expand All @@ -29,18 +30,13 @@
"@rubensworks/eslint-config": "^3.0.0",
"@types/jest": "^29.0.0",
"@types/readable-stream": "^4.0.0",
"eslint": "8.48.0",
"husky": "^4.0.0",
"eslint": "^8.0.0",
"husky": "^9.0.0",
"jest": "^29.0.0",
"readable-stream-node-to-web": "^1.0.0",
"stream-to-string": "^1.0.0",
"streamify-string": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
},
"husky": {
"hooks": {
"pre-commit": "yarn run lint && yarn run build && yarn run test"
}
}
}
1 change: 0 additions & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"include": [
"index.ts",
"lib/*.ts",
"test/*.ts"
]
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"sourceMap": true
},
"include": [
"index.ts",
"lib/*.ts"
],
"exclude": [
Expand Down
Loading

0 comments on commit 6fd87f5

Please sign in to comment.