instance_id
stringlengths
10
65
repo
stringlengths
5
59
pr_number
int64
1
313k
task_type
stringclasses
1 value
base_commit
stringlengths
40
40
review_commit
stringlengths
40
40
title
stringlengths
2
282
body
stringlengths
7
3k
patch
stringlengths
202
204k
n_defects
int64
1
72
n_supported
int64
1
65
n_major
int64
0
32
defects
stringlengths
140
18.8k
certifier_count
int64
sindresorhus__eslint-plugin-unicorn__484
sindresorhus/eslint-plugin-unicorn
484
defect
f664c130ef2ac7c28e24fe9fd8b7dd9fdad3a162
09c93d47917f66ca964c77d0fd87aff9e8dda315
Deprecate `prefer-exponentiation-operator` rule
Deprecate `unicorn/prefer-exponentiation-operator` rule, replace it with ESLint official rule [`prefer-exponentiation-operator`](https://eslint.org/docs/rules/prefer-exponentiation-operator) I ran `prefer-exponentiation-operator` over our test cases, little difference: 1. spaces ```js Math.pow(1, 2); 1 ** ...
diff --git a/docs/rules/prefer-exponentiation-operator.md b/docs/rules/prefer-exponentiation-operator.md index 8358b728f8..9d6bb55e22 100644 --- a/docs/rules/prefer-exponentiation-operator.md +++ b/docs/rules/prefer-exponentiation-operator.md @@ -1,5 +1,7 @@ # Prefer the exponentiation operator over `Math.pow()` +**...
2
1
0
[{"id": "G0", "claim": "It would be worth adding a check that ensures deprecated rules are described in the readme.", "category": "testing", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The Deprecated Rules section should use a plain list instead of a Markdown table, since tabl...
null
sindresorhus__eslint-plugin-unicorn__496
sindresorhus/eslint-plugin-unicorn
496
defect
f489ce204e546b379b867e15f381b7fff9bf068f
5165d3e90d76aa27a500facd4798ca474babc5f7
Add `string-content` rule
fixes #327 <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </summary> ### Referenced issues This pull request has been submitted to: - [#327: Rule proposal: `string-content`](https://issuehunt.io/repos/55832243/issues/327) --- IssueHunt has been backed by the following sponsors. [Beco...
diff --git a/docs/rules/string-content.md b/docs/rules/string-content.md new file mode 100644 index 0000000000..8ac2588ad2 --- /dev/null +++ b/docs/rules/string-content.md @@ -0,0 +1,66 @@ +# Enforce better string context + +This rule is fixable. + +## Fail + +```js +const foo = 'Someone\'s coming!'; +``` + +## Pass + ...
8
6
1
[{"id": "G0", "claim": "The default config for the `string-content` rule should be set to `off` instead of `error` in the recommended config.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Checking `TemplateElement` instead of `TemplateLiteral` may repor...
null
sindresorhus__eslint-plugin-unicorn__555
sindresorhus/eslint-plugin-unicorn
555
defect
e856680e0c9fc7fc2b49dc142a7fd7bcd549d46d
1c52e15e3e449df60c8429ee8ddaddcf7ee5649a
Add `ignore` option to `expiring-todo-comment` rule
Fixes #502.
diff --git a/docs/rules/expiring-todo-comments.md b/docs/rules/expiring-todo-comments.md index e6c8553a17..65a66827a3 100644 --- a/docs/rules/expiring-todo-comments.md +++ b/docs/rules/expiring-todo-comments.md @@ -294,3 +294,24 @@ If you want this rule to trigger on stray TODO conditions, you can enable this f } ] ...
9
5
1
[{"id": "G0", "claim": "It would be nice for the `ignore` option to allow regex literals, e.g. `/ignore/i`, instead of only strings.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The documentation of the `ignore` option should also use the explanation a...
null
sindresorhus__eslint-plugin-unicorn__603
sindresorhus/eslint-plugin-unicorn
603
defect
350e3a60dcde0c4e280ffa7bd351e88d39726a1b
f78695278ead9657cabf15ef5f57ceb1f8f3842e
`prevent-abbreviations`: Add global variables check
Fixes #445
diff --git a/rules/utils/avoid-capture.js b/rules/utils/avoid-capture.js index 350b23aec7..51a584d344 100644 --- a/rules/utils/avoid-capture.js +++ b/rules/utils/avoid-capture.js @@ -28,10 +28,17 @@ const nameCollidesWithArgumentsSpecial = (name, scopes, isStrict) => { return isStrict || scopes.some(scopeHasArguments...
3
3
1
[{"id": "G0", "claim": "Rename `maybeGlobal` to `isProbablyGlobal` as suggested.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Add a doc comment to the helper explaining what the maybe/probably qualifier implies, i.e. when the result can not be...
null
sindresorhus__eslint-plugin-unicorn__622
sindresorhus/eslint-plugin-unicorn
622
defect
fa3a2dac753e3205f258b358450a680450819a49
bdaafea94e1bff8da84466d833754bf2c1df5b34
Add `prefer-number-properties` rule
Fixes #594
diff --git a/docs/rules/prefer-number-properties.md b/docs/rules/prefer-number-properties.md new file mode 100644 index 0000000000..6c4c664a46 --- /dev/null +++ b/docs/rules/prefer-number-properties.md @@ -0,0 +1,60 @@ +# Prefer `Number.{parseInt,parseFloat,isNaN,isFinite}()` and `Number.NaN` over global ones. + +Enfor...
3
3
0
[{"id": "G0", "claim": "The doc title should be simplified to \"Prefer `Number` static properties over global ones.\" instead of listing all the methods.", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The docs should explain why `Number.isNaN()`/`...
null
sindresorhus__eslint-plugin-unicorn__637
sindresorhus/eslint-plugin-unicorn
637
defect
38f2456be2da16452def9ed82bb9fab9898a8b94
c7d7f893b1555b69cf61890a35de918a86e08672
Improve `string-content`
- Remove default pattern. - Add suggestions to patterns with `fix: false` - Add `codecov.yml` allow coverage to drop Fixes #630
diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..fd7b560509 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 99% + threshold: 1% diff --git a/docs/rules/string-content.md b/docs/rules/string-content.md index fd3e0909...
1
1
0
[{"id": "G0", "claim": "Keep the removed Default Pattern section instead of deleting it, renamed to `Pattern Ideas` or something similar to give people inspiration on what kind of patterns to use, and add the `...` => `…` example there too.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "int...
null
sindresorhus__eslint-plugin-unicorn__64
sindresorhus/eslint-plugin-unicorn
64
defect
d576ea528d6ea341f7336ce65174ec14f11af7a7
6b2f7f21820e1bd9cd971249496ff4afdfd5adee
Add `prefer-starts-ends-with` rule - fixes #13
The changes here add the `prefer-starts-ends-with` for ONLY the regex cases. I am not so sure how people use `.match` for the purpose of `.startsWith` and `.endsWith` and am concerned that the way I had currently might cause false negative because `str.match(/^foo/)` could be a valid use. Should we test if the code on...
diff --git a/docs/rules/prefer-starts-ends-with.md b/docs/rules/prefer-starts-ends-with.md new file mode 100644 index 0000000000..8a4ba69c67 --- /dev/null +++ b/docs/rules/prefer-starts-ends-with.md @@ -0,0 +1,18 @@ +# Prefer `.startsWith` and `.endsWith` + +Determine whether a string begins/ends with characters with ...
8
7
1
[{"id": "G0", "claim": "The rule's docs title should be reworded (sindresorhus asked for better suggestions than `Prefer String#startsWidth & String#endsWidth over a regex`, and asked to use it in the readme description too).", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id...
null
sindresorhus__eslint-plugin-unicorn__704
sindresorhus/eslint-plugin-unicorn
704
defect
efdb03af14999b3d99202fe1d611415d64669e38
430e0ec7689c310eb13bfc9ad1644919a4157973
Add `no-reduce` rule
Fixes #623
diff --git a/docs/rules/no-reduce.md b/docs/rules/no-reduce.md new file mode 100644 index 0000000000..1f4c57113d --- /dev/null +++ b/docs/rules/no-reduce.md @@ -0,0 +1,26 @@ +# Disallow the usage of Array#reduce + +`Array.reduce` usually results in hard-to-read code. It can almost every time by replaced fith `.map`, `....
6
6
3
[{"id": "G0", "claim": "The new rule fails on the project's own existing `reduce` usages, and they must be rewritten instead of being silenced with `eslint-disable` comments.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "There is no way to know whether ...
null
sindresorhus__eslint-plugin-unicorn__718
sindresorhus/eslint-plugin-unicorn
718
defect
05f5ccbd6a224f20ac82be8af363ab0c7dd152f2
dc15e8fdb5765a37cb5a4c956aa51603715bd756
Add `no-useless-undefined` rule
Fixes #683
diff --git a/docs/rules/no-useless-undefined.md b/docs/rules/no-useless-undefined.md new file mode 100644 index 0000000000..21ccf282b7 --- /dev/null +++ b/docs/rules/no-useless-undefined.md @@ -0,0 +1,83 @@ +# Disallow useless `undefined` + +This rule is fixable. + +## Fail + +```js +let foo = undefined; +``` + +```js ...
2
2
1
[{"id": "G0", "claim": "The fixer output `return ;` / `yield ;` leaves a space before the semicolon; sindresorhus asked that the space be removed by the fixer instead of being left for another style rule to fix.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", ...
null
sindresorhus__eslint-plugin-unicorn__745
sindresorhus/eslint-plugin-unicorn
745
defect
cec3a9dfa08db1efd166001d604b04d4fa8ab53f
05ab8cae6b86dd56d09edf282aff88f8773cc584
Use singular array element variable name in autofix for `no-for-loop` rule
If the loop is iterating an array with a plural name (such as `plugins`), the generated element variable in the autofix could use the singular version of the array name (`plugin`), instead of just the generic name `element`. Fixes #743. CC: @mongoose700
diff --git a/package.json b/package.json index dea370eded..fd51fde919 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "eslint-utils": "^2.0.0", "import-modules": "^2.0.0", "lodash": "^4.17.15", + "pluralize": "^8.0.0", "read-pkg-up": "^7.0.1", "regexp-tree": "^0.1.21", "reserved-words"...
5
5
0
[{"id": "G0", "claim": "When the singular of the array name would be a reserved word, the autofix should prefer the singular name with a trailing underscore produced via avoidCapture (e.g. `case_`) rather than falling back to the generic `element`, as fisker and sindresorhus prefer.", "category": "design", "verdict": "...
null
sindresorhus__eslint-plugin-unicorn__783
sindresorhus/eslint-plugin-unicorn
783
defect
459408580b953cfd9940d4d2a0df0f397f537739
b7dbf4f4164dfafc5f4b86c7b5f7efdc98538279
`prefer-starts-ends-with`: Fix pipe in regex
Fix the case where `/^A|B/.test(s)` → `s.startsWith('A|B')`. Fixes https://github.com/sindresorhus/eslint-plugin-unicorn/issues/782
diff --git a/rules/prefer-starts-ends-with.js b/rules/prefer-starts-ends-with.js index 209ba42a5e..4105c3e113 100644 --- a/rules/prefer-starts-ends-with.js +++ b/rules/prefer-starts-ends-with.js @@ -11,7 +11,7 @@ const doesNotContain = (string, characters) => characters.every(character => !st const isSimpleString = ...
1
1
0
[{"id": "G0", "claim": "The test should also cover the end-anchored alternation case, adding `,` after `/^A|B/` and a `/A|B$/` entry to validRegex.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__eslint-plugin-unicorn__809
sindresorhus/eslint-plugin-unicorn
809
defect
0c7a19957f482953031e337dd8f46ae67ec3c2ce
9ada22a52ca060a0b06179f7c1077fa588d786a8
Allow `Children` in `no-fn-reference-in-iterator`
This allows the use of `Children.map(children, fn)` in `no-fn-reference-in-iterator`. This handles the following situation. ```js import { Children } from 'react'; export default ({ children ]) => ( Children.map(children, (child) => child) ); ``` The casing for `React.Children` in the test has been chan...
diff --git a/rules/no-fn-reference-in-iterator.js b/rules/no-fn-reference-in-iterator.js index 767a403542..b6f384ab58 100644 --- a/rules/no-fn-reference-in-iterator.js +++ b/rules/no-fn-reference-in-iterator.js @@ -60,6 +60,7 @@ const iteratorMethods = [ const ignoredCallee = [ 'Promise', 'React.children', + 'Chil...
1
1
0
[{"id": "G0", "claim": "The new 'Children.forEach(children, fn)' test case should carry a trailing comment // `import {Children} from 'react';` to say where Children comes from.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__eslint-plugin-unicorn__833
sindresorhus/eslint-plugin-unicorn
833
defect
f141d08829085cb314bc78a4bdf59e2c739dedb8
be5bd020c16cbcad44c377576622e9560e048664
Add `numeric-separators-style` rule
A new rule to enforce the [numeric separators](https://github.com/tc39/proposal-numeric-separator)' style. See #828 for more information. Concerning the code, I decided to group digits together by splitting them into an array of chunks and then joining them with an underscore. Although this was the simplest way I fo...
diff --git a/docs/rules/numeric-separators-style.md b/docs/rules/numeric-separators-style.md new file mode 100644 index 0000000000..b494da10fc --- /dev/null +++ b/docs/rules/numeric-separators-style.md @@ -0,0 +1,70 @@ +# Enforce the style of numeric separators by correctly grouping digits + +Enforces a convention of g...
25
25
10
[{"id": "G0", "claim": "The value of a bigint literal can be null, so the rule must also check `node.bigint` instead of only `typeof node.value`.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The power-part handling does not ignore the `-` sign, so...
null
sindresorhus__eslint-plugin-unicorn__88
sindresorhus/eslint-plugin-unicorn
88
defect
dacf53857b359a617ac026776b61274b1243eb2c
86e09246b71db39f51ba2515763ced217942a234
Add support for custom errors in the `throw-new-error` rule
added customer error by using /^(?:[A-Z][a-z0-9]*)*Error$/ fixes #4
diff --git a/rules/throw-new-error.js b/rules/throw-new-error.js index dfcab0b20b..24048be33d 100644 --- a/rules/throw-new-error.js +++ b/rules/throw-new-error.js @@ -9,13 +9,14 @@ const errorTypes = [ 'TypeError', 'URIError' ]; +const customerError = /^(?:[A-Z][a-z0-9]*)*Error$/; const create = context => ({ ...
4
3
1
[{"id": "G0", "claim": "The identifiers misspell the word \"custom\" as \"customer\" (and later \"custome\"/\"Custome\") and should read \"customError\"/\"CustomError\" throughout the rule and tests.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim":...
null
sindresorhus__eslint-plugin-unicorn__910
sindresorhus/eslint-plugin-unicorn
910
defect
dfc1ce0bf617548ebd54af6d81bff5fedd8d9cbc
02d8bcf699fac629b26f4a15988d49d58c0a0378
Fix `false` import styles seen in reported problem messages
Fixes #899 (Alternative fix)
diff --git a/rules/import-style.js b/rules/import-style.js index f2083f3acc..65f9d35ede 100644 --- a/rules/import-style.js +++ b/rules/import-style.js @@ -172,7 +172,7 @@ const create = context => { styles = new Map( Object.entries(styles).map( ([moduleName, styles]) => - [moduleName, new Map(Object.entries...
3
2
0
[{"id": "G0", "claim": "Use an array-destructuring hole instead of the unused `_` binding when filtering style entries.", "category": "style", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The unused key left by the change (now-meaningless `false` style entries) should be remo...
null
sindresorhus__eslint-plugin-unicorn__916
sindresorhus/eslint-plugin-unicorn
916
defect
dfc1ce0bf617548ebd54af6d81bff5fedd8d9cbc
6656f1fda929390965b616036c8ab2c9a50536e5
`numeric-separators-style`: Add `onlyIfContainsSeparator` option
Added an option for each literal type, named `checkOnlyIfSeparator`. As explained in the docs, it: Check if the group sizes are valid **only** if there are groups, separated with an `_`. Example: ```js const foo = 100000; // Pass, because there are no groups, so no check was performed. const bar = 1_000_000; //...
diff --git a/docs/rules/numeric-separators-style.md b/docs/rules/numeric-separators-style.md index 843f75d8d9..bab35fe4b1 100644 --- a/docs/rules/numeric-separators-style.md +++ b/docs/rules/numeric-separators-style.md @@ -33,6 +33,19 @@ If you want a custom group size for a specific number type, you can specify it h ...
6
6
2
[{"id": "G0", "claim": "The PR should test or define the behaviour for numbers with a separator in multiple parts, e.g. `12_34.5678e1234.5678` (ignore all of it, or just part?).", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The option's documentation s...
null
sindresorhus__execa__1004
sindresorhus/execa
1,004
defect
63de2065d9cfb80d511f7d239b997d39e5123843
ad51b1c52f4b552c841fb8ba349a3d92805be71a
Fix passing the same file or stream to both `stdout` and `stderr`
Fixes #1002. This works with both `execa()` and `execaSync()`.
diff --git a/docs/bash.md b/docs/bash.md index a742143259..3c3c72d55d 100644 --- a/docs/bash.md +++ b/docs/bash.md @@ -493,6 +493,34 @@ await $({stdout: {file: 'output.txt'}})`echo example`; [More info.](output.md#file-output) +### Piping interleaved stdout and stderr to a file + +```sh +# Bash +npm run build &> o...
1
1
0
[{"id": "G0", "claim": "The docs example should define the file descriptor once as `const output = {file: 'output.txt'}` and pass that same variable to both `stdout` and `stderr`, instead of repeating the object literal.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__execa__836
sindresorhus/execa
836
defect
28acdbc657c6ac2f4603508b4c6ae446857a817e
28487750dba2883a7bd39d4a7011182e97c3cd03
Add `.kill(signal, error)`
Fixes #816.
diff --git a/index.d.ts b/index.d.ts index bf6012c23f..f1ed1b0de4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -833,7 +833,8 @@ export type ExecaChildPromise<OptionsType extends Options = Options> = { [More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal) */ - kill(signalOrError: Parameters<C...
2
2
1
[{"id": "G0", "claim": "The readme's kill() signature heading should be rewritten as `#### kill(signal, error?)` plus `#### kill(error?)` (a `suggestion` block) so that passing `error` as the first argument is clear.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id":...
null
sindresorhus__got__1035
sindresorhus/got
1,035
defect
d222164dffeb3ebf7d3ecb710fd56e2af5324c81
15dd22cea682338d64b05f50bf2eef7178b5fba5
Reject normalization errors with CancelableRequest
Closes #1025 In the event of an error being thrown during argument normalization a normal promise was being returned which prevented users from calling any of the CancelableRequest convenience methods. This changes makes it so a rejected CancelableRequest is returned instead. #### Checklist - [x] I have read t...
diff --git a/source/as-promise.ts b/source/as-promise.ts index 44850ccc6..68aeeaec5 100644 --- a/source/as-promise.ts +++ b/source/as-promise.ts @@ -23,6 +23,18 @@ const parseBody = (body: Buffer, responseType: NormalizedOptions['responseType'] throw new TypeError(`Unknown body type '${responseType as string}'`); };...
2
2
1
[{"id": "G0", "claim": "The new test should chain the convenience methods the PR attaches to rejections (.json().text().buffer()) instead of calling got() bare, and assert the exact error message 'Invalid URL' as in the suggestion — at S1 it neither exercised those methods nor checked the message.", "category": "testin...
null
sindresorhus__got__1037
sindresorhus/got
1,037
defect
d222164dffeb3ebf7d3ecb710fd56e2af5324c81
1dd9a2ab4cd52ae45a966ec4afb66356fd1cb363
Allow request body to be sent with a DELETE request
Fixes #1028. Adds DELETE to the methods that apply a `content-length` header when a request body is given, to allow the request body to actually be sent. Fixes the expected failing test added in #1031 (by using streams directly instead of requiring the body to be parsed) and removes the `failing` modifier. Tha...
diff --git a/source/normalize-arguments.ts b/source/normalize-arguments.ts index e7672ebb1..7af45d956 100644 --- a/source/normalize-arguments.ts +++ b/source/normalize-arguments.ts @@ -404,7 +404,7 @@ export const normalizeRequestArguments = async (options: NormalizedOptions): Pro // body. if (is.undefined(headers[...
1
1
1
[{"id": "G0", "claim": "Undo the rewrite of the 'DELETE method sends plain objects as JSON' test in test/post.ts: the underlying failure needs to be fixed (not necessarily in this PR), not covered up by turning the failing test into a passing one.", "category": "testing", "verdict": "supported", "priority": "P1", "scop...
null
sindresorhus__got__1054
sindresorhus/got
1,054
defect
b4a540218efa09292738f63a84b7ed2b63a81175
3dfe11a147ecceb03a0c0646320f05a828911318
Wait until body file descriptor is open
Fixes #1046
diff --git a/source/create.ts b/source/create.ts index 6d0dd1a73..4ab14ac3d 100644 --- a/source/create.ts +++ b/source/create.ts @@ -1,3 +1,4 @@ +import {Readable} from 'stream'; import {Merge} from 'type-fest'; import is from '@sindresorhus/is'; import asPromise, {createRejection} from './as-promise'; @@ -99,7 +100...
1
1
0
[{"id": "G0", "claim": "Instead of catching body errors after the fact, it could be done via a promise that waits until options.body is readable/open.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__got__1181
sindresorhus/got
1,181
defect
731e4fa235ae9b43e03e74fee34b8b32d8ebb705
78d2cb7abeef9caf544fa573a4e44868a4d1673c
Limit number of requests in pagination
Currently, it's easily possible to trigger an infinite amount of requests during development because we use a `while(true)` construct. This PR adds a new option to limit the number of requests. #### Checklist - [X] I have read the documentation. - [X] I have included a pull request description of my changes. - ...
diff --git a/readme.md b/readme.md index 8a9c63799..4e673f0c1 100644 --- a/readme.md +++ b/readme.md @@ -760,6 +760,13 @@ Default: `Infinity` The maximum amount of items that should be emitted. +###### pagination.requestLimit + +Type: `number`\ +Default: `100` + +The maximum amount of request that should be trigge...
3
3
1
[{"id": "G0", "claim": "The default `pagination.requestLimit` of 100 is too low; if it is only meant to guard against mistakes in development the default should be higher, maybe `Infinity`.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The documentation...
null
sindresorhus__got__1246
sindresorhus/got
1,246
defect
9770e540d088c35ec0b467fa3d2fafb60ed6797d
7edcb947d4f31b6e04777a9d2ed0f4148ae80ce7
Don't force query string normalization
It assumes that the query speicified in the input is not `URLSearchParams` unless the `searchParams` option is present. ~The search params are correctly normalized via `decodeURIComponent` (I spent 30 mins reading stackoverflow and exeprimenting by myself, I'm pretty sure that's the correct one).~ The WHATWG URL han...
diff --git a/source/core/index.ts b/source/core/index.ts index 0bbecf54e..724a9110b 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -728,10 +728,7 @@ export default class Request extends Duplex implements RequestEvents<Request> { // Trigger search params normalization if (options.url.search) {...
5
4
1
[{"id": "G0", "claim": "`options.url.search` is already a string, so the `.toString()` in `options.url.search = decodeURIComponent(options.url.search.toString())` is redundant and should be dropped.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": ...
null
sindresorhus__got__1248
sindresorhus/got
1,248
defect
9770e540d088c35ec0b467fa3d2fafb60ed6797d
b5824175486d6084e5579f310107bce3501d5e8d
Do not destroy completed requests
Fixes #1245 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [ ] If it's a new feature, I have included documentation updates.
diff --git a/package.json b/package.json index 9ac633aea..782f11977 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,6 @@ "@types/responselike": "^1.0.0", "cacheable-lookup": "^5.0.3", "cacheable-request": "^7.0.1", - "decompress-response": "^5.0.0", "get-stream": "^5.1.0", "http2-wrapper": "^1...
2
2
0
[{"id": "G0", "claim": "Rename the variable `empty` to `isEmpty` at source/core/utils/decompress-response.ts:39.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "If the plan is to upstream these changes, add a TODO comment saying so.", "category":...
null
sindresorhus__got__1255
sindresorhus/got
1,255
defect
761b8e01f7d194dd3b9aa6578c26966ebae6172c
0ac003aa473544d517fcad3880ee7298e4a78245
General improvements to HTTPS API
#### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. Fixes #1254 `checkServerIdentity` [signature](https://github.com/DefinitelyTyped/Definite...
diff --git a/readme.md b/readme.md index 8d2354b77..d8d9e1327 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,7 @@ For browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the - [Errors with metadata](#errors) - [JSON mode](#json-mode) - [WHATWG URL support](#url) +- [HTTPS](#https) - [Hooks]...
27
26
0
[{"id": "G0", "claim": "The two existing HTTPS tests make plain HTTP requests and should use `got.secure` instead of `got`.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "pre_existing"}, {"id": "G1", "claim": "checkServerIdentity is never called when connecting to localhost addresses such ...
null
sindresorhus__got__1264
sindresorhus/got
1,264
defect
761b8e01f7d194dd3b9aa6578c26966ebae6172c
c4e4ae4d21e423bbb0eff8a60409686b3590b65b
Add `dnsLookupIpVersion` option
#### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. I've added the documentation relative to the `family` property. I've also added a stricter type definition. I think the name "family" it's a little generic, it might be renamed to "IPfamily" or ...
diff --git a/readme.md b/readme.md index 8d2354b77..edc19008e 100644 --- a/readme.md +++ b/readme.md @@ -499,6 +499,17 @@ An instance of [`CacheableLookup`](https://github.com/szmarczak/cacheable-lookup **Note:** This should stay disabled when making requests to internal hostnames such as `localhost`, `database.local`...
6
4
0
[{"id": "G0", "claim": "The new option should be named `ipVersion` instead of `family`.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The option's values should not give `0` a special meaning; the type should be `'auto' | 'ipv4' | 'ipv6'`.", "category":...
null
sindresorhus__got__1266
sindresorhus/got
1,266
defect
761b8e01f7d194dd3b9aa6578c26966ebae6172c
ae24c2fa38524426b6cbba55cc591d3c7e2a3b87
Make `calculateDelay` promisable
#### Checklist - [x] I have read the documentation. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. Fixes #1262
diff --git a/readme.md b/readme.md index 8d2354b77..15eefc8a4 100644 --- a/readme.md +++ b/readme.md @@ -412,7 +412,7 @@ This also accepts an `object` with the following fields to constrain the duratio Type: `number | object`\ Default: - limit: `2` -- calculateDelay: `({attemptCount, retryOptions, error, computedVal...
4
4
2
[{"id": "G0", "claim": "The pull request's new promisable `calculateDelay` behaviour needs tests.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Node.js 14.2.0 fails with 'Cannot call end after a stream was destroyed' because the async `error` listener ...
null
sindresorhus__got__1289
sindresorhus/got
1,289
defect
a337dfdfc4151593044c8b729245308081a071be
22bfc5ede16af88454e63a1645e32f6e5f6ced6a
Do not wait for `ready` event if the file descriptor is already opened
got waits for the `open` event if the body is an `fs.ReadStream` even if the fd is already opened. With this PR I added a check `ReadStream.pending` in order to immediately resolve `waitForOpenFile` if the fd is already opened. #### Checklist - [x] I have read the documentation. - [x] I have included a pull r...
diff --git a/source/core/index.ts b/source/core/index.ts index 05ea117e1..18fde83cc 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -262,6 +262,10 @@ const waitForOpenFile = async (file: ReadStream): Promise<void> => new Promise(( reject(error); }; + if (!file.pending) { + resolve(); + } + fil...
2
2
0
[{"id": "G0", "claim": "waitForOpenFile should listen for the `ready` event instead of `open`, as a just-in-case consistency improvement that probably will not change much.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "pre_existing"}, {"id": "G1", "claim": "The new test should use `p-event...
null
sindresorhus__got__1293
sindresorhus/got
1,293
defect
a337dfdfc4151593044c8b729245308081a071be
5b7e2bc67f8f12453612a035aff0309546917f96
Some `beforeRequest` edited options are discarded
Currently he edits of `options.agent` and `options.url` made in `beforeRequest` are discarded. This PR simply read `agent` and `url` after `beforeRequest` hooks. #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some test...
diff --git a/source/core/index.ts b/source/core/index.ts index 05ea117e1..45b6412cb 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -1254,7 +1254,7 @@ export default class Request extends Duplex implements RequestEvents<Request> { async _makeRequest(): Promise<void> { const {options} = this; - c...
3
1
1
[{"id": "G0", "claim": "The `request` and `timeout` options destructured at the top of `_makeRequest` should also be re-read after the `beforeRequest` hooks have run, since edits a hook makes to them are currently discarded.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, ...
null
sindresorhus__got__1298
sindresorhus/got
1,298
defect
2c8fe196361e5fc3c063b56b816f916999d60c09
1752ead1fb58316e1fb4bdc03fd43a239973ca5c
Add options to customize parsing/stringifying JSON
Custom function to parse JSON responses. #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. Fixes #1274
diff --git a/readme.md b/readme.md index 33ebdfb02..06430db66 100644 --- a/readme.md +++ b/readme.md @@ -317,6 +317,23 @@ const body = await got(url).json(); const body = await got(url, {responseType: 'json', resolveBodyOnly: true}); ``` +###### parseJson + +Type: `(text: string) => unknown`\ +Default: `(text) => J...
7
5
0
[{"id": "G0", "claim": "The `parseJson` field in the `Defaults` interface should be required (`parseJson: ParseJsonFn`), not optional (`parseJson?: ParseJsonFn`).", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The `parseJson` option adds unnecessary comp...
null
sindresorhus__got__1305
sindresorhus/got
1,305
defect
7f643bb6bc3b3df4a8e7d77277d81d67d7dc0222
444b036f08b5d1aff191b9c932cc9d74959674c7
Fix `response` event not being emitted on cache verify request
~~That's only a workaround, a real solution is still WIP (this PR will be updated).~~ #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. Fixes #1287
diff --git a/source/core/index.ts b/source/core/index.ts index 214887c63..cac88d714 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -1296,16 +1296,17 @@ export default class Request extends Duplex implements RequestEvents<Request> { // `http-cache-semantics` checks this delete (options as unknow...
2
2
1
[{"id": "G0", "claim": "The new ETag test fails: `cache.size` is 0 instead of 1 right after the first request resolves.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The 304 response handler should not set an ETag header, since it was copied from the 2...
null
sindresorhus__got__1501
sindresorhus/got
1,501
defect
390b1451423df610686894194612647abca98dea
5d3a25962d00608068a5215f221d0d430ad1a2f1
`beforeRetry` allows stream body if different from original
#### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. Fixes #1500
diff --git a/source/as-promise/index.ts b/source/as-promise/index.ts index 35e8944a6..c332bdcae 100644 --- a/source/as-promise/index.ts +++ b/source/as-promise/index.ts @@ -152,8 +152,10 @@ export default function asPromise<T>(normalizedOptions: NormalizedOptions): Canc request.once('error', onError); + const...
2
2
0
[{"id": "G0", "claim": "Rename the misspelled variable `previusBody` to `previousBody` in source/as-promise/index.ts.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Don't use the abbreviation `genBody` in the new test in test/hooks.ts; spell the...
null
sindresorhus__got__1510
sindresorhus/got
1,510
defect
c00fce35ef5c38564d34b79bdb30e064406a8058
545a6e615cef33226a8fd0de88e3ee613120f38f
Remove automatic `content-length` on ReadStream
**This PR contains breaking changes, merge on Got 12** #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates in both the README and the types. ...
diff --git a/readme.md b/readme.md index c97c4d422..5e6f5c56e 100644 --- a/readme.md +++ b/readme.md @@ -236,7 +236,7 @@ Type: `string | Buffer | stream.Readable` or [`form-data` instance](https://gith **Note #4:** This option is not enumerable and will not be merged with the instance defaults. -The `content-lengt...
2
2
1
[{"id": "G0", "claim": "A note should be added near the upload progress documentation about the need to set the `content-length` header in order to use the upload progress feature on files.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G2", "claim": "The JSDoc ...
null
sindresorhus__got__1518
sindresorhus/got
1,518
defect
51d88a0efed56760d116c5b911cea71e3265c787
0920f1abd5e8b960de29006942a89b9832a639a3
Add read timeout
Fixes #1512 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates in both the README and the types.
diff --git a/readme.md b/readme.md index 642c2912e..8446d9133 100644 --- a/readme.md +++ b/readme.md @@ -518,7 +518,10 @@ This also accepts an `object` with the following fields to constrain the duratio - `socket` starts when the socket is connected. See [request.setTimeout](https://nodejs.org/api/http.html#http_reque...
2
2
0
[{"id": "G0", "claim": "Strike through the `read` timeout line in the timeout documentation, since the `read` timeout is currently blocked by the Node.js issue and should not be presented as available.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim":...
null
sindresorhus__got__1534
sindresorhus/got
1,534
defect
c00fce35ef5c38564d34b79bdb30e064406a8058
3bb79fe7d071c5e3cbcbd1103d36e8afce34b0d2
Upgrade dev dependencies
Read: https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/ Array access is now stricter and adds `undefined` to the union.
diff --git a/package.json b/package.json index 6cdc2d9d6..9fa0867ad 100644 --- a/package.json +++ b/package.json @@ -57,19 +57,19 @@ }, "devDependencies": { "@ava/typescript": "^1.1.1", - "@sindresorhus/tsconfig": "^0.7.0", + "@sindresorhus/tsconfig": "^0.8.0", "@sinonjs/fake-timers": "^6.0.1", - "@types/b...
2
2
0
[{"id": "G0", "claim": "In the 'reads multiple cookies' test, the destructured cookies should use the non-null assertion `!` instead of optional chaining `?`.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "In the 'reads a cookie' test, `cookie` should us...
null
sindresorhus__got__1739
sindresorhus/got
1,739
defect
f896aa52abc41fe40d4942da94a0408477358f14
b40be7c8e9b46f72302f92082644c98a07c953fd
HTTPError code set to 'HTTPError' #1711
This is my understanding of the intention of #1711. This sets the code property on the HTTPError object to 'HTTPError' instead of leaving it as undefined. #### Checklist - [X] I have read the documentation. - [X] I have included a pull request description of my changes. - [X] I have included some tests (update...
diff --git a/readme.md b/readme.md index 82a89c170..e0655aaa7 100644 --- a/readme.md +++ b/readme.md @@ -1705,43 +1705,44 @@ Additionaly, the errors may have `request` (Got Stream) and `response` (Got Resp #### got.RequestError -When a request fails. Contains a `code` property with error class code, like `ECONNREF...
6
6
1
[{"id": "G0", "claim": "The code defaulting should be done on all errors at once for consistency, and the codes should use a better name than `HTTPError`, following the Node.js error code convention.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "unclear"}, {"id": "G1", "claim": "Omit setti...
null
sindresorhus__got__1768
sindresorhus/got
1,768
defect
7524d9051d96c10924045d902ae219857ca3e57b
9935868b1c9cab0e67e48935f49d55a8d9be2d16
Fix default pagination handling for empty `Link` header
## Background This fixes https://github.com/sindresorhus/got/issues/1741. #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [ ] If it's a new feature, I have included documentation updates in both the README ...
diff --git a/source/core/options.ts b/source/core/options.ts index b8343debd..b2df99268 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -674,11 +674,12 @@ const defaultInternals: Options['_internals'] = { return JSON.parse(response.body as string); }, paginate: ({response}) => { - if (ty...
1
1
1
[{"id": "G0", "claim": "The default paginate check should also treat a whitespace-only Link header as empty, using rawLinkHeader.trim() === '' instead of rawLinkHeader === '', to be fully resilient.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
sindresorhus__got__1835
sindresorhus/got
1,835
defect
79547b35067f141cd6c1c528e5042fa4662fdf97
56454f6130e76b9667637bd07fa0547784845aa7
Add support for `FormData` request body
This PR brings general support for `multipart/form-data` encoding and allows to use any spec-comliant FormData object as request body. This PR also introduces a new dependency [`form-data-encoder`](https://npmjs.com/package/form-data-encoder), so you might expect it to add about 37 KB of extra size into the install siz...
diff --git a/documentation/2-options.md b/documentation/2-options.md index 0ac3faacb..86230be70 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -271,7 +271,7 @@ stream.on('data', console.log); ### `body` -**Type: `string | Buffer | stream.Readable | Generator | AsyncGenerator` or [`form...
6
6
2
[{"id": "G0", "claim": "The custom content-type header set by the developer should be sent no matter the content type — the encoder-generated content-type should only be used when the developer has not set one, otherwise the FormData body is not encoded and not sent correctly.", "category": "correctness", "verdict": "s...
null
sindresorhus__got__2020
sindresorhus/got
2,020
defect
4f24bd11fb50757ec8753a74e4a7b18de95ba155
561a14ef458927bf2fbb9d520950e282fc975600
Support `AbortController`
Fixes #1511. Thanks for this awesome lib! :) I added `signal` option for supporting `AbortController`. when `AbortController.abort` is called, throws `DOMException` in the promise of `asPromise.ts`. About tests, I copied, pasted and fixed `cancel.ts` to `abort.ts`. I'd appreciate it if you could let me k...
diff --git a/documentation/2-options.md b/documentation/2-options.md index 968a22baa..2d9aa1efe 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -209,6 +209,29 @@ await got('https://httpbin.org/anything'); #### **Note:** > - If you're passing an absolute URL as `url`, you need to set `prefi...
12
9
4
[{"id": "G0", "claim": "Throw an `AbortError` class inheriting from `RequestError` instead of a `DOMException`, since `DOMException` does not exist until Node 17, is not a `NodeJS.ErrnoException`, and strips the `code` and request metadata users need.", "category": "design", "verdict": "supported", "priority": "P1", "s...
null
sindresorhus__got__2043
sindresorhus/got
2,043
defect
c25af092bf792c2c7e29db848a569f2eb3e527f8
b8572e7624c9fe30f17e60e119a1240b80839548
Add `response.ok`
Fixes #2036 Added a boolean ok to the response from got API to indicate whether status code is within 200 & 299 i.e. 2xx. #### Checklist - [X] I have read the documentation. - [X] I have included a pull request description of my changes. - [X] I have included some tests. - [x] If it's a new feature, I have ...
diff --git a/source/core/index.ts b/source/core/index.ts index 1d913c265..2fe465dcd 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -147,6 +147,7 @@ export default class Request extends Duplex implements RequestEvents<Request> { requestUrl?: URL; redirectUrls: URL[]; retryCount: number; + ok?: boo...
6
6
3
[{"id": "G0", "claim": "The pull request must also update the documentation, since it adds the response.ok property without documenting it.", "category": "documentation", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The doc comment on `ok` should read 'Whether the response wa...
null
sindresorhus__got__2062
sindresorhus/got
2,062
defect
5c628ccc4fe520214ca3fabdf7607ec9e89e38e8
1624cc07b8e0c3d4444f25a5564f4997f1333e83
Add `enableUnixSockets` option
### What is the PR for? For issue #2046, we add an option to control if unix domain socket is supported: ```js // enableUnixSocket is default to false before Got v13 const gotUnixSocketEnabled = got.extend({enableUnixSocket: true}); ``` ### How is the PR tested? Unit tests. #### Checklist - [x] I h...
diff --git a/documentation/2-options.md b/documentation/2-options.md index f5e10669a..15b0c539d 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -918,6 +918,28 @@ By default, requests will not use [method rewriting](https://datatracker.ietf.or For example, when sending a `POST` request and...
18
17
4
[{"id": "G0", "claim": "The pull request also needs to update the documentation, moving the UNIX Domain Sockets section from documentation/tips.md into the options docs for this option.", "category": "documentation", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The sentence \...
null
sindresorhus__got__2145
sindresorhus/got
2,145
defect
26fffe94618b370629f6148b6d21ebfeab1e5299
0a48ba7ff48da9b8cac240965309231c6f0cf85b
Improve docs and disable method rewriting on 307 and 308
Solves #2136: - Improve/extend the documentation on method rewriting behavior - Disable method rewriting on 307 and 308 redirects, as this is explicitly prohibited by the spec #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have inclu...
diff --git a/documentation/2-options.md b/documentation/2-options.md index bc39348ba..969a3f702 100644 --- a/documentation/2-options.md +++ b/documentation/2-options.md @@ -692,7 +692,7 @@ Defines if redirect responses should be followed automatically. #### **Note:** > - If a `303` is sent by the server in response...
6
6
0
[{"id": "G0", "claim": "The documentation reference to `methodRewriting` in the redirect note should be rendered as a link.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new nested `if` condition in the redirect handler should not be nested; ...
null
sindresorhus__got__2162
sindresorhus/got
2,162
defect
623229fad64b89a58c68c9f47fc36a4883cc994a
22b72cfdc2b3e7319d21432f8588d0b01561c371
Fix resource leak by removing abort event listeners on destroy
This change removes the event listener callback that is added to the passed `AbortSignal` when the *got* instance is destroyed. I'm not entirely sure that this fix covers all clean up points. I skipped the clean up on the redirect which I think is correct but would appreciate confirmation. Also I'd be open to add...
diff --git a/source/core/index.ts b/source/core/index.ts index 0a054fd64..1e9ecb37c 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -176,6 +176,7 @@ export default class Request extends Duplex implements RequestEvents<Request> { private _triggerRead: boolean; declare private _jobs: Array<() => void>...
3
2
1
[{"id": "G0", "claim": "When the signal is already aborted, the abort listener is still registered (leaking it) and the suggested `return;` would also skip the nodeStream body branch, so the signal handling should be moved after the `if (is.nodeStream(body))` branch and only register the listener when the signal is not...
null
sindresorhus__got__2325
sindresorhus/got
2,325
defect
3822412385506a1efef6580d270eae14086b9b43
85eb541ab9585bc62d777a8140d930e37b1aea76
feat: allow typing the body of a RequestError response
#### Checklist Made `RequestError`/`HTTPError` to be generic eg. ```ts await got('https://google.com', { responseType: 'json' }) .catch((err: HTTPError<{ code: number, message: string}>) => console.log(err.response.body.message)); ``` Resolves https://github.com/sindresorhus/got/issues/2312 - [x] I hav...
diff --git a/source/core/errors.ts b/source/core/errors.ts index d344517da..a1ab5b003 100644 --- a/source/core/errors.ts +++ b/source/core/errors.ts @@ -16,13 +16,13 @@ function isRequest(x: unknown): x is Request { An error to be thrown when a request fails. Contains a `code` property with error class code, like `EC...
1
1
1
[{"id": "G0", "claim": "HTTPError's default type parameter should be `unknown` rather than `any` (as `RequestError`'s already is), and since that would be a breaking change, at least add a code comment (TODO) to change it to `unknown` in the next major version.", "category": "design", "verdict": "supported", "priority"...
null
sindresorhus__got__2327
sindresorhus/got
2,327
defect
f10e151c87b02ad1ed60d75becd076d17f16f099
a26165abbaa7ddbf47b4745396c2342277e73c1a
feat: add original error property
Add root error as `RequestError['cause']` Resolves #2010 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates in both the README and the types....
diff --git a/documentation/8-errors.md b/documentation/8-errors.md index 2cb97aa7d..38cb8a0b4 100644 --- a/documentation/8-errors.md +++ b/documentation/8-errors.md @@ -19,8 +19,9 @@ All Got errors contain various metadata, such as: Read the article [here](async-stack-traces.md). -**Note:** +> [!NOTE] > - The err...
2
2
0
[{"id": "G0", "claim": "The 'should wrap non-got cause' test should be rewritten without adding the socks and socks-proxy-agent dev dependencies, since every added dependency adds a maintenance burden.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim...
null
sindresorhus__got__2388
sindresorhus/got
2,388
defect
f4f3ba88e4db2270792385e7d32a694d7432d232
ec311440b0c5d25b978aa49a9622e52a1dcfafe8
fix: correct support for AbortSignal:timeout()
See #2371 This changes the rejected value to TimeotError when `AbortSignal:timeout()` is initially aborted. As stated in [docs](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static#return_value): > The signal will abort with its [AbortSignal.reason](https://developer.mozilla.org/en-US/do...
diff --git a/source/core/index.ts b/source/core/index.ts index 842bc4def..12c98d213 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -264,7 +264,12 @@ export default class Request extends Duplex implements RequestEvents<Request> { if (this.options.signal) { const abort = () => { - this.destro...
1
1
0
[{"id": "G0", "claim": "Use a named constant instead of the magic number 23 for the AbortSignal.timeout error code in the tests.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__got__2436
sindresorhus/got
2,436
defect
3b90c761b5442a54e9212f87a3e3bb6f345196e0
6ea7289c8010b44b820faa3711d503f73babff9d
Stream decoding of large bodies
Fixes #2433
diff --git a/source/core/index.ts b/source/core/index.ts index d3bc620d9..ab5c30fd2 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -31,7 +31,12 @@ import Options, { type OptionsInit, type NormalizedOptions, } from './options.js'; -import {isResponseOk, type PlainResponse, type Response} from './re...
1
1
1
[{"id": "G0", "claim": "Since `await from.toArray()` waits for the stream to complete, the buffer-to-string decoding happens all at once after the full response body is received, so streaming the decode gives no benefit unless decoding happens incrementally (e.g. TextDecoderStream or TextDecoder.decode(buffer, {stream:...
null
sindresorhus__got__787
sindresorhus/got
787
defect
6eaa81ba8db87340bbdbd79ef91594803f37b854
09c219e5cf34b9a4dfb36ad9886bf2c517c0427c
Fix the retry functionality and increase coverage
Fixes #786
diff --git a/source/errors.ts b/source/errors.ts index 853ae5e6b..027bc9a67 100644 --- a/source/errors.ts +++ b/source/errors.ts @@ -1,5 +1,4 @@ import urlLib from 'url'; -import http from 'http'; import is from '@sindresorhus/is'; import {Timings} from '@szmarczak/http-timer'; import {Response, Options} from './ut...
4
4
0
[{"id": "G0", "claim": "Add a doc code comment to source/utils/unhandle.ts explaining the purpose of the unhandler and what problem it solves.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "In source/utils/unhandle.ts, `Fn` needs a more descriptiv...
null
sindresorhus__got__809
sindresorhus/got
809
defect
f77db9929096d0b56cde7981e3f8b1ca635eb628
3e69c1812e92e3107d5083936652b8b89a13aced
Fix default `retry` option value when specifying a number
Fixes: https://github.com/sindresorhus/got/issues/806 #### Checklist - [x] I have read the documentation.
diff --git a/source/index.ts b/source/index.ts index 547fa7f05..f4c10b11d 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,60 +1,5 @@ -import packageJson from '../package.json'; import create from './create'; - -const defaults = { - options: { - method: 'GET', - retry: { - retries: 2, - methods: [ - '...
8
5
2
[{"id": "G0", "claim": "The pre-existing test 'works when defaults.options.retry is not an object' fails because the extended instance now retries on 413 (retryCount 2 instead of the asserted 0), so it should be tested against 2.", "category": "testing", "verdict": "supported", "priority": "P0", "scope": "introduced"},...
null
sindresorhus__got__812
sindresorhus/got
812
defect
f77db9929096d0b56cde7981e3f8b1ca635eb628
93a9cb192a1b0a5aca2640b793a9a94d089130c7
Pass the response as the second argument to the `beforeRedirect` hook
Closes #810 > The `beforeRedirect` hook will receive the original response (the one that has a 3xx status code) as the second argument. #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new fe...
diff --git a/readme.md b/readme.md index 6219188d6..f79798100 100644 --- a/readme.md +++ b/readme.md @@ -408,7 +408,7 @@ See the [AWS section](#aws) for an example. Type: `Function[]`<br> Default: `[]` -Called with [normalized](source/normalize-arguments.js) [request options](#options). Got will make no further cha...
2
2
2
[{"id": "G0", "claim": "The response parameter added to the beforeRedirect hook should be typed as a concrete response type (IncomingMessage) rather than `any`, and the type should not accept `ResponseLike`.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "cla...
null
sindresorhus__got__827
sindresorhus/got
827
defect
e9c01e03b07acb80ef5501dab97e9dd1a2e61af8
bd376c8fcd01282f953e01390a1cd6b769419ef0
Add remote IP address to the response
Fixes #356 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </...
diff --git a/source/request-as-event-emitter.ts b/source/request-as-event-emitter.ts index 8a9e55445..121e9d55b 100644 --- a/source/request-as-event-emitter.ts +++ b/source/request-as-event-emitter.ts @@ -8,7 +8,6 @@ import CacheableRequest = require('cacheable-request'); import toReadableStream = require('to-readable...
6
3
2
[{"id": "G0", "claim": "The naming of the newly added `ResponseObject` interface should be confirmed as okay.", "category": "design", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The remote IP address cannot be provided for cached responses without extending cacheable-request a...
null
sindresorhus__got__830
sindresorhus/got
830
defect
e9c01e03b07acb80ef5501dab97e9dd1a2e61af8
eec03fa6d1d60edf0f10c367b507bd550f488d62
Don't break the default behavior when using custom retry function
#### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. Fixes #753 <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </...
diff --git a/readme.md b/readme.md index 546615da4..959e7861c 100644 --- a/readme.md +++ b/readme.md @@ -322,20 +322,21 @@ This also accepts an `object` with the following fields to constrain the duratio Type: `number | object`<br> Default: -- retries: `2` +- limit: `2` +- retryFunction: `(iteration, retryOptions, ...
4
3
3
[{"id": "G0", "claim": "The RetryFunction signature has a poorly named `retry` argument, lacks a doc comment for `computedValue`, and takes too many positional arguments, so it should pass one object as an argument instead.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id":...
null
sindresorhus__got__833
sindresorhus/got
833
defect
3ff567524072b0d2417802002602df7fd8e21cc6
b26d9bb96a53a69c87cb1015ba7f0da449809a1e
Experimental pagination feature
Fixes #722 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates. <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </...
diff --git a/source/create.ts b/source/create.ts index 01823ed37..8114e1c68 100644 --- a/source/create.ts +++ b/source/create.ts @@ -14,7 +14,7 @@ import deepFreeze from './utils/deep-freeze'; import merge, {mergeOptions} from './merge'; import asPromise, {isProxiedSymbol} from './as-promise'; import asStream, {Prox...
7
6
1
[{"id": "G0", "claim": "The PR should not implement a default `paginate` function, and filtering should be a separate property, because users may want to go forwards, backwards, or filter elements.", "category": "design", "verdict": "opposed", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The default...
null
sindresorhus__got__910
sindresorhus/got
910
defect
abd95a3be4d93c8aa332de8ccf0b506939993c93
0454f7aaa02463ae75ca6e854634b0a7529644c8
Don't merge `context`, `body`, `json`, `form` & fix types
Fixes #897
diff --git a/source/create.ts b/source/create.ts index 367974c2c..1d1217f74 100644 --- a/source/create.ts +++ b/source/create.ts @@ -8,7 +8,8 @@ import { URLOrOptions, URLArgument, HandlerFunction, - ExtendedOptions + ExtendedOptions, + NormalizedDefaults } from './utils/types'; import deepFreeze from './utils/...
2
2
1
[{"id": "G0", "claim": "The thrown hooks error message makes no sense and should be more helpful.", "category": "correctness", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new test should also check that context, form, body and hooks payloads are never mutated, to guard a...
null
sindresorhus__got__914
sindresorhus/got
914
defect
63cb1b2345745fd47fb4c7b21f05a205aa3b1562
81437758166a425a900a74b2b594e32f98724c82
Add `maxRedirects` option
Fixes #838 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates.
diff --git a/readme.md b/readme.md index e1ae5bd20..0d7927ec3 100644 --- a/readme.md +++ b/readme.md @@ -368,6 +368,13 @@ Defines if redirect responses should be followed automatically. Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request...
1
1
0
[{"id": "G0", "claim": "The existing 'throws on endless redirects' test in test/redirects.ts should be renamed to indicate it now checks the default maxRedirects behavior.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "pre_existing"}]
null
sindresorhus__got__942
sindresorhus/got
942
defect
6cc3d9f3027f28ce4dcbe8605d104e65f7e66787
81b54e1cd9a784eb2fa7f3b37e03385debde8083
Add `methodRewriting` option
Fixes #934 #### Checklist - [x] I have read the documentation. - [x] I have included a pull request description of my changes. - [x] I have included some tests. - [x] If it's a new feature, I have included documentation updates.
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..63c9bf66a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +yarn.lock +coverage +.nyc_output +dist +.*.dockerfile \ No newline at end of file diff --git a/readme.md b/readme.md index bd3028c0a..a11a52de1 100644 --- a/readme....
3
3
0
[{"id": "G0", "claim": "The new option should be named `methodRewriting` instead of `enableMethodRewriting`, since the \"enable\" prefix is implied.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The readme's methodRewriting description should clarify th...
null
sindresorhus__ky__339
sindresorhus/ky
339
defect
bf5be2f27b614ae632285d995e2b7dcfec985bcd
587cd2c6baf49cd0d6f6be84ae29f7735369d65e
Remove some `@ts-expect-error`
- [x] fixed in production code - [x] fixed in tests - [x] ts:check errors - [x] tests - [x] resolved conflicts But I didn't remove every `@ts-expect-error` as sometimes it's needed (for error validation in test cases) Fixes #337
diff --git a/package.json b/package.json index 3bac6ee8..22f82629 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ ], "devDependencies": { "@sindresorhus/tsconfig": "^1.0.1", + "@type-challenges/utils": "^0.1.1", "@types/body-parser": "^1.19.0", "@types/busboy": "^0.2.3", "@types/express"...
4
1
0
[{"id": "G0", "claim": "The new `@type-challenges/utils` devDependency, added only for `Expect` and `Equal`, could be avoided by defining those helpers without a dependency.", "category": "maintainability", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G4", "claim": "Use of `as` type asserti...
null
sindresorhus__ky__417
sindresorhus/ky
417
defect
3e72832a33dc591e7704dc9288a25c094aefa45d
1ddac7b3376803b1ba0959d05e2b66442aa127ad
Add `beforeError` hook
Fixes #412
diff --git a/readme.md b/readme.md index f9775a32..c6924eb6 100644 --- a/readme.md +++ b/readme.md @@ -258,6 +258,33 @@ const response = await ky('https://example.com', { }); ``` +###### hooks.beforeError + +Type: `Function[]`\ +Default: `[]` + +This hook enables you to modify the HTTPError right before it is throw...
6
6
2
[{"id": "G0", "claim": "Linting is not passing on this pull request; commits should pass `npm test` locally before being pushed.", "category": "correctness", "verdict": "supported", "priority": "P0", "scope": "introduced"}, {"id": "G1", "claim": "The new `beforeError` hook needs to be documented in the readme too.", "c...
null
sindresorhus__ky__454
sindresorhus/ky
454
defect
da40323e903fb943c9192e4a43f9dc601d16a5e8
6e0ff050019ed6e0e840c84c9c2149deae6ec394
Add retry.backoffLimit option
I saw in the source code that the retry backoff function is hardcoded and exponential. However, I wanted to customize it. Fortunately I also found the open issue addressing this limitation. To start simple, I added a `backoffLimit` so that you can cap the delay that is exponentially growing. After 5 or so retries t...
diff --git a/source/core/Ky.ts b/source/core/Ky.ts index 0603c894..6dbc1579 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -218,7 +218,7 @@ export class Ky { } const BACKOFF_FACTOR = 0.3; - return BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000; + return Math.min(this._options.retry.backo...
9
7
2
[{"id": "G0", "claim": "The JSDoc for backoffLimit should describe the option in simpler higher-level terms without mentioning `computedValue`.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The closing block-comment delimiter of the backoffLimit ...
null
sindresorhus__ky__482
sindresorhus/ky
482
defect
b322f7cddb6c9a1687a1775224cd0690bd406a95
2773f42570e37d18fdf0da4582f6ecfb24ff653f
feat: Throw DomException with name AbortError
## Description When throwing DomException it should provide `AbortError` name to the DomException constructor as specified in the MDN docs [here](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) ![Screenshot 2023-01-11 at 15 49 58](https://user-images.githubusercontent.com/155505/211836956-ed...
diff --git a/source/errors/DOMException.ts b/source/errors/DOMException.ts index 3d771cd1..69a5b120 100644 --- a/source/errors/DOMException.ts +++ b/source/errors/DOMException.ts @@ -1,8 +1,20 @@ -const DOMException = globalThis.DOMException ?? Error; +// DomException is supported on most modern browsers, and Node >= 1...
5
5
1
[{"id": "G0", "claim": "Use `t.is()` instead of `t.true()` with `===` for asserting the error name in the abort test.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Rename `domExceptionSupported` to `isDomExceptionSupported` via the reviewer's s...
null
sindresorhus__ky__536
sindresorhus/ky
536
defect
577dd4c5e36f214930a22247523a73d37847c335
76d87eb0821da2737cc9af5b0d91e4e9d8e1768e
Pass unknown options to fetch
This PR implements option number 2 of [this comment](https://github.com/sindresorhus/ky/issues/516#issuecomment-1674303251) by @sholladay. > Ky starts passing unknown options directly to fetch instead of relying on the Request class to do it for us. This is the right thing for Ky to do but might prove to be a little...
diff --git a/source/core/Ky.ts b/source/core/Ky.ts index f45d1011..04c2ca2d 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -8,6 +8,7 @@ import {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize. import timeout, {type TimeoutOptions} from '../utils/timeout.js'; import delay from '../ut...
2
1
0
[{"id": "G0", "claim": "The variable `requestInit` in source/core/Ky.ts could be named `nonRequestOptions` or `unhandledOptions` to say what it holds.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The change to the Options types leaves users wi...
null
sindresorhus__ky__579
sindresorhus/ky
579
defect
7760a811976338a27dc93c100125489afbf0271d
1e1e476311873c049bb051eac5fd19c7e350982c
feat: add support for `stringifyJson`
When sending an HTTP request, this option allows the user to specify how the request data should be serialized as a string. For example, it will be useful when users want to change the default serialization behavior using `JSON.stringify(_, replacer)`. ```typescript import ky from 'ky'; import { DateTime } from...
diff --git a/readme.md b/readme.md index b31fbcc3..44ca2d29 100644 --- a/readme.md +++ b/readme.md @@ -426,6 +426,29 @@ const json = await ky('https://example.com', { }).json(); ``` +##### stringifyJson + +Type: `Function`\ +Default: `JSON.stringify()` + +User-defined JSON-stringifying function. + +Use-cases: +1. S...
3
3
0
[{"id": "G0", "claim": "In source/core/Ky.ts the json body should be set with `this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json)` instead of a ternary.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The expected body...
null
sindresorhus__ky__598
sindresorhus/ky
598
defect
36d0bd3ed3a3d3d915536988311fd046fa325e8c
2c71d104175f9cbbdaa99aff7a6c71b7111bfa15
feat(retry): allow respecting Retry-After for user-defined status codes
Implemented as recommended in related issue, with appropriate testing and documentation. The included test is just a copy of the existing 413 one, but with a 500 and required config instead. Closes #473.
diff --git a/readme.md b/readme.md index d410de48..633f3e18 100644 --- a/readme.md +++ b/readme.md @@ -212,14 +212,17 @@ Default: - `limit`: `2` - `methods`: `get` `put` `head` `delete` `options` `trace` - `statusCodes`: [`408`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) [`413`](https://developer....
6
5
1
[{"id": "G0", "claim": "The `console.log(result)` debug statement should be removed from the new 'respect custom `afterStatusCodes` (500)' test.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The newly added module-level `retryAfterOn500` and `lastTried...
null
sindresorhus__ky__611
sindresorhus/ky
611
defect
4886b666ec65aec8e51e59a89d3daf130a24c878
64843f41cf8223264675a6403d3dcd91c1d9c8f9
Add support for passing a function to ky.extend()
callback function receives parent's default options to allow extended instance to refer to modify parent options Closes #586
diff --git a/readme.md b/readme.md index 9826868a..ae4da97a 100644 --- a/readme.md +++ b/readme.md @@ -510,6 +510,22 @@ console.log('unicorn' in response); //=> true ``` +You can also refer to parent defaults by providing a function to `.extend()`. + +```js +import ky from 'ky'; + +const api = ky.create({prefixUrl:...
3
3
0
[{"id": "G0", "claim": "Add a test permutation covering what happens when the extend function does not set parent options, i.e. whether `prefixUrl` is still inherited when the function leaves it out.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Add a ...
null
sindresorhus__ky__618
sindresorhus/ky
618
defect
fbe0ec68b052a9df6221a3531553783860925289
37b7a9bb03e2f213b6dc581b320086db343e63c0
Add support for the `RateLimit-Reset` header
Closes #608 This PR adds automatic handling for non-standard rate limiting headers that are used by some APIs (e.g. GitHub and Twitter) instead of `Retry-After`. The following headers are now supported as a fallback for `Retry-After`: - `RateLimit-Reset` as proposed by https://www.ietf.org/archive/id/draft-poll...
diff --git a/readme.md b/readme.md index 86045eca..acf581f8 100644 --- a/readme.md +++ b/readme.md @@ -208,7 +208,7 @@ An object representing `limit`, `methods`, `statusCodes`, `afterStatusCodes`, an If `retry` is a number, it will be used as `limit` and other defaults will remain in place. -If the response provid...
1
1
1
[{"id": "G0", "claim": "Falling back to RateLimit-Reset/X-RateLimit-Reset without detecting the value format is incorrect because X-RateLimit-Reset (GitHub) carries UTC epoch-seconds rather than delta-seconds, so a third value type must be detected (e.g. treat a number greater than 1700000000 as a timestamp).", "catego...
null
sindresorhus__ky__671
sindresorhus/ky
671
defect
4a427011ad7b4ab98bb5f02ecaa5375fba5addca
ccc96440779803552af0721a0fba3e68de8fcff1
Fix options.method being undefined in normalized options
Fix `options.method` (where `options` has the `NormalizedOptions` type) being `undefined` when no method is provided. Fixes #670.
diff --git a/source/core/Ky.ts b/source/core/Ky.ts index 5218d6c7..17bd53b5 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -135,7 +135,7 @@ export class Ky { }, options.hooks, ), - method: normalizeRequestMethod(options.method ?? (this._input as Request).method), + method: normalizeRequestM...
2
2
1
[{"id": "G0", "claim": "Keep casting `this._input` to `Request` (or `RequestInit`) instead of using `instanceof Request`, so Request-like objects remain acceptable and the expression stays short.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Use `t.plan...
null
sindresorhus__ky__706
sindresorhus/ky
706
defect
3207ecc30677fea718b8206a1bd9d3ea152a9975
b45193e87c7f428794a3f2a3cfb4a6e2b7da6844
Don't produce URL with "?" alone
When the `searchParams` is an empty project, `ky` still produce URL with question mark, like "/path?". It should be without "?". This PR is to fix that.
diff --git a/source/core/Ky.ts b/source/core/Ky.ts index 81907932..9c4d813f 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -14,7 +14,7 @@ import {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize. import timeout, {type TimeoutOptions} from '../utils/timeout.js'; import delay from '../...
2
1
0
[{"id": "G0", "claim": "Because the cache is identified by URL, the two URLs \"/path?\" and \"/path\" will make the browser (or proxy) create two caches even though they point to the same document, which is wasteful.", "category": "performance", "verdict": "uncertain", "priority": "P2", "scope": "pre_existing"}, {"id":...
null
sindresorhus__ky__746
sindresorhus/ky
746
defect
ac3e6149b449ad49e51e89543b1dc27e8bfba7bd
f860cb1b04abdc71f90acba8541dc251a64f3174
Add type guards for errors
Introduce type guards to enhance error handling in the Ky client, allowing for more precise identification of HTTP and timeout errors. This improves the robustness of error management in the application. closes #742
diff --git a/readme.md b/readme.md index 0fd70b9b..f19c00e6 100644 --- a/readme.md +++ b/readme.md @@ -622,13 +622,21 @@ Be aware that some types of errors, such as network errors, inherently mean that If you need to read the actual response when an `HTTPError` has occurred, call the respective parser method on the re...
6
5
1
[{"id": "G0", "claim": "last commit adds a fallback name check in case instanceof fails for some reason.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "IMO, these functions should be standalone and not attached to the Ky instance.", "category": "design",...
null
sindresorhus__ky__751
sindresorhus/ky
751
defect
7e1fd0ba60be6ae2c5aec0ef401393a54d98e372
8a412739d8331d84a837e5b21e62e3e69e034f3b
Fix `signal` merging when using both instance and request options
Fixes #748
diff --git a/source/utils/merge.ts b/source/utils/merge.ts index 525d49b5..fffaaab5 100644 --- a/source/utils/merge.ts +++ b/source/utils/merge.ts @@ -48,6 +48,7 @@ export const deepMerge = <T>(...sources: Array<Partial<T> | undefined>): T => { let returnValue: any = {}; let headers = {}; let hooks = {}; + const ...
1
1
1
[{"id": "G0", "claim": "The new merge logic calls AbortSignal.any without a feature check, which will throw a TypeError in browsers where AbortSignal.any is missing (the rest of the codebase checks supportsAbortSignal for this reason) whenever instance options with a signal are merged with request options, so guard the...
null
sindresorhus__ky__772
sindresorhus/ky
772
defect
f0fdbd407504e3d3ed60db7b6460972d5134aef8
c99800818975a8eaf078fa433b5d52e4d6931b80
Add support for `context` object
Fixes #677
diff --git a/readme.md b/readme.md index 5db42bce..51279692 100644 --- a/readme.md +++ b/readme.md @@ -614,6 +614,68 @@ import fetch from 'isomorphic-unfetch'; const json = await ky('https://example.com', {fetch}).json(); ``` +##### context + +Type: `object<string, unknown>`\ +Default: `{}` + +User-defined data pas...
1
1
1
[{"id": "G0", "claim": "Add `t.plan()` to the hooks test (and ideally the others) so the test fails if the hooks don't run instead of passing vacuously.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
sindresorhus__ky__789
sindresorhus/ky
789
defect
337a1b2cf565d1e327d70377c65ef6c1a6318e70
08d4065e794ec9f87f6fab8afee761ce08467791
Changes type of retry.methods option to HttpMethod
I learned the hard way that the methods need to be lowercase (and kept wondering why the requests are not retried). This change should prevent that mistake --- Fixes #807
diff --git a/source/core/constants.ts b/source/core/constants.ts index 4e66e213..fb814be4 100644 --- a/source/core/constants.ts +++ b/source/core/constants.ts @@ -1,5 +1,6 @@ import type {Expect, Equal} from '@type-challenges/utils'; -import {type HttpMethod, type KyOptionsRegistry} from '../types/options.js'; +import...
2
2
1
[{"id": "G0", "claim": "Circular dependencies are fine in ESM, so avoiding one does not justify moving HttpMethod out of options.ts into common.ts; the type belongs back in options.ts.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "Hardcoding HttpMethod ...
null
sindresorhus__ky__806
sindresorhus/ky
806
defect
4b6cd2fe28b3b80a95b011de3ad227f89cced25b
c7a16eb7033e646ad05bf8d62b1ec7f6ede1c261
Avoid awaiting response cancel on forced retry
This fixes #803 where `ky.retry()` hangs when `afterResponse` hooks clone a response and then force a retry without consuming or canceling the extra clone. `Response.clone` uses `ReadableStream.tee`, and the Streams spec allows cancel promises to remain pending until all tee branches are canceled. Ky only controls the ...
diff --git a/source/core/Ky.ts b/source/core/Ky.ts index c387b510..c8ecada0 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -62,10 +62,9 @@ export class Ky { } if (modifiedResponse instanceof RetryMarker) { - // Cancel both the cloned response passed to the hook and the current response - ...
1
1
0
[{"id": "G0", "claim": "Since cancellation errors are deliberately ignored in the retry cleanup, Promise.allSettled() and the cleanupPromises array are unnecessary there.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__meow__154
sindresorhus/meow
154
defect
629af48c24a2f19636512b2f532cfcd9419f9be1
f26f8310764edfa2cbbcd40c7f107e2dc5e81ada
Improve flags types to acknowledge `isMultiple` and `isRequired` options
This PR fixes two things in the types of flags: 1. Without this PR the type of an `isMultiple` flag is still reported to be a non-array. 2. All types are right now reported as always being defined, even when both `isRequired` and `default` is missing. This PR adds `|undefined` in those cases + does so in the case w...
diff --git a/index.d.ts b/index.d.ts index e92d14a..6366dfb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -25,7 +25,8 @@ declare namespace meow { type BooleanFlag = Flag<'boolean', boolean>; type NumberFlag = Flag<'number', number>; - type AnyFlags = {[key: string]: StringFlag | BooleanFlag | NumberFlag}; + type A...
1
1
1
[{"id": "G0", "claim": "The isMultiple branch of TypedFlags should apply PossiblyOptionalFlag's logic, since a flag with isMultiple: true and no default resolves to undefined for empty argv instead of the expected array; NiGhTTraX suggests addressing it in another PR alongside a test, treating the PR as an improvement ...
null
sindresorhus__meow__168
sindresorhus/meow
168
defect
a1f5f0fb16057e137259607565a319e5d3e2152b
c97d60e251795c15cd32980cb49d0b68805916c2
Fix reporting missing required flags
Fixes https://github.com/sindresorhus/meow/issues/165. Also updated readme.md. Note that I've made a transitive dependency explicit (decamelize). Rather than add the latest version, I've stuck with the older version brought in by decamelize-keys to avoid unnecessary bloat.
diff --git a/index.js b/index.js index dccbcb5..9d14dec 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const path = require('path'); const buildParserOptions = require('minimist-options'); const parseArguments = require('yargs-parser'); const camelCaseKeys = require('camelcase-keys'); +const decamelize = requi...
3
2
1
[{"id": "G0", "claim": "The error thrown by validateOptions should be rewritten with a template literal instead of string concatenation, per the suggestion block.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The doc comments in index.d.ts need...
null
sindresorhus__meow__169
sindresorhus/meow
169
defect
a1f5f0fb16057e137259607565a319e5d3e2152b
fc33c0fb887ed43e8d3af01d9f02cfa3f653fb81
Add `allowUnknownFlags` options
fix #126 To simplify figuring out which flags are unknown, I tried: 1. Pass [unknown-options-as-args](https://www.npmjs.com/package/yargs-parser#unknown-options-as-args) to yargs-parser first; 2. Filter unknown options collected in `argv._` which starts with `-`. And I also make `allowUnknownFlags` be `true`...
diff --git a/index.d.ts b/index.d.ts index df3f10e..ad9bf13 100644 --- a/index.d.ts +++ b/index.d.ts @@ -199,6 +199,13 @@ declare namespace meow { @default true */ readonly hardRejection?: boolean; + + /** + Whether to allow unknown flags or not. + + @default true + */ + readonly allowUnknownFlags?: boole...
6
5
0
[{"id": "G0", "claim": "The test file should import `path` with an ESM import at the top instead of `const path = require('path')` after the other imports.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The test titles should capitalise 'CLI' ('...
null
sindresorhus__meow__182
sindresorhus/meow
182
defect
8c12b2dd2988d6d358a75c4b3962ab452640eac7
ffe125a250a4acf8202060a16c6e034666e24f01
Allow user to pass in package URL for package reading
Related to #176 ### Changes - Add `importMeta` option for allowing users to pass in their package URL - Apply `importMeta` option to all the test code ### Spec - `importMeta` is required - Its value should be `import.meta`
diff --git a/estest/index.js b/estest/index.js index c10f205..23cfb8d 100644 --- a/estest/index.js +++ b/estest/index.js @@ -13,6 +13,7 @@ meow( 🌈 unicorns 🌈 `, { + packagePath: import.meta.url, flags: { rainbow: { type: 'boolean', diff --git a/index.d.ts b/index.d.ts index 70733bc..cc09578 1006...
4
3
2
[{"id": "G0", "claim": "Consider having users read the package at their side and pass it in, since the existing `pkg` option already supports that, instead of the pull request's new path-based package reading.", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim"...
null
sindresorhus__meow__228
sindresorhus/meow
228
defect
dc0e33cc33c890bbd8dd9c74d5e0db7173335fbb
5404d58d51c08269c3f38612d67611006aa77534
Add `choices` option
Closes #171. Continues from #183. Improves the error messages, adds tests cases, and aggregates option validation error messages. Currently the choices array isn't validated to be the same type as the flag. There were a couple of days in between starting and creating this PR, so I may have missed something.
diff --git a/index.d.ts b/index.d.ts index b9ba23c..a68251a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,13 +15,14 @@ Callback function to determine if a flag is required during runtime. */ export type IsRequiredPredicate = (flags: Readonly<AnyFlags>, input: readonly string[]) => boolean; -export type Flag<Type ...
2
2
1
[{"id": "G0", "claim": "The test 'choices - choices must be of the same type' should be changed from `test.failing` to a passing `test`, i.e. the choices-of-mixed-types case should actually be validated instead of left as a known-failing test.", "category": "correctness", "verdict": "supported", "priority": "P1", "scop...
null
sindresorhus__meow__241
sindresorhus/meow
241
defect
1d083266d4c4f3b37da22693cf22235ca7fe9fb5
d66b3016a865e2dc434d40d87d4a1c4a5e641779
feat: support indent level as option
Fixes #240
diff --git a/readme.md b/readme.md index d6a9eeb..0aec4cf 100644 --- a/readme.md +++ b/readme.md @@ -299,6 +299,13 @@ Default: `true` Whether to allow unknown flags or not. +##### helpIndent + +Type `number`\ +Default: `2` + +Indentation to use on helpText. + ## Promises Meow will make unhandled rejected promi...
3
2
1
[{"id": "G0", "claim": "The `index.test-d.ts` file needs to be updated (the new option lacks type-definition test coverage).", "category": "testing", "verdict": "uncertain", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The readme description of `helpIndent` (\"Indentation to use on helpText.\") need...
null
sindresorhus__meow__242
sindresorhus/meow
242
defect
58eedf48e594b112ac8b3bf14dff1ccd6e0b38c9
ce2954bd2d8b8489011ca0ee54c3cf9424f5b0bb
Use Rollup for bundling dependencies
Closes #67. Bumps dev dependencies and adds an `_actualDependencies` field. Builds on `prepare` and outputs a bundled `dependencies.js` and `licenses.md` to the `build` folder: ```sh \__ build/ \__ licenses.md # License of each bundled dependency \__ dependencies.js # Vendor bundle \__ index.js \__ optio...
diff --git a/.gitignore b/.gitignore index 239ecff..cf762fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules +dist yarn.lock diff --git a/package.json b/package.json index 92d88b9..61f4c12 100644 --- a/package.json +++ b/package.json @@ -13,16 +13,19 @@ "type": "module", "exports": { "type...
6
5
3
[{"id": "G0", "claim": "The bundled code should not be minified with terser; debugging is important and minification saves little.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The bundled dependencies need to be devDependencies, with a custom package.j...
null
sindresorhus__np__308
sindresorhus/np
308
defect
cec8e001794170db18d6c9cb468644d97441e697
36f46080c984ac8006a9fde1bee5bd6d5cd62020
Open a GitHub Releases draft after publish
fix #306
diff --git a/index.js b/index.js index 0bf3d833..34ab6c58 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ const prerequisiteTasks = require('./lib/prerequisite'); const gitTasks = require('./lib/git'); const util = require('./lib/util'); const publish = require('./lib/publish'); +const release = require('./li...
12
12
4
[{"id": "G0", "claim": "The task title should spell \"GitHub\" instead of \"Github\".", "category": "correctness", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The release task needs skip/enable logic so it does not run when the repository is not hosted on GitHub.", "category...
null
sindresorhus__np__495
sindresorhus/np
495
defect
a44f05df56bb192dc5511d6503cee8739f46915d
b50b94c04750686507a8b76480efe9ac9a2f4042
Add tests for the config
Fixes #381. I used `proxyquire` for mocking the dependencies `is-installed-globally` and `pkg-dir`. Mocking with [`sinon`](https://github.com/sinonjs/sinon/issues/562) was not possible. <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </summary> ### Referenced issues This pull request h...
diff --git a/test/config.js b/test/config.js new file mode 100644 index 00000000..c47ba70b --- /dev/null +++ b/test/config.js @@ -0,0 +1,35 @@ +import path from 'path'; +import os from 'os'; +import test from 'ava'; +import sinon from 'sinon'; +import proxyquire from 'proxyquire'; + +const stubOs = sinon.stub(os, 'home...
4
4
1
[{"id": "G0", "claim": "Rename the `os.homedir` stub from `stubOs` to `homedirStub` in test/config.js.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Add tests covering the edge cases where the global config is only used when the global `np` bin...
null
sindresorhus__np__505
sindresorhus/np
505
defect
5d1a00bb5c40c30f6adb30b6ad4719d841de5e6b
26bd2c6ced8cac11863c233878a2a51228db961b
Fix 2FA prompt when the package exists
<!-- Thanks for submitting a pull request 🙌 **Note:** Please don't create a pull request which has significant changes (i.e. adds new functionality or modifies existing one in a non-trivial way) without creating an issue first. Try to limit the scope of your pull request and provide a general description of t...
diff --git a/source/cli.js b/source/cli.js index fd0be0c4..b4ff0506 100755 --- a/source/cli.js +++ b/source/cli.js @@ -95,9 +95,12 @@ updateNotifier({pkg: cli.pkg}).notify(); ...cli.flags }; - const runPublish = flags.publish && !pkg.private; + const runPublish = flags.publish && !pkg.private; - const availab...
6
5
1
[{"id": "G0", "claim": "Reviewer asks why the pull request reindents the runPublish line from a tab to two spaces — a formatting-only change with no apparent purpose.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "Reviewer questions why the prev...
null
sindresorhus__np__509
sindresorhus/np
509
defect
a44f05df56bb192dc5511d6503cee8739f46915d
0a1cf1a2ca0138db2937d7eeed17c2c5a2c8a5d4
Add pre-publish task tests
Fixes #384. Stubs were created for the commands as mention in my [comment](https://github.com/sindresorhus/np/issues/384#issuecomment-589947855). The tests run serially because the stubbed `execa`-dependency is cached when loaded the first time (see https://github.com/avajs/ava/issues/1066 and https://nodejs.org/api/m...
diff --git a/package.json b/package.json index 98921dbc..33b56e64 100644 --- a/package.json +++ b/package.json @@ -67,8 +67,27 @@ }, "devDependencies": { "ava": "^2.3.0", + "execa_test_double": "^4.0.0", + "mockery": "^2.1.0", "proxyquire": "^2.1.0", "sinon": "^8.0.1", "xo": "^0.25.3" + }, + "x...
4
4
0
[{"id": "G0", "claim": "Passing tests in test/prerequisite-tasks.js (and in the other places doing the same) should assert with `t.notThrowsAsync(...)` instead of a bare `t.pass()` after `await run(...)`.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "T...
null
sindresorhus__np__547
sindresorhus/np
547
defect
1f701cdea14febb9f28a9791d395db85e51b6222
945b2c99779cb52411534163a6f6657f4f827341
Respect `preId` in `.npmrc` for release tags
Fixes #523 . Additionally, has unit tests for the new function introduced to get `preId` if available. Tested on MacOS10.13.6.
diff --git a/source/release-task-helper.js b/source/release-task-helper.js index 5dcaab2c..b8506bb0 100644 --- a/source/release-task-helper.js +++ b/source/release-task-helper.js @@ -1,12 +1,12 @@ 'use strict'; const open = require('open'); const newGithubReleaseUrl = require('new-github-release-url'); -const {getTa...
3
2
1
[{"id": "G0", "claim": "The new `ow(options, ow.object.hasKeys('yarn'))` guard may make the `npm` config branch below it moot, since non-yarn users would not pass the check.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The method name `getPreId` s...
null
sindresorhus__np__560
sindresorhus/np
560
defect
6be4223543ae8a63e1b0e8a5b6eaa7ec4b60d0fe
97ad2672cc4c829f78ea19ccfecc3be75c04e0f5
Create release draft even when pushing to protected branches failed
Fixes #502. Setup for tests: 1. setup branch protection fro some playground repository 2. publish new version with `np` The tags should be pushed and the release draft should be created.
diff --git a/source/git-util.js b/source/git-util.js index e59b0570..bd55ad1f 100644 --- a/source/git-util.js +++ b/source/git-util.js @@ -126,8 +126,18 @@ exports.commitLogFromRevision = async revision => { return stdout; }; -exports.push = async () => { - await execa('git', ['push', '--follow-tags']); +exports.p...
3
3
2
[{"id": "G0", "claim": "The GH006 protected-branch error check should use error.stderr.includes('GH006') instead of the exact-prefix error.stderr.indexOf('remote: error: GH006: Protected branch update failed') === 0 comparison.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introdu...
null
sindresorhus__np__616
sindresorhus/np
616
defect
c97b1df5875767ae0676bd7e15de987724ca7f3b
d7e5eb9d824ef5b1848e4756f8d5f90647e18d4e
Fix error "glob pattern string required"
Fixes #614
diff --git a/integration-test b/integration-test index ae82745e..b2492e19 160000 --- a/integration-test +++ b/integration-test @@ -1 +1 @@ -Subproject commit ae82745e85ff662a569d64c896cb53b80091e654 +Subproject commit b2492e190f3864f96955a7acb4349bb9722530b9 diff --git a/source/npm/util.js b/source/npm/util.js index d2...
1
1
0
[{"id": "G0", "claim": "The empty-input guard should be more explicit: check `globArray.length === 0` and return `[]` before computing `globString`, as suggested.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}]
null
sindresorhus__ow__1
sindresorhus/ow
1
defect
bd362ece978a6f9846d40e0869c0651f21384606
6eb3b82f04c05172c75d619e558dfad3ab851f41
Rewrite in TypeScript
I just took a stab at rewriting this in TypeScript. Didn't add TSLint yet and it should be finetuned as well, but I think it's a good start to receive the first feedback.
diff --git a/.gitignore b/.gitignore index 239ecff..7dda61e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules +dist +coverage +.nyc_output yarn.lock diff --git a/.travis.yml b/.travis.yml index 7d69d74..81ab236 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,5 @@ node_js: - '8' - '6' ...
7
6
1
[{"id": "G0", "claim": "The coverage upload should switch from coveralls, which the reviewer finds slow and buggy, to Codecov.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The `files` list in package.json must include the directory the build o...
null
sindresorhus__ow__109
sindresorhus/ow
109
defect
97e1b19989e900cdcf70a88cb22651bcc1a46efe
6416806449961a640780b7a9c0c3c5e17ae3c81a
Add `number.integerOrInfinite` predicate
I assumed that `value` should be positive as well :slightly_smiling_face: Resolves #95
diff --git a/source/lib/predicates/number.ts b/source/lib/predicates/number.ts index 7813960..7cd361c 100644 --- a/source/lib/predicates/number.ts +++ b/source/lib/predicates/number.ts @@ -131,4 +131,11 @@ export class NumberPredicate extends Predicate<number> { validator: value => value < 0 }); } + + get inte...
4
4
2
[{"id": "G0", "claim": "The name `integerOrInfinity` does not reflect the behavior as long as positive, non-zero numbers are the only ones enforced.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The validator's `value > 0` restriction wrongly rejects 0 ...
null
sindresorhus__ow__127
sindresorhus/ow
127
defect
3cf642138b71554200d063d868bb5d2c515aa3b3
96afb5a28d92f0d894d023634fc471ba6b3249b5
Add object shape validators
This PR introduces `ow.object.partialShape` and `ow.object.exactShape` 🎉. See #92 for the discussion. Fixes #92
diff --git a/source/index.ts b/source/index.ts index bc641bb..7050e5a 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,9 +1,10 @@ import callsites from 'callsites'; import {inferLabel} from './lib/utils/infer-label'; import {Predicate} from './lib/predicates/predicate'; -import {testSymbol, BasePredicate, is...
4
4
0
[{"id": "G0", "claim": "The newly introduced `is-plain-obj` dependency should be dropped in favour of the existing `plainObject` check from `is`.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The JSDoc for `partialShape` and `exactShape` should...
null
sindresorhus__ow__13
sindresorhus/ow
13
defect
98ba0c039eedaa18f248e9131dc357e961df4c83
b3163ac73d8331d282122afbe2f9c6f8aaa07741
Add boolean validator
Adds a boolean predicate with two getters, `true` and `false`.
diff --git a/source/lib/predicates/boolean.ts b/source/lib/predicates/boolean.ts new file mode 100644 index 0000000..e657241 --- /dev/null +++ b/source/lib/predicates/boolean.ts @@ -0,0 +1,28 @@ +import { Predicate, Context } from './predicate'; + +export class BooleanPredicate extends Predicate<boolean> { + + construc...
1
1
0
[{"id": "G0", "claim": "Write the true/false validators as explicit comparisons (`value => value === true` and `value => value === false`) for readability.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}]
null
sindresorhus__ow__130
sindresorhus/ow
130
defect
6951a1643f5587fd0c21988ab5ab46a08ee6ae0c
8bae5f8ffdfa7481e1c116a31cb2a2db0841b7d6
Add proper `not` messages
This PR adds proper `not` messages, so instead of e.g. `[NOT] Expected number to be greater than 5, got 6 ` we get `Expected number to not be greater than 5, got 6`. It also introduces breaking changes - no more `validator.nonEmpty()` methods (`validator.not.empty` looks nicer 🙂). Fixes #101 <!-- Issuehunt conten...
diff --git a/source/lib/operators/not.ts b/source/lib/operators/not.ts index 2c9f79a..e2f6d8f 100644 --- a/source/lib/operators/not.ts +++ b/source/lib/operators/not.ts @@ -10,10 +10,15 @@ export const not = <T, P extends Predicate<T>>(predicate: P) => { const originalAddValidator = predicate.addValidator; predic...
6
6
2
[{"id": "G0", "claim": "Move the random placeholder generation out of `not` into a `random-id` util under source/utils and call `randomId()` instead.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Don't remove the `nonEmpty` getters and their te...
null
sindresorhus__ow__184
sindresorhus/ow
184
defect
b2285d0d4fe59def762bd989cab067d8d9b66eab
c24a8f56dce81166bb1f64996e041d37fb0cb1fc
Allow potentially undefined functions to be checked
proposed changes to fix #147 <!-- Issuehunt content --> --- <details> <summary> <b>IssueHunt Summary</b> </summary> ### Referenced issues This pull request has been submitted to: - [#147: TypeScript optional function argument throws error TS2345 with `ow.optional.function`](https://issuehunt.io/repos/105227249/is...
diff --git a/source/predicates/predicate.ts b/source/predicates/predicate.ts index 3902eae..bdf960c 100644 --- a/source/predicates/predicate.ts +++ b/source/predicates/predicate.ts @@ -86,13 +86,15 @@ export class Predicate<T = unknown> implements BasePredicate<T> { /** @hidden */ - [testSymbol](value: T, main: M...
2
2
1
[{"id": "G0", "claim": "Add tests covering the new ability to check potentially undefined functions.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Avoid the `value as T` cast on the known value in [testSymbol] — TS should be able to infer the type afte...
null
sindresorhus__ow__194
sindresorhus/ow
194
defect
72c1463a74853ecc6adf41f5aca1b9d7162f43b9
dfe9f01760bc562960047ba72c386db7d461a0be
Add `asserts` annotations
Fixes #159 Also adds: - Type-level tests - A generic typearg for ArrayPredicate and ObjectPredicate. So `ow.array.ofType(ow.string)` infers `string[]` and `ow.object.exactShape({ foo: ow.string, bar: ow.object.exactShape({ baz: ow.number }) })` infers `{ foo: string; bar: { baz: number } }` - A Shape -> TypeOfSh...
diff --git a/package.json b/package.json index af63398..249c235 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@types/vali-date": "^1.0.0", "ava": "^2.0.0", "del-cli": "^3.0.1", + "expect-type": "^0.11.0", "nyc": "^15.1.0", "ts-node": "^9.0.0", "typedoc": "^0.19.2", diff --git a/read...
2
2
0
[{"id": "G0", "claim": "The double type-cast (`as unknown as ArrayPredicate<U>`) in `ofType` should be avoided if there is any way to have TypeScript handle the type without forcing it.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "A short doc comment e...
null
sindresorhus__ow__213
sindresorhus/ow
213
defect
49841a260cd431985b91d319b091dd59096775a3
34500edd2245df28eb7531d6ac48285614363e3c
Avoid unnecessary inference of stack for label
- For `ow.isValid`, it's acutually not necessary to inference the stack for the label because the message won't actually be used. - For the check of elements, e.g. `ow.object.valuesOfType`, `ow.array.ofType`, `ow.map.keysOfType`, `ow.map.valuesOfType`, `ow.set.ofType`, the inference of the label can also be avoided. ...
diff --git a/source/index.ts b/source/index.ts index 81845f3..f0dc8ad 100644 --- a/source/index.ts +++ b/source/index.ts @@ -81,7 +81,8 @@ Object.defineProperties(ow, { isValid: { value: <T>(value: T, predicate: BasePredicate<T>): boolean => { try { - ow(value, predicate); + // Use a dummy label to avoid...
1
1
1
[{"id": "G0", "claim": "The new map error message is incorrect because backticks should mark variable names or types, so it should ideally read '(Map) Expected item 0 to be of type `number` but received type `string`'.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}]
null
sindresorhus__ow__28
sindresorhus/ow
28
defect
568eb70488097c337da6a23a481943a03843a0cf
4768539080ef9216d71680aa52608a8cf7f01965
Add symbol, undefined and null predicates
Completed all the primitive predicates by adding `symbol`, `undefined` and `null`.
diff --git a/source/index.ts b/source/index.ts index 748f6db..640919b 100644 --- a/source/index.ts +++ b/source/index.ts @@ -28,6 +28,18 @@ export interface Ow { * Test the value to be a Date. */ date: DatePredicate; + /** + * Test the value to be a Symbol. + */ + symbol: Predicate<Symbol>; + /** + * Test th...
2
1
0
[{"id": "G0", "claim": "The `symbol` predicate should be placed after `null`, since checking for a symbol is not as common.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The `Object.defineProperties` block could be refactored into a map-driven loop of p...
null
sindresorhus__p-queue__161
sindresorhus/p-queue
161
defect
35e2d38b6e081475547b3c96d2e8f17f337acbd7
513e46b91d28a5924b68406502ce4d5ab244bed7
Support `AbortController`
Fixes #78
diff --git a/readme.md b/readme.md index dc32de4..af8f1ec 100644 --- a/readme.md +++ b/readme.md @@ -118,7 +118,7 @@ Note: If your items can potentially throw an exception, you must handle those er Type: `Function` -Promise-returning/async function. +Promise-returning/async function. When executed, it will receive...
3
2
1
[{"id": "G0", "claim": "When a queued job is aborted before it runs, the `queue.add()` promise never settles; it should reject instead, using a normal error for now with a TODO comment to switch to Node.js ABORT_ERR.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "...
null
sindresorhus__p-queue__94
sindresorhus/p-queue
94
defect
c2e768f540dd22380bdf84c8cbd5a794ccac5e02
09992c275d6dcf5392b8c33ebdc1754ce38733d9
Add `.sizeBy()` method to find queue size by priority
Thanks for a great and useful library. We use `p-queue` to totally order all of the web requests our app makes. However this means that there is a risk that when the user closes the tab, there is some work left pending in the promise queue. We use priority to discern between important requests (eg. a user action)...
diff --git a/package.json b/package.json index 0997daa..a734597 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "random-int": "^2.0.0", "time-span": "^3.1.0", "ts-node": "^8.3.0", - "typescript": "^3.7.2", + "typescript": "3.7.2", "xo": "^0.25.3" }, "ava": { diff --git a/source/index.ts...
4
4
1
[{"id": "G0", "claim": "The sizeBy doc comment should also include the use-case, so users get hints about how it could be useful to them.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new sizeBy feature also needs to be documented in the read...
null
sindresorhus__pageres__356
sindresorhus/pageres
356
defect
3da607975a18f4f97fe2fbcf2e13756609ffde76
8b898a439f5eb8663ef0c78d03d187cf69781fac
Enable TypeScript strict mode
We need definitions for the below modules before we proceed. - [x] `easydate` - [x] `array-differ` - [x] `get-res` - [x] `capture-website` see https://github.com/sindresorhus/capture-website/pull/19 - [x] `viewport-list` closes #350
diff --git a/package.json b/package.json index 096097a..957a2d2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "main": "dist", "engines": { @@ -53,7 +5...
10
7
2
[{"id": "G0", "claim": "The png-js import in the tests should use the published @types/png.js package rather than a hand-written module declaration.", "category": "maintainability", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The png-js import needs @ts-ignore because a .d.ts ...
null
sindresorhus__react-extras__25
sindresorhus/react-extras
25
defect
463f76af7205f830522c5184dd1f6994e0e13340
a162e67f266507acca2bb33e09239d4dc24fbed3
Add `intersperse` function and `Join` component
Fixes #24
diff --git a/index.d.ts b/index.d.ts index b099cea..1b82ee8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,6 +3,7 @@ import { type ComponentClass, type HTMLProps, type ReactNode, + type JSX, } from 'react'; /** @@ -358,5 +359,97 @@ body.dark-mode { */ export class BodyClass extends ReactComponent<ElementCla...
6
3
0
[{"id": "G0", "claim": "JoinProps declares children as a required prop even though the implementation and tests support rendering Join with no children, so TypeScript consumers cannot use the zero-children case; make children optional.", "category": "correctness", "verdict": "uncertain", "priority": "P1", "scope": "int...
null
sindresorhus__react-extras__27
sindresorhus/react-extras
27
defect
603e49569f4a459172b79df454c8ee36eb59e65a
dde1dbb25a72292e115b31497ff1381a2caa5632
Add `useEventListener`, `useWindowEvent`, and `useDocumentEvent` hooks
Fixes #26 --- I realize it looks complicated, but this is the simplest I could do while still handling everything details around React correctly. It does a lot so the user doesn't have to use `useMemo` for options and stuff.
diff --git a/index.d.ts b/index.d.ts index d692b55..ef51770 100644 --- a/index.d.ts +++ b/index.d.ts @@ -451,5 +451,134 @@ import {Join} from 'react-extras'; */ export function Join(props: JoinProps): JSX.Element; +// eslint-disable-next-line @typescript-eslint/ban-types +type NullishTarget<T> = T | null | undefine...
2
2
2
[{"id": "G0", "claim": "Add a test covering the case where the handler callback is wrapped with useEffectEvent.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "normalizeOptions assumes options is an object, so non-object values such as null would not be ...
null