Skip to content

Commit

Permalink
Merge PR #14 from 'nodech/ts-lint'
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Aug 31, 2023
2 parents 9e05f42 + e089840 commit ce5d35b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ jobs:
node-version: 20.x

- name: Install tools
run: npm install --location=global bslint
run: npm install --location=global bslint typescript

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

- name: Lint types
run: npm run lint-types

test:
name: Test
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 3 additions & 1 deletion lib/brq.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

'use strict';

module.exports = require('./request');
const {request} = require('./request');

module.exports = request;
5 changes: 3 additions & 2 deletions lib/request-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ class Response {
/**
* Response
* @constructor
* @ignore
*/

constructor() {
Expand Down Expand Up @@ -430,6 +429,7 @@ request.stream = function stream(options) {
const s = new EventEmitter();
const body = [];

// @ts-ignore
s.write = (data, enc) => {
if (!Buffer.isBuffer(data)) {
assert(typeof data === 'string');
Expand All @@ -439,6 +439,7 @@ request.stream = function stream(options) {
return true;
};

// @ts-ignore
s.end = () => {
options.extra = Buffer.concat(body);
_request(options, false).then((res) => {
Expand All @@ -461,4 +462,4 @@ request.stream = function stream(options) {
* Expose
*/

module.exports = request;
exports.request = request;
3 changes: 1 addition & 2 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ class Request extends Stream {
/**
* Request
* @constructor
* @private
* @param {Object} options
*/

Expand Down Expand Up @@ -641,4 +640,4 @@ function ensureRequires(ssl) {
* Expose
*/

module.exports = request;
exports.request = request;
9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"main": "./lib/brq.js",
"scripts": {
"lint": "eslint lib/ test/",
"lint-types": "tsc -p .",
"test": "bmocha --reporter spec test/*-test.js"
},
"dependencies": {
"bsert": "~0.0.12"
},
"devDependencies": {
"bmocha": "^2.1.8"
"bmocha": "^2.1.8",
"bts-type-deps": "^0.0.3"
},
"engines": {
"node": ">=8.0.0"
Expand Down
31 changes: 31 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"include": [
"lib/**/*.js"
],
"compilerOptions": {
"rootDir": ".",
"target": "ES2020",
"lib": [
"ES2020"
],

"noEmit": true,

"allowJs": true,
"checkJs": true,
"maxNodeModuleJsDepth": 10,

"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,

"stripInternal": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": false,

"typeRoots": [
"node_modules/bts-type-deps/types"
]
}
}

0 comments on commit ce5d35b

Please sign in to comment.