eslint-plugin-class-validator-type-match 1.6.0 → 2.0.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.
@@ -879,6 +879,7 @@ exports.default = createRule({
879
879
  * - Not initialized (no = value)
880
880
  * - Don't have undefined in their type
881
881
  * Should use the definite assignment assertion (!)
882
+ * Note: Properties with | null still require ! unless they also have ?
882
883
  */
883
884
  const isOptionalProperty = node.optional === true;
884
885
  const hasInitializer = node.value !== undefined;
@@ -322,10 +322,11 @@ exports.default = createRule({
322
322
  }
323
323
  /**
324
324
  * Priority 3: Null in type with @IsOptional() (likely incorrect)
325
- * Note: ? adds undefined, not null
326
- * Only flag if there's null but NO undefined (neither explicit nor from ?)
325
+ * @IsOptional() works with undefined, not null
326
+ * Flag if there's null in the type (with or without ?)
327
+ * However, if it already has undefined explicitly, we won't flag it as user might intentionally want both
327
328
  */
328
- if (hasDecorator && hasNull && !hasUndefined && !isOptionalProperty) {
329
+ if (hasDecorator && hasNull && !hasUndefined) {
329
330
  const propertyTypeWithoutNull = getPropertyTypeWithoutNull(node);
330
331
  issues.push({
331
332
  messageId: 'nullUnionIncorrect',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-class-validator-type-match",
3
- "version": "1.6.0",
3
+ "version": "2.0.0",
4
4
  "description": "ESLint plugin to ensure class-validator decorators match TypeScript type annotations",
5
5
  "keywords": [
6
6
  "eslint",