@@ -10,7 +10,7 @@ export class Warnings {
1010 this . package = pkg ;
1111 }
1212
13- get isLocalProject ( ) {
13+ get isPrincipalRootProject ( ) {
1414 return this . package . currentNode === 0 ||
1515 this . package . dependencyVersion . flags . includes ( "isGit" ) ;
1616 }
@@ -55,9 +55,6 @@ export class Warnings {
5555 if ( window . settings . warnings . has ( warning . kind ) ) {
5656 continue ;
5757 }
58- const multipleLocation = warning . kind === "encoded-literal" ?
59- warning . location . map ( ( loc ) => locationToString ( loc ) ) . join ( " // " ) :
60- locationToString ( warning . location ) ;
6158
6259 const id = Math . random ( ) . toString ( 36 ) . slice ( 2 ) ;
6360 const hasNoInspection =
@@ -72,7 +69,7 @@ export class Warnings {
7269 ]
7370 } ) ;
7471
75- if ( this . isLocalProject || hasNoInspection ) {
72+ if ( this . isPrincipalRootProject || hasNoInspection ) {
7673 viewMoreElement . style . display = "none" ;
7774 }
7875 else {
@@ -102,18 +99,21 @@ export class Warnings {
10299 viewMoreElement
103100 ]
104101 } ) ;
105- const boxPosition = utils . createDOMElement ( "div" , {
102+ const boxPosition = warning . location === null ? null : utils . createDOMElement ( "div" , {
106103 className : "box-source-code-position" ,
107104 childs : [
108- utils . createDOMElement ( "p" , { text : multipleLocation } )
105+ utils . createDOMElement ( "p" , {
106+ text : this . getWarningLocation ( warning )
107+ } )
109108 ]
110109 } ) ;
111110
112111 const box = utils . createFileBox ( {
113112 title : warning . kind ,
114113 fileName : warning . file . length > 20 ? `${ warning . file . slice ( 0 , 20 ) } ...` : warning . file ,
115114 childs : [ boxContainer , boxPosition ] ,
116- titleHref : `https://github.com/NodeSecure/js-x-ray/blob/master/docs/${ warning . kind } .md` ,
115+ titleHref : warning . kind === "invalid-semver" ?
116+ null : `https://github.com/NodeSecure/js-x-ray/blob/master/docs/${ warning . kind } .md` ,
117117 fileHref : `${ unpkgRoot } ${ warning . file } ` ,
118118 severity : warning . severity ?? "Information"
119119 } )
@@ -122,4 +122,13 @@ export class Warnings {
122122
123123 return fragment ;
124124 }
125+
126+ getWarningLocation ( warning ) {
127+ if ( warning . kind === "encoded-literal" ) {
128+ return warning . location
129+ . map ( ( loc ) => locationToString ( loc ) ) . join ( " // " ) ;
130+ }
131+
132+ return locationToString ( warning . location ) ; ;
133+ }
125134}
0 commit comments