From dcf95601b603280eb22c003c91d6606c53e7f41a Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 7 Nov 2021 08:08:30 +0100 Subject: [PATCH] Use strict types --- index.js | 2 +- package.json | 9 +++++---- test.js | 2 ++ tsconfig.json | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 54cc3a5..9735080 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ const ltr = new RegExp('^[^' + rtlRange + ']*[' + ltrRange + ']') * Detect direction. * * @param {string} value - * @returns {'rtl' | 'ltr' | 'neutral'} + * @returns {'rtl'|'ltr'|'neutral'} */ export function direction(value) { const source = String(value || '') diff --git a/package.json b/package.json index 83a4886..385707b 100644 --- a/package.json +++ b/package.json @@ -46,11 +46,11 @@ "xo": "^0.46.0" }, "scripts": { - "prepack": "npm run build && npm run format", + "prepublishOnly": "npm run build && npm run format", "build": "rimraf \"*.d.ts\" && tsc && type-coverage", "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", - "test-api": "node test.js", - "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", + "test-api": "node --conditions development test.js", + "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api", "test": "npm run build && npm run format && npm run test-coverage" }, "prettier": { @@ -72,6 +72,7 @@ "typeCoverage": { "atLeast": 100, "detail": true, - "strict": true + "strict": true, + "ignoreCatch": true } } diff --git a/test.js b/test.js index 5942cf8..1c5d24d 100644 --- a/test.js +++ b/test.js @@ -1,3 +1,4 @@ +import assert from 'node:assert' import fs from 'node:fs' import childProcess from 'node:child_process' import {PassThrough} from 'node:stream' @@ -72,6 +73,7 @@ test('cli', function (t) { } ) + assert(subprocess.stdin, 'expected stdin') input.pipe(subprocess.stdin) input.write('لة') setImmediate(function () { diff --git a/tsconfig.json b/tsconfig.json index 8ac10fe..e31adf8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,4 @@ { - "files": ["index.js"], "include": ["*.js"], "compilerOptions": { "target": "ES2020", @@ -11,6 +10,7 @@ "declaration": true, "emitDeclarationOnly": true, "allowSyntheticDefaultImports": true, - "skipLibCheck": true + "skipLibCheck": true, + "strict": true } }