@darraghor/eslint-plugin-nestjs-typed 4.0.0 → 4.0.1
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 +46 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## A note on versions
|
|
8
8
|
|
|
9
|
-
Version
|
|
10
|
-
|
|
11
|
-
Version
|
|
9
|
+
- Version `4.x` supports Eslint version `>=8.x` and typescript eslint parser `^6`
|
|
10
|
+
- Version `3.x` supports Eslint version `>=8.x` and typescript eslint parser `^5`
|
|
11
|
+
- Version `2.x` supports Eslint version `<=7.x` and typescript eslint parser `^4`
|
|
12
12
|
|
|
13
13
|
There were many breaking changes between these versions.
|
|
14
14
|
|
|
@@ -18,34 +18,32 @@ This plugin only supports typescript up to the version typescript eslint parser
|
|
|
18
18
|
|
|
19
19
|
## Index of available rules
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| | [`
|
|
29
|
-
| |
|
|
30
|
-
|
|
|
31
|
-
| | [`
|
|
32
|
-
| |
|
|
33
|
-
|
|
|
34
|
-
| | [`
|
|
35
|
-
| | [`
|
|
36
|
-
| |
|
|
37
|
-
|
|
|
38
|
-
| |
|
|
39
|
-
|
|
|
40
|
-
| | [`
|
|
41
|
-
| |
|
|
42
|
-
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Detailed docs are available here: https://github.com/darraghoriordan/eslint-plugin-nestjs-typed/tree/main/src/docs/rules
|
|
21
|
+
| Category | Rule | is on in recommended ruleset? |
|
|
22
|
+
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------- |
|
|
23
|
+
| Nest Modules and Dependency Injection | [`provided-injected-should-match-factory-parameters`](./src/docs/rules/provided-injected-should-match-factory-parameters.md) | Y |
|
|
24
|
+
| | [`injectable-should-be-provided`](./src/docs/rules/injectable-should-be-provided.md) | Y |
|
|
25
|
+
| | | |
|
|
26
|
+
| Nest Swagger | [`api-property-matches-property-optionality`](./src/docs/rules/api-property-matches-property-optionality.md) | Y |
|
|
27
|
+
| | [`controllers-should-supply-api-tags`](./src/docs/rules/controllers-should-supply-api-tags.md) | Y |
|
|
28
|
+
| | [`api-method-should-specify-api-response`](./src/docs/rules/api-method-should-specify-api-response.md) | N |
|
|
29
|
+
| | [`api-method-should-specify-api-operation`](./src/docs/rules/api-method-should-specify-api-operation.md) | Y |
|
|
30
|
+
| | [`api-enum-property-best-practices`](./src/docs/rules/api-enum-property-best-practices.md) | Y |
|
|
31
|
+
| | [`api-property-returning-array-should-set-array`](./src/docs/rules/api-property-returning-array-should-set-array.md) | Y |
|
|
32
|
+
| | | |
|
|
33
|
+
| Preventing bugs | [`param-decorator-name-matches-route-param`](./src/docs/rules/param-decorator-name-matches-route-param.md) | Y |
|
|
34
|
+
| | [`validate-nested-of-array-should-set-each`](./src/docs/rules/validate-nested-of-array-should-set-each.md) | Y |
|
|
35
|
+
| | [`validated-non-primitive-property-needs-type-decorator`](./src/docs/rules/validated-non-primitive-property-needs-type-decorator.md) | Y |
|
|
36
|
+
| | [`all-properties-are-whitelisted`](./src/docs/rules/all-properties-are-whitelisted.md) | Y |
|
|
37
|
+
| | [`all-properties-have-explicit-defined`](./src/docs/rules/all-properties-have-explicit-defined.md) | Y |
|
|
38
|
+
| | | |
|
|
39
|
+
| Security | [`validation-pipe-should-forbid-unknown`](./src/docs/rules/validation-pipe-should-use-forbid-unknown.md) | Y |
|
|
40
|
+
| | [`api-methods-should-be-guarded`](./src/docs/rules/api-methods-should-be-guarded.md) | N |
|
|
41
|
+
| | | |
|
|
42
|
+
| Code Consistency | [`sort-module-metadata-arrays`](./src/docs/rules/sort-module-metadata-arrays.md) | N |
|
|
43
|
+
|
|
44
|
+
The "recommended" ruleset are the default rules that are turned on when you configure the plugin as described in this document.
|
|
45
|
+
|
|
46
|
+
The name "recommended" is an eslint convention. Some rules in this plugin are opinionated and have to be turned on explicitly in your eslintrc file.
|
|
49
47
|
|
|
50
48
|
## Who is this package for?
|
|
51
49
|
|
|
@@ -53,7 +51,7 @@ If you use NestJs (https://nestjs.com/) these ESLint rules will help you to prev
|
|
|
53
51
|
|
|
54
52
|
They mostly check that you are using decorators correctly.
|
|
55
53
|
|
|
56
|
-
The
|
|
54
|
+
The primary groupings of rules in this plugin are...
|
|
57
55
|
|
|
58
56
|
### 1. Detect Nest Dependency Injection issues
|
|
59
57
|
|
|
@@ -83,12 +81,18 @@ https://github.com/typestack/class-validator/issues/438
|
|
|
83
81
|
|
|
84
82
|
## To install
|
|
85
83
|
|
|
84
|
+
The plugin is on npm here: https://www.npmjs.com/package/@darraghor/eslint-plugin-nestjs-typed
|
|
85
|
+
You can see how the rules are used in this NestJS project: https://github.com/darraghoriordan/use-miller
|
|
86
|
+
|
|
86
87
|
```
|
|
87
88
|
npm install --save-dev @darraghor/eslint-plugin-nestjs-typed
|
|
88
89
|
|
|
89
90
|
// or
|
|
90
91
|
|
|
91
92
|
yarn add -D @darraghor/eslint-plugin-nestjs-typed
|
|
93
|
+
// or
|
|
94
|
+
|
|
95
|
+
pnpm add -D @darraghor/eslint-plugin-nestjs-typed
|
|
92
96
|
```
|
|
93
97
|
|
|
94
98
|
If you don't already have `class-validator` you should install that
|
|
@@ -97,14 +101,17 @@ If you don't already have `class-validator` you should install that
|
|
|
97
101
|
npm install class-validator
|
|
98
102
|
|
|
99
103
|
// or
|
|
104
|
+
|
|
100
105
|
yarn add class-validator
|
|
106
|
+
|
|
107
|
+
// or
|
|
108
|
+
|
|
109
|
+
pnpm add class-validator
|
|
101
110
|
```
|
|
102
111
|
|
|
103
112
|
## To configure
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
Then update your eslint with the plugin import and add the recommended rule set
|
|
114
|
+
Update your eslint with the plugin import and add the recommended rule set
|
|
108
115
|
|
|
109
116
|
```ts
|
|
110
117
|
module.exports = {
|
|
@@ -122,7 +129,9 @@ module.exports = {
|
|
|
122
129
|
};
|
|
123
130
|
```
|
|
124
131
|
|
|
125
|
-
Note: the injectables test scans your whole project. It's best to filter out ts things that don't matter - use `filterFromPaths` configuration setting for this.
|
|
132
|
+
Note: the injectables test scans your whole project. It's best to filter out ts things that don't matter - use `filterFromPaths` configuration setting for this. See the rule documentation for more info.
|
|
133
|
+
|
|
134
|
+
There are some defaults already applied.
|
|
126
135
|
|
|
127
136
|
Note: You can easily turn off all the swagger rules if you don't use swagger by adding the `no-swagger` rule set AFTER the recommended rule set.
|
|
128
137
|
|
|
@@ -131,7 +140,7 @@ Note: You can easily turn off all the swagger rules if you don't use swagger by
|
|
|
131
140
|
extends: ["plugin:@darraghor/nestjs-typed/recommended",
|
|
132
141
|
"plugin:@darraghor/nestjs-typed/no-swagger"
|
|
133
142
|
],
|
|
134
|
-
|
|
143
|
+
// more config
|
|
135
144
|
```
|
|
136
145
|
|
|
137
146
|
Disable a single rule with the full name e.g. in your eslint configuration...
|