@@ -889,6 +889,13 @@ function normalizeWS(text) {
889889
890890}
891891
892+ const rStartsWithValidPropertyName = / ^ (?: [ ^ ' " ] [ ^ \s . ] + | ' (?: [ ^ ' \\ ] | \\ .) * ' | " (?: [ ^ " \\ ] | \\ .) * " ) / ;
893+
894+ function isNestedPropertyName ( name ) {
895+ const match = rStartsWithValidPropertyName . exec ( name ) ;
896+ return match && match [ 0 ] . length < name . length && name [ match [ 0 ] . length ] === "." ;
897+ }
898+
892899//---- add on: API JSON -----------------------------------------------------------------
893900
894901function createAPIJSON ( symbols , filename ) {
@@ -1411,7 +1418,7 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
14111418 continue ;
14121419 }
14131420
1414- if ( name . indexOf ( '.' ) >= 0 ) {
1421+ if ( isNestedPropertyName ( name ) ) {
14151422 continue ;
14161423 }
14171424
@@ -2276,6 +2283,19 @@ function validateAPIJSON(api) {
22762283 }
22772284 }
22782285
2286+ /**
2287+ * Checks the name of a property in an object-like structure.
2288+ * As in JavaScript, the rules for such names are less strict than
2289+ * for classes, interfaces or function declarations.
2290+ */
2291+ function checkPropertyName ( name , hint ) {
2292+ const match = rStartsWithValidPropertyName . exec ( name ) ;
2293+ if ( match == null || match [ 0 ] . length !== name . length ) {
2294+ naming [ name ] ??= [ ] ;
2295+ naming [ name ] . push ( hint ) ;
2296+ }
2297+ }
2298+
22792299 function checkModuleName ( name , hint ) {
22802300 if ( ! rValidModuleNames . test ( name ) ) {
22812301 naming [ name ] = naming [ name ] || [ ] ;
@@ -2386,7 +2406,12 @@ function validateAPIJSON(api) {
23862406 }
23872407
23882408 function checkParam ( param , prefix , hint ) {
2389- checkName ( param . name , `name of param ${ prefix } ${ param . name } of ${ hint } ` ) ;
2409+ if ( prefix ) {
2410+ // nested parameter properties follow the naming conventions for object properties
2411+ checkPropertyName ( param . name , `name of param ${ prefix } ${ param . name } of ${ hint } ` ) ;
2412+ } else {
2413+ checkName ( param . name , `name of param ${ prefix } ${ param . name } of ${ hint } ` ) ;
2414+ }
23902415 checkType ( param , `param ${ prefix } ${ param . name } of ${ hint } ` ) ;
23912416 if ( param . parameterProperties ) {
23922417 Object . keys ( param . parameterProperties ) . forEach ( ( sub ) =>
@@ -2508,7 +2533,7 @@ function validateAPIJSON(api) {
25082533 if ( symbol . properties ) {
25092534 symbol . properties . forEach ( ( prop ) => {
25102535 const qualifiedName = `${ symbol . name } .${ prop . name } ` ;
2511- checkName ( prop . name , `name of ${ qualifiedName } ` ) ;
2536+ checkPropertyName ( prop . name , `name of ${ qualifiedName } ` ) ;
25122537 if ( prop . type ) {
25132538 checkType ( prop , `type of ${ qualifiedName } ` ) ;
25142539 }
0 commit comments