eslint-plugin-hyper-fetch 8.1.0 โ 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,84 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐งน Hyper Fetch ESLint Plugin
|
|
2
2
|
|
|
3
|
-
<p>
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<b>ESLint rules to enforce HyperFetch best practices and catch type issues early.</b>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
7
8
|
<a href="https://github.com/BetterTyped/hyper-fetch">
|
|
8
|
-
<img src="https://
|
|
9
|
+
<img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?style=flat" alt="GitHub stars" />
|
|
9
10
|
</a>
|
|
10
|
-
<a href="https://
|
|
11
|
-
<img src="https://
|
|
11
|
+
<a href="https://www.npmjs.com/package/eslint-plugin-hyper-fetch">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/eslint-plugin-hyper-fetch" alt="npm version" />
|
|
12
13
|
</a>
|
|
13
|
-
<a href="https://
|
|
14
|
-
<img src="https://
|
|
14
|
+
<a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md">
|
|
15
|
+
<img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch" alt="License" />
|
|
15
16
|
</a>
|
|
16
17
|
<a href="https://github.com/BetterTyped/hyper-fetch">
|
|
17
|
-
<img src="https://
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://www.npmjs.com/package/@hyper-fetch/react">
|
|
20
|
-
<img src="https://custom-icon-badges.demolab.com/bundlephobia/minzip/@hyper-fetch/react?color=64BC4B&logo=package" />
|
|
18
|
+
<img src="https://img.shields.io/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
21
19
|
</a>
|
|
22
20
|
</p>
|
|
23
21
|
|
|
24
|
-
## About
|
|
22
|
+
## ๐ About
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
analysis. It allows to find generic types issues like typos, missing values or completely incorrect usage of types.
|
|
24
|
+
This ESLint plugin provides static analysis rules specific to HyperFetch. It catches generic type issues like typos, missing values, or incorrect usage of `createClient` and `createRequest` type parameters before they cause runtime errors.
|
|
28
25
|
|
|
29
|
-
##
|
|
26
|
+
## ๐ฏ Key Capabilities
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
- ๐ฎ **Catch type bugs before they run** โ Validates `createClient` and `createRequest` generic parameters at lint time
|
|
29
|
+
- โจ **No more typo-induced `any`** โ Detects misspelled keys like `rsponse` instead of `response`
|
|
30
|
+
- ๐ง **Plug and play** โ Use the recommended preset or configure rules one by one
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
#npm
|
|
35
|
-
npm i eslint-plugin-hyper-fetch
|
|
32
|
+
## ๐ Quick Start
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
```bash
|
|
35
|
+
npm install -D eslint-plugin-hyper-fetch
|
|
39
36
|
```
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```js
|
|
38
|
+
```json
|
|
44
39
|
{
|
|
45
|
-
"extends": [
|
|
46
|
-
// ...
|
|
47
|
-
"plugin:hyper-fetch/recommended"
|
|
48
|
-
]
|
|
40
|
+
"extends": ["plugin:hyper-fetch/recommended"]
|
|
49
41
|
}
|
|
50
42
|
```
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
|
|
44
|
+
Or configure individual rules:
|
|
55
45
|
|
|
56
|
-
```
|
|
46
|
+
```json
|
|
57
47
|
{
|
|
58
|
-
"plugins": [
|
|
59
|
-
// ...
|
|
60
|
-
"hyper-fetch"
|
|
61
|
-
],
|
|
48
|
+
"plugins": ["hyper-fetch"],
|
|
62
49
|
"rules": {
|
|
63
|
-
// ...
|
|
64
50
|
"hyper-fetch/client-generic-types": "error",
|
|
65
51
|
"hyper-fetch/request-generic-types": "error"
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
54
|
```
|
|
69
55
|
|
|
70
|
-
##
|
|
56
|
+
## ๐ Documentation
|
|
57
|
+
|
|
58
|
+
- [ESLint Plugin Docs](https://hyperfetch.bettertyped.com/docs/integrations/plugin-eslint)
|
|
59
|
+
- [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
|
|
71
60
|
|
|
72
|
-
|
|
61
|
+
## ๐ก Examples
|
|
73
62
|
|
|
74
|
-
|
|
63
|
+
### Catches incorrect generic types
|
|
75
64
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
```ts
|
|
66
|
+
// โ This will be flagged by hyper-fetch/request-generic-types
|
|
67
|
+
const getUser = client.createRequest<{
|
|
68
|
+
rsponse: User; // Typo: "rsponse" instead of "response"
|
|
69
|
+
}>()({
|
|
70
|
+
endpoint: "/users/:userId",
|
|
71
|
+
method: "GET",
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// โ
Correct usage โ no lint error
|
|
77
|
+
const getUser = client.createRequest<{
|
|
78
|
+
response: User;
|
|
79
|
+
}>()({
|
|
80
|
+
endpoint: "/users/:userId",
|
|
81
|
+
method: "GET",
|
|
82
|
+
});
|
|
83
|
+
```
|
|
81
84
|
|
|
82
|
-
##
|
|
85
|
+
## License
|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
[MIT](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hyper-fetch",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Eslint plugin for HyperFetch",
|
|
5
5
|
"author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
|
|
6
6
|
"homepage": "https://hyperfetch.bettertyped.com/",
|