sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

Add `string.nonBlank` #227

Closed leaumar closed 2 years ago

leaumar commented 2 years ago

fixes #226

Useful for all kinds of user/file/env sourced inputs that may contain strings of whitespace where a meaningful value is expected.

leaumar commented 2 years ago

I tried to run the tests, but...

PS D:\Projects\ow> npm test

ow@0.28.1 test xo && c8 ava

TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file at open (node:internal/fs/promises:410:10) at Object.readFile (node:internal/fs/promises:755:20) at Object.load (file:///D:/Projects/ow/node_modules/esm-utils/lib/json.js:7:36) at handleTSConfig (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:164:33) at mergeWithFileConfig (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:138:19) at async parseOptions (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:557:51) at async Promise.all (index 0) at async getOptionGroups (file:///D:/Projects/ow/node_modules/xo/lib/options-manager.js:573:21) at async Object.lintFiles (file:///D:/Projects/ow/node_modules/xo/index.js:69:17) at async file:///D:/Projects/ow/node_modules/xo/cli.js:211:18

leaumar commented 2 years ago

Alright, if the last open point (making the wording clearer) is solved for you, I have no remaining points other than not being able to run the tests.

leaumar commented 2 years ago

Found a list of metachars in js, turns out there are only 6 so I figured I'd add them to stop at a logical point. \f and \v aren't so common but I can imagine \0 popping up in places. Had to write \0 as \x00 because my IDE thinks it's an error otherwise, even though it works fine in a js console.

sindresorhus commented 2 years ago

CI is failing

leaumar commented 2 years ago

Try it now?

leaumar commented 2 years ago

Oh, yeah, a null byte wouldn't actually be whitespace. I'll remove that, then it should be good. image

sindresorhus commented 2 years ago

@leaumar We unfortunately cannot release this until TS supports ESM, but in the meantime, you can install this with npm i 'sindresorhus/ow#96207f00f3b3ab8b79e258f892ec948731a8cfd4'.

leaumar commented 2 years ago

Sounds like something that could take months still, if ever?

sindresorhus commented 2 years ago

It will be in TS 4.6 (was supposed to be in this release, but pulled last minute). So probably a month or two. TS 4.5 is scheduled to be out today.

leaumar commented 2 years ago

Ah, cool. Thanks for the pointer

sindresorhus commented 2 years ago

This is finally out: https://github.com/sindresorhus/ow/releases/tag/v1.0.0