eslint-plugin-class-validator-type-match 3.1.4 → 4.1.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/dist/index.d.ts +23 -37
- package/dist/index.js +95 -39
- package/dist/rules/decorator-type-match.d.ts +3 -1
- package/dist/rules/definite-assignment-match.d.ts +3 -1
- package/dist/rules/dto-filename-match.d.ts +3 -1
- package/dist/rules/optional-decorator-match.d.ts +3 -1
- package/dist/rules/type-decorator-match.d.ts +3 -1
- package/dist/rules/validate-nested-match.d.ts +3 -1
- package/package.json +21 -15
- package/readme.md +40 -20
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,34 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
1
2
|
declare const _default: {
|
|
3
|
+
meta: {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
2
7
|
rules: {
|
|
3
|
-
'decorator-type-match':
|
|
4
|
-
|
|
8
|
+
'decorator-type-match': TSESLint.RuleModule<"mismatch" | "enumMismatch" | "invalidEachOption", [], unknown, TSESLint.RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
'optional-decorator-match': TSESLint.RuleModule<"missingOptionalDecorator" | "missingOptionalSyntax" | "conflictingDefiniteAssignment" | "undefinedUnionWithoutDecorator" | "undefinedUnionWithoutOptional" | "nullUnionIncorrect" | "redundantUndefinedInType", [{
|
|
5
12
|
strictNullChecks?: boolean;
|
|
6
13
|
checkDefaultValues?: boolean;
|
|
7
14
|
customOptionalDecorators?: string[];
|
|
8
|
-
}], unknown,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
plugins: string[];
|
|
17
|
-
rules: {
|
|
18
|
-
'class-validator-type-match/decorator-type-match': string;
|
|
19
|
-
'class-validator-type-match/optional-decorator-match': string;
|
|
20
|
-
'class-validator-type-match/validate-nested-match': string;
|
|
21
|
-
'class-validator-type-match/type-decorator-match': string;
|
|
22
|
-
'class-validator-type-match/definite-assignment-match': string;
|
|
23
|
-
'class-validator-type-match/dto-filename-match': string;
|
|
24
|
-
};
|
|
15
|
+
}], unknown, TSESLint.RuleListener> & {
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
'validate-nested-match': TSESLint.RuleModule<"nestedArrayMismatch" | "missingValidateNested" | "missingEachOption" | "unnecessaryValidateNested" | "tupleValidationWarning" | "multiTypeUnionWarning" | "mixedComplexityUnionWarning" | "pickOmitWarning", [], unknown, TSESLint.RuleListener> & {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
'type-decorator-match': TSESLint.RuleModule<"typeMismatch" | "missingTypeDecorator", [], unknown, TSESLint.RuleListener> & {
|
|
22
|
+
name: string;
|
|
25
23
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rules: {
|
|
29
|
-
'class-validator-type-match/decorator-type-match': string;
|
|
30
|
-
'class-validator-type-match/optional-decorator-match': string;
|
|
31
|
-
'class-validator-type-match/validate-nested-match': string;
|
|
32
|
-
'class-validator-type-match/type-decorator-match': string;
|
|
33
|
-
'class-validator-type-match/definite-assignment-match': string;
|
|
34
|
-
'class-validator-type-match/dto-filename-match': string;
|
|
35
|
-
};
|
|
24
|
+
'definite-assignment-match': TSESLint.RuleModule<"incorrectDefiniteAssignment", [], unknown, TSESLint.RuleListener> & {
|
|
25
|
+
name: string;
|
|
36
26
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
rules: {
|
|
40
|
-
'class-validator-type-match/decorator-type-match': string;
|
|
41
|
-
'class-validator-type-match/optional-decorator-match': string;
|
|
42
|
-
'class-validator-type-match/definite-assignment-match': string;
|
|
43
|
-
'class-validator-type-match/dto-filename-match': string;
|
|
44
|
-
};
|
|
27
|
+
'dto-filename-match': TSESLint.RuleModule<"incorrectDtoClassName", [], unknown, TSESLint.RuleListener> & {
|
|
28
|
+
name: string;
|
|
45
29
|
};
|
|
46
30
|
};
|
|
31
|
+
configs: Record<string, TSESLint.ClassicConfig.Config>;
|
|
32
|
+
flatConfigs: TSESLint.FlatConfig.SharedConfigs;
|
|
47
33
|
};
|
|
48
34
|
export = _default;
|
package/dist/index.js
CHANGED
|
@@ -8,46 +8,102 @@ const validate_nested_match_1 = __importDefault(require("./rules/validate-nested
|
|
|
8
8
|
const type_decorator_match_1 = __importDefault(require("./rules/type-decorator-match"));
|
|
9
9
|
const definite_assignment_match_1 = __importDefault(require("./rules/definite-assignment-match"));
|
|
10
10
|
const dto_filename_match_1 = __importDefault(require("./rules/dto-filename-match"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const package_json_1 = require("../package.json");
|
|
12
|
+
const rules = {
|
|
13
|
+
'decorator-type-match': decorator_type_match_1.default,
|
|
14
|
+
'optional-decorator-match': optional_decorator_match_1.default,
|
|
15
|
+
'validate-nested-match': validate_nested_match_1.default,
|
|
16
|
+
'type-decorator-match': type_decorator_match_1.default,
|
|
17
|
+
'definite-assignment-match': definite_assignment_match_1.default,
|
|
18
|
+
'dto-filename-match': dto_filename_match_1.default,
|
|
19
|
+
};
|
|
20
|
+
const plugin = {
|
|
21
|
+
meta: {
|
|
22
|
+
name: package_json_1.name,
|
|
23
|
+
version: package_json_1.version,
|
|
24
|
+
},
|
|
25
|
+
rules,
|
|
26
|
+
};
|
|
27
|
+
// Legacy configs for .eslintrc (extends: ['plugin:class-validator-type-match/recommended'])
|
|
28
|
+
const legacyConfigs = {
|
|
29
|
+
recommended: {
|
|
30
|
+
plugins: ['class-validator-type-match'],
|
|
31
|
+
rules: {
|
|
32
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
33
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
34
|
+
'class-validator-type-match/validate-nested-match': 'error',
|
|
35
|
+
'class-validator-type-match/type-decorator-match': 'error',
|
|
36
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
37
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
38
|
+
},
|
|
19
39
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'class-validator-type-match/dto-filename-match': 'error',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
strict: {
|
|
33
|
-
plugins: ['class-validator-type-match'],
|
|
34
|
-
rules: {
|
|
35
|
-
'class-validator-type-match/decorator-type-match': 'error',
|
|
36
|
-
'class-validator-type-match/optional-decorator-match': 'error',
|
|
37
|
-
'class-validator-type-match/validate-nested-match': 'error',
|
|
38
|
-
'class-validator-type-match/type-decorator-match': 'error',
|
|
39
|
-
'class-validator-type-match/definite-assignment-match': 'error',
|
|
40
|
-
'class-validator-type-match/dto-filename-match': 'error',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
basic: {
|
|
44
|
-
plugins: ['class-validator-type-match'],
|
|
45
|
-
rules: {
|
|
46
|
-
'class-validator-type-match/decorator-type-match': 'error',
|
|
47
|
-
'class-validator-type-match/optional-decorator-match': 'error',
|
|
48
|
-
'class-validator-type-match/definite-assignment-match': 'error',
|
|
49
|
-
'class-validator-type-match/dto-filename-match': 'error',
|
|
50
|
-
},
|
|
40
|
+
strict: {
|
|
41
|
+
plugins: ['class-validator-type-match'],
|
|
42
|
+
rules: {
|
|
43
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
44
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
45
|
+
'class-validator-type-match/validate-nested-match': 'error',
|
|
46
|
+
'class-validator-type-match/type-decorator-match': 'error',
|
|
47
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
48
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
51
49
|
},
|
|
52
50
|
},
|
|
51
|
+
basic: {
|
|
52
|
+
plugins: ['class-validator-type-match'],
|
|
53
|
+
rules: {
|
|
54
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
55
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
56
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
57
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
// Flat configs for eslint.config.ts (classValidatorTypeMatch.configs.recommended)
|
|
62
|
+
const flatConfigs = {
|
|
63
|
+
recommended: {
|
|
64
|
+
name: 'class-validator-type-match/recommended',
|
|
65
|
+
plugins: {
|
|
66
|
+
'class-validator-type-match': plugin,
|
|
67
|
+
},
|
|
68
|
+
rules: {
|
|
69
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
70
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
71
|
+
'class-validator-type-match/validate-nested-match': 'error',
|
|
72
|
+
'class-validator-type-match/type-decorator-match': 'error',
|
|
73
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
74
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
strict: {
|
|
78
|
+
name: 'class-validator-type-match/strict',
|
|
79
|
+
plugins: {
|
|
80
|
+
'class-validator-type-match': plugin,
|
|
81
|
+
},
|
|
82
|
+
rules: {
|
|
83
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
84
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
85
|
+
'class-validator-type-match/validate-nested-match': 'error',
|
|
86
|
+
'class-validator-type-match/type-decorator-match': 'error',
|
|
87
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
88
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
basic: {
|
|
92
|
+
name: 'class-validator-type-match/basic',
|
|
93
|
+
plugins: {
|
|
94
|
+
'class-validator-type-match': plugin,
|
|
95
|
+
},
|
|
96
|
+
rules: {
|
|
97
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
98
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
99
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
100
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
module.exports = {
|
|
105
|
+
meta: plugin.meta,
|
|
106
|
+
rules,
|
|
107
|
+
configs: legacyConfigs,
|
|
108
|
+
flatConfigs,
|
|
53
109
|
};
|
|
@@ -46,5 +46,7 @@ type MessageIds = 'mismatch' | 'enumMismatch' | 'invalidEachOption';
|
|
|
46
46
|
* name!: string; // Error: { each: true } on non-array type
|
|
47
47
|
* }
|
|
48
48
|
*/
|
|
49
|
-
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener
|
|
49
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
50
52
|
export default _default;
|
|
@@ -66,5 +66,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
66
66
|
* name!: string | undefined;
|
|
67
67
|
* }
|
|
68
68
|
*/
|
|
69
|
-
declare const _default: ESLintUtils.RuleModule<"incorrectDefiniteAssignment", [], unknown, ESLintUtils.RuleListener
|
|
69
|
+
declare const _default: ESLintUtils.RuleModule<"incorrectDefiniteAssignment", [], unknown, ESLintUtils.RuleListener> & {
|
|
70
|
+
name: string;
|
|
71
|
+
};
|
|
70
72
|
export default _default;
|
|
@@ -44,5 +44,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
44
44
|
* filter?: string;
|
|
45
45
|
* }
|
|
46
46
|
*/
|
|
47
|
-
declare const _default: ESLintUtils.RuleModule<"incorrectDtoClassName", [], unknown, ESLintUtils.RuleListener
|
|
47
|
+
declare const _default: ESLintUtils.RuleModule<"incorrectDtoClassName", [], unknown, ESLintUtils.RuleListener> & {
|
|
48
|
+
name: string;
|
|
49
|
+
};
|
|
48
50
|
export default _default;
|
|
@@ -71,5 +71,7 @@ type Options = [
|
|
|
71
71
|
* value: string | null; // Should be value?: string or value: string | undefined
|
|
72
72
|
* }
|
|
73
73
|
*/
|
|
74
|
-
declare const _default: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener
|
|
74
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
75
77
|
export default _default;
|
|
@@ -39,5 +39,7 @@ type MessageIds = 'typeMismatch' | 'missingTypeDecorator';
|
|
|
39
39
|
* address!: Address;
|
|
40
40
|
* }
|
|
41
41
|
*/
|
|
42
|
-
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener
|
|
42
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
43
45
|
export default _default;
|
|
@@ -46,5 +46,7 @@ type MessageIds = 'nestedArrayMismatch' | 'missingValidateNested' | 'missingEach
|
|
|
46
46
|
* tags!: string[];
|
|
47
47
|
* }
|
|
48
48
|
*/
|
|
49
|
-
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener
|
|
49
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
50
52
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-class-validator-type-match",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "ESLint plugin to ensure class-validator decorators match TypeScript type annotations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -26,29 +26,35 @@
|
|
|
26
26
|
"lint": "eslint \"src/**/*.ts\"",
|
|
27
27
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
28
28
|
"format": "prettier --write \"**/*.{ts,md}\"",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"test:coverage": "vitest run --coverage",
|
|
29
32
|
"prepare": "husky"
|
|
30
33
|
},
|
|
31
34
|
"peerDependencies": {
|
|
32
|
-
"@typescript-eslint/parser": "
|
|
33
|
-
"eslint": "
|
|
35
|
+
"@typescript-eslint/parser": "8.53.0",
|
|
36
|
+
"eslint": "9.39.2"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@typescript-eslint/utils": "
|
|
39
|
+
"@typescript-eslint/utils": "8.53.0"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
|
-
"@commitlint/cli": "20.1
|
|
40
|
-
"@commitlint/config-conventional": "20.
|
|
41
|
-
"@eslint/js": "9.
|
|
42
|
-
"@typescript-eslint/parser": "8.
|
|
43
|
-
"eslint": "
|
|
44
|
-
"
|
|
42
|
+
"@commitlint/cli": "20.3.1",
|
|
43
|
+
"@commitlint/config-conventional": "20.3.1",
|
|
44
|
+
"@eslint/js": "9.39.2",
|
|
45
|
+
"@typescript-eslint/parser": "8.53.0",
|
|
46
|
+
"@typescript-eslint/rule-tester": "8.53.0",
|
|
47
|
+
"@vitest/coverage-v8": "4.0.17",
|
|
48
|
+
"eslint": "9.39.2",
|
|
49
|
+
"globals": "16.5.0",
|
|
45
50
|
"husky": "9.1.7",
|
|
46
|
-
"lint-staged": "16.2.
|
|
47
|
-
"prettier": "3.
|
|
48
|
-
"typescript": "
|
|
49
|
-
"typescript-eslint": "8.
|
|
51
|
+
"lint-staged": "16.2.7",
|
|
52
|
+
"prettier": "3.8.0",
|
|
53
|
+
"typescript": "5.9.3",
|
|
54
|
+
"typescript-eslint": "8.53.0",
|
|
55
|
+
"vitest": "4.0.17"
|
|
50
56
|
},
|
|
51
57
|
"engines": {
|
|
52
|
-
"node": "
|
|
58
|
+
"node": "v25.3.0"
|
|
53
59
|
}
|
|
54
60
|
}
|
package/readme.md
CHANGED
|
@@ -18,12 +18,50 @@ yarn add -D eslint-plugin-class-validator-type-match
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### Flat Config (eslint.config.ts)
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import classValidatorTypeMatch from 'eslint-plugin-class-validator-type-match';
|
|
25
|
+
|
|
26
|
+
export default [classValidatorTypeMatch.flatConfigs.recommended];
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or with manual rule configuration:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import classValidatorTypeMatch from 'eslint-plugin-class-validator-type-match';
|
|
33
|
+
|
|
34
|
+
export default [
|
|
35
|
+
{
|
|
36
|
+
plugins: {
|
|
37
|
+
'class-validator-type-match': classValidatorTypeMatch,
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
'class-validator-type-match/decorator-type-match': 'error',
|
|
41
|
+
'class-validator-type-match/optional-decorator-match': 'error',
|
|
42
|
+
'class-validator-type-match/validate-nested-match': 'error',
|
|
43
|
+
'class-validator-type-match/type-decorator-match': 'error',
|
|
44
|
+
'class-validator-type-match/definite-assignment-match': 'error',
|
|
45
|
+
'class-validator-type-match/dto-filename-match': 'error',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Legacy Config (.eslintrc)
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
// .eslintrc.js
|
|
55
|
+
module.exports = {
|
|
56
|
+
extends: ['plugin:class-validator-type-match/recommended'],
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or with manual rule configuration:
|
|
22
61
|
|
|
23
62
|
```javascript
|
|
24
63
|
// .eslintrc.js
|
|
25
64
|
module.exports = {
|
|
26
|
-
parser: '@typescript-eslint/parser',
|
|
27
65
|
plugins: ['class-validator-type-match'],
|
|
28
66
|
rules: {
|
|
29
67
|
'class-validator-type-match/decorator-type-match': 'error',
|
|
@@ -36,30 +74,12 @@ module.exports = {
|
|
|
36
74
|
};
|
|
37
75
|
```
|
|
38
76
|
|
|
39
|
-
### Recommended Configuration
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
// .eslintrc.js
|
|
43
|
-
module.exports = {
|
|
44
|
-
parser: '@typescript-eslint/parser',
|
|
45
|
-
extends: ['plugin:class-validator-type-match/recommended'],
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
77
|
### Configuration Presets
|
|
50
78
|
|
|
51
79
|
- **`recommended`** - All rules enabled (best for most projects)
|
|
52
80
|
- **`strict`** - All rules enabled with strict settings
|
|
53
81
|
- **`basic`** - Only core type matching rules (decorator-type-match, optional-decorator-match, definite-assignment-match, dto-filename-match)
|
|
54
82
|
|
|
55
|
-
```javascript
|
|
56
|
-
// Use basic preset for less strict validation
|
|
57
|
-
module.exports = {
|
|
58
|
-
parser: '@typescript-eslint/parser',
|
|
59
|
-
extends: ['plugin:class-validator-type-match/basic'],
|
|
60
|
-
};
|
|
61
|
-
```
|
|
62
|
-
|
|
63
83
|
## Rules
|
|
64
84
|
|
|
65
85
|
### `decorator-type-match`
|