Skip to content

Commit

Permalink
pkg: add type lints using tsc.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Aug 31, 2023
1 parent 49eb4bf commit f17a208
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/base32.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function _decode(str, table, unpad) {
if (left > 0)
throw new Error('Invalid base32 string.');

if (str.length !== i + (-mode & 7) * unpad)
if (str.length !== i + (-mode & 7) * Number(unpad))
throw new Error('Invalid base32 string.');

for (; i < str.length; i++) {
Expand All @@ -244,7 +244,7 @@ function _decode(str, table, unpad) {
* Test a base32 string.
* @param {String} str
* @param {Boolean} [unpad=false]
* @returns {Buffer}
* @returns {Boolean}
*/

function test(str, unpad = false) {
Expand All @@ -260,7 +260,7 @@ function test(str, unpad = false) {
* Test a base32 hex string.
* @param {String} str
* @param {Boolean} [unpad=false]
* @returns {Buffer}
* @returns {Boolean}
*/

function testHex(str, unpad = false) {
Expand Down
4 changes: 3 additions & 1 deletion lib/bs32.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = require('./base32');
const base32 = require('./base32');

module.exports = base32;
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 @@ -15,13 +15,15 @@
"main": "./lib/bs32.js",
"scripts": {
"lint": "eslint lib/ test/",
"lint-types": "tsc -p .",
"test": "bmocha --reporter spec test/*-test.js"
},
"dependencies": {
"bsert": "~0.0.10"
},
"devDependencies": {
"bmocha": "^2.1.0"
"bmocha": "^2.1.0",
"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 f17a208

Please sign in to comment.