You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eslint - field should not have the same name as the enclosing class (#5843)
* base structure
* impl
* correct rule ignore
* include codegen_name comment in logic
* restore comment on weight
* better check for comment
(cherry picked from commit 6463ee1)
|`single-key-dictionary-key-is-string`|`SingleKeyDictionary` keys must be strings. |
11
-
|`dictionary-key-is-string`|`Dictionary` keys must be strings. |
12
-
|`no-native-types`| TypeScript native utility types (`Record`, `Partial`, etc.) and collection types (`Map`, `Set`, etc.) are not allowed. Use spec-defined aliases like `Dictionary` instead. |
13
-
|`invalid-node-types`| The spec uses a subset of TypeScript, so some types, clauses and expressions are not allowed. |
14
-
|`no-generic-number`| Generic `number` type is not allowed outside of `_types/Numeric.ts`. Use concrete numeric types like `integer`, `long`, `float`, `double`, etc. |
15
-
|`request-must-have-urls`| All Request interfaces extending `RequestBase` must have a `urls` property defining their endpoint paths and HTTP methods. |
16
-
|`no-variants-on-responses`|`@variants` is only supported on Interface types, not on Request or Response classes. Use value_body pattern with `@codegen_name` instead. Includes additional checks on variant tag use. |
17
-
|`no-inline-unions`| Inline union types (e.g., `field: A \| B`) are not allowed in properties/fields. Define a named type alias instead to improve code generation for statically-typed languages. |
18
-
|`prefer-tagged-variants`| Union of class types should use tagged variants (`@variants internal` or `@variants container`) instead of inline unions for better deserialization support in statically-typed languages. |
19
-
|`no-duplicate-type-names`| All types must be unique across class and enum definitions. |
20
-
| `no-all-string-literal-unions | Unions consisting entirely of string literals (e.g., `"green" \| "yellow" \| "red"`) are not allowed, use enums instead. |
|`single-key-dictionary-key-is-string`|`SingleKeyDictionary` keys must be strings. |
11
+
|`dictionary-key-is-string`|`Dictionary` keys must be strings. |
12
+
|`no-native-types`| TypeScript native utility types (`Record`, `Partial`, etc.) and collection types (`Map`, `Set`, etc.) are not allowed. Use spec-defined aliases like `Dictionary` instead. |
13
+
|`no-same-name-as-enclosing-type`| Classes having fields with the same name as the class is breaking for some client libraries. |
14
+
|`invalid-node-types`| The spec uses a subset of TypeScript, so some types, clauses and expressions are not allowed. |
15
+
|`no-generic-number`| Generic `number` type is not allowed outside of `_types/Numeric.ts`. Use concrete numeric types like `integer`, `long`, `float`, `double`, etc. |
16
+
|`request-must-have-urls`| All Request interfaces extending `RequestBase` must have a `urls` property defining their endpoint paths and HTTP methods. |
17
+
|`no-variants-on-responses`|`@variants` is only supported on Interface types, not on Request or Response classes. Use value_body pattern with `@codegen_name` instead. Includes additional checks on variant tag use. |
18
+
|`no-inline-unions`| Inline union types (e.g., `field: A \| B`) are not allowed in properties/fields. Define a named type alias instead to improve code generation for statically-typed languages. |
19
+
|`prefer-tagged-variants`| Union of class types should use tagged variants (`@variants internal` or `@variants container`) instead of inline unions for better deserialization support in statically-typed languages. |
20
+
|`no-duplicate-type-names`| All types must be unique across class and enum definitions. |
21
+
| `no-all-string-literal-unions | Unions consisting entirely of string literals (e.g., `"green" \| "yellow" \| "red"`) are not allowed, use enums instead. |
21
22
|`jsdoc-endpoint-check`| Validates JSDoc on endpoints in the specification. Ensuring consistent formatting. Some errors can be fixed with `--fix`. |
22
-
|`codegen-exclude-on-request-only`| Ensures `@codegen_exclude` is only used on request definitions located in namespaced `specification/` files (i.e. files. |
23
+
|`codegen-exclude-on-request-only`| Ensures `@codegen_exclude` is only used on request definitions located in namespaced `specification/` files (i.e. files. |
suggestion: 'Either change the class name, or if it\'s not possible, use a different codegen name for the field by commenting it with /** @codegen_name different_name **/.'
69
+
}
70
+
})
71
+
}
72
+
}
73
+
}
74
+
}
75
+
}
76
+
,
77
+
}
78
+
},
79
+
meta:
80
+
{
81
+
docs: {
82
+
description: 'Classes having fields with the same name as the class is breaking for some client libraries.'
83
+
}
84
+
,
85
+
messages: {
86
+
shouldNotUseClassNameForFieldNames: 'Class "{{class}}" has invalid fields. {{suggestion}}.'
0 commit comments