@@ -22,47 +22,36 @@ export const NoRequiredSchemaPropertiesUndefined:
2222 leave ( _ : AnySchema ) {
2323 parents . pop ( ) ;
2424 } ,
25- enter ( schema : AnySchema , ctx : UserContext ) {
26- parents . push ( schema ) ;
27- if ( ! schema . required ) return ;
25+ enter ( currentSchema : AnySchema , ctx : UserContext ) {
26+ parents . push ( currentSchema ) ;
27+ if ( ! currentSchema . required ) return ;
2828
2929 const hasProperty = (
3030 schemaOrRef : AnySchema | undefined ,
3131 propertyName : string ,
3232 visited : Set < AnySchema > ,
3333 resolveFrom ?: string
3434 ) : boolean => {
35- const resolved = resolveSchema ( schemaOrRef , ctx , resolveFrom ) ;
36- if ( ! resolved . schema || visited . has ( resolved . schema ) ) return false ;
37- visited . add ( resolved . schema ) ;
35+ const { schema , location } = resolveSchema ( schemaOrRef , ctx , resolveFrom ) ;
36+ if ( ! schema || visited . has ( schema ) ) return false ;
37+ visited . add ( schema ) ;
3838
39- if (
40- resolved . schema . properties &&
41- getOwn ( resolved . schema . properties , propertyName ) !== undefined
42- ) {
39+ if ( schema . properties && getOwn ( schema . properties , propertyName ) !== undefined ) {
4340 return true ;
4441 }
4542
46- if (
47- resolved . schema . allOf ?. some ( ( s ) =>
48- hasProperty ( s , propertyName , visited , resolved . location )
49- )
50- ) {
43+ if ( schema . allOf ?. some ( ( s ) => hasProperty ( s , propertyName , visited , location ) ) ) {
5144 return true ;
5245 }
5346
5447 if (
55- resolved . schema . anyOf ?. every ( ( s ) =>
56- hasProperty ( s , propertyName , new Set ( visited ) , resolved . location )
57- )
48+ schema . anyOf ?. every ( ( s ) => hasProperty ( s , propertyName , new Set ( visited ) , location ) )
5849 ) {
5950 return true ;
6051 }
6152
6253 if (
63- resolved . schema . oneOf ?. every ( ( s ) =>
64- hasProperty ( s , propertyName , new Set ( visited ) , resolved . location )
65- )
54+ schema . oneOf ?. every ( ( s ) => hasProperty ( s , propertyName , new Set ( visited ) , location ) )
6655 ) {
6756 return true ;
6857 }
@@ -87,11 +76,11 @@ export const NoRequiredSchemaPropertiesUndefined:
8776 : undefined ;
8877 } ;
8978
90- const compositionRoot = findCompositionRoot ( parents . length - 2 , schema ) ;
79+ const compositionRoot = findCompositionRoot ( parents . length - 2 , currentSchema ) ;
9180
92- for ( const [ i , requiredProperty ] of schema . required . entries ( ) ) {
81+ for ( const [ i , requiredProperty ] of currentSchema . required . entries ( ) ) {
9382 if (
94- ! hasProperty ( schema , requiredProperty , new Set ( ) ) &&
83+ ! hasProperty ( currentSchema , requiredProperty , new Set ( ) ) &&
9584 ! hasProperty ( compositionRoot , requiredProperty , new Set ( ) )
9685 ) {
9786 ctx . report ( {
0 commit comments