@@ -15,7 +15,7 @@ export class HarAnalyzer {
1515 this . config = JSON . parse ( readFileSync ( configPath , 'utf8' ) ) ;
1616 }
1717
18- transform2SimplifiedData ( harData , url , group ) {
18+ transform2SimplifiedData ( harData , url ) {
1919 const data = {
2020 'url' : url ,
2121 'rules' : this . config . rules ,
@@ -61,7 +61,7 @@ export class HarAnalyzer {
6161 for ( const htmlObj of data . htmls ) {
6262 const dom = new JSDOM ( htmlObj . content ) ;
6363 const styleElements = dom . window . document . querySelectorAll ( 'style' ) ;
64- styleElements . forEach ( ( styleElement , index ) => {
64+ styleElements . forEach ( ( styleElement ) => {
6565 const styleElementObj = {
6666 'url' : htmlObj . url ,
6767 'content' : styleElement . textContent ,
@@ -73,7 +73,7 @@ export class HarAnalyzer {
7373
7474 // Extract style="" attributes from HTML content
7575 const elementsWithStyleAttr = dom . window . document . querySelectorAll ( '[style]' ) ;
76- elementsWithStyleAttr . forEach ( ( element , index ) => {
76+ elementsWithStyleAttr . forEach ( ( element ) => {
7777 const styleAttrContent = element . getAttribute ( 'style' ) ;
7878 const styleAttrObj = {
7979 'url' : htmlObj . url ,
@@ -105,38 +105,35 @@ export class HarAnalyzer {
105105 return knowledgeData ;
106106 }
107107
108- try {
109- // Ensure the correct context for `this` using arrow function
110- const lintPromises = analyzedData [ 'all-styles' ] . map ( entry => {
111- return stylelint . lint ( {
112- code : entry . content ,
113- config : this . config
114- } ) . then ( result => {
115- // Attach warnings along with the entry.url
116- return result . results . flatMap ( res =>
117- res . warnings . map ( warning => ( {
118- url : entry . url ,
119- rule : warning . rule ,
120- category : 'standard' ,
121- severity : warning . severity ,
122- text : warning . text ,
123- line : warning . line ,
124- column : warning . column
125- } ) )
126- ) ;
127- } ) ;
108+ // Ensure the correct context for `this` using arrow function
109+ const lintPromises = analyzedData [ 'all-styles' ] . map ( entry => {
110+ return stylelint . lint ( {
111+ code : entry . content ,
112+ config : this . config
113+ } ) . then ( result => {
114+ // Attach warnings along with the entry.url
115+ return result . results . flatMap ( res =>
116+ res . warnings . map ( warning => ( {
117+ url : entry . url ,
118+ rule : warning . rule ,
119+ category : 'standard' ,
120+ severity : warning . severity ,
121+ text : warning . text ,
122+ line : warning . line ,
123+ column : warning . column
124+ } ) )
125+ ) ;
128126 } ) ;
127+ } ) ;
129128
130- // Wait for all linting promises to resolve and flatten the results
131- const lintResults = await Promise . all ( lintPromises ) ;
132- knowledgeData . issues = lintResults . flat ( ) ;
129+ // Wait for all linting promises to resolve and flatten the results
130+ const lintResults = await Promise . all ( lintPromises ) ;
131+ knowledgeData . issues = lintResults . flat ( ) ;
133132
134- // Populate "resolved-rules" with rules not mentioned in "issues"
135- const allRules = Object . keys ( this . config . rules ) ;
136- const mentionedRules = new Set ( knowledgeData . issues . map ( issue => issue . rule ) ) ;
137- knowledgeData [ 'resolved-rules' ] = allRules . filter ( rule => ! mentionedRules . has ( rule ) ) ;
138- } catch ( err ) {
139- }
133+ // Populate "resolved-rules" with rules not mentioned in "issues"
134+ const allRules = Object . keys ( this . config . rules ) ;
135+ const mentionedRules = new Set ( knowledgeData . issues . map ( issue => issue . rule ) ) ;
136+ knowledgeData [ 'resolved-rules' ] = allRules . filter ( rule => ! mentionedRules . has ( rule ) ) ;
140137
141138 return knowledgeData ;
142139 }
@@ -146,7 +143,7 @@ export class HarAnalyzer {
146143 this . groups [ group ] = { } ;
147144 }
148145
149- const analyzedData = this . transform2SimplifiedData ( harData , url , group ) ;
146+ const analyzedData = this . transform2SimplifiedData ( harData , url ) ;
150147 if ( ! ( 'analyzedData' in this . groups [ group ] ) ) {
151148 this . groups [ group ] [ 'analyzedData' ] = [ ]
152149 }
0 commit comments