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 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': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"mismatch" | "enumMismatch" | "invalidEachOption", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
4
- 'optional-decorator-match': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"missingOptionalDecorator" | "missingOptionalSyntax" | "conflictingDefiniteAssignment" | "undefinedUnionWithoutDecorator" | "undefinedUnionWithoutOptional" | "nullUnionIncorrect" | "redundantUndefinedInType", [{
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, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
9
- 'validate-nested-match': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"nestedArrayMismatch" | "missingValidateNested" | "missingEachOption" | "unnecessaryValidateNested" | "tupleValidationWarning" | "multiTypeUnionWarning" | "mixedComplexityUnionWarning" | "pickOmitWarning", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
10
- 'type-decorator-match': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"typeMismatch" | "missingTypeDecorator", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
11
- 'definite-assignment-match': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"incorrectDefiniteAssignment", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
12
- 'dto-filename-match': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"incorrectDtoClassName", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
13
- };
14
- configs: {
15
- recommended: {
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
- strict: {
27
- plugins: string[];
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
- basic: {
38
- plugins: string[];
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
- module.exports = {
12
- 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,
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
- configs: {
21
- recommended: {
22
- plugins: ['class-validator-type-match'],
23
- rules: {
24
- 'class-validator-type-match/decorator-type-match': 'error',
25
- 'class-validator-type-match/optional-decorator-match': 'error',
26
- 'class-validator-type-match/validate-nested-match': 'error',
27
- 'class-validator-type-match/type-decorator-match': 'error',
28
- 'class-validator-type-match/definite-assignment-match': 'error',
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.1.4",
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": "^6.0.0 || ^7.0.0 || ^8.0.0",
33
- "eslint": "^8.0.0 || ^9.0.0"
35
+ "@typescript-eslint/parser": "8.53.0",
36
+ "eslint": "9.39.2"
34
37
  },
35
38
  "dependencies": {
36
- "@typescript-eslint/utils": "^8.0.0"
39
+ "@typescript-eslint/utils": "8.53.0"
37
40
  },
38
41
  "devDependencies": {
39
- "@commitlint/cli": "20.1.0",
40
- "@commitlint/config-conventional": "20.0.0",
41
- "@eslint/js": "9.37.0",
42
- "@typescript-eslint/parser": "8.46.0",
43
- "eslint": "9.37.0",
44
- "globals": "16.4.0",
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.4",
47
- "prettier": "3.6.2",
48
- "typescript": "^5.6.0",
49
- "typescript-eslint": "8.46.0"
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": ">=16.0.0"
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
- ### Manual Configuration
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`