Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: add type lints. #14

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}
}