@@ -216,23 +216,31 @@ function findConfigForHtmlFile(base: string) {
216216 }
217217
218218 while ( base && base . length > 0 ) {
219- let tmpConfigFile = path . resolve ( base + path . sep , ".htmlhintrc" ) ;
220- trace ( `[HTMLHint Debug] Checking config path: ${ tmpConfigFile } ` ) ;
221-
222- // undefined means we haven't tried to load the config file at this path, so try to load it.
223- if ( htmlhintrcOptions [ tmpConfigFile ] === undefined ) {
224- htmlhintrcOptions [ tmpConfigFile ] = loadConfigurationFile ( tmpConfigFile ) ;
225- }
219+ // Check for both .htmlhintrc and .htmlhintrc.json files
220+ const configFiles = [
221+ path . resolve ( base , ".htmlhintrc" ) ,
222+ path . resolve ( base , ".htmlhintrc.json" ) ,
223+ ] ;
224+
225+ for ( const tmpConfigFile of configFiles ) {
226+ trace ( `[HTMLHint Debug] Checking config path: ${ tmpConfigFile } ` ) ;
227+
228+ // undefined means we haven't tried to load the config file at this path, so try to load it.
229+ if ( htmlhintrcOptions [ tmpConfigFile ] === undefined ) {
230+ htmlhintrcOptions [ tmpConfigFile ] =
231+ loadConfigurationFile ( tmpConfigFile ) ;
232+ }
226233
227- // defined, non-null value means we found a config file at the given path, so use it.
228- if ( htmlhintrcOptions [ tmpConfigFile ] ) {
229- options = htmlhintrcOptions [ tmpConfigFile ] ;
230- trace ( `[HTMLHint Debug] Using config from: ${ tmpConfigFile } ` ) ;
231- break ;
234+ // defined, non-null value means we found a config file at the given path, so use it.
235+ if ( htmlhintrcOptions [ tmpConfigFile ] ) {
236+ options = htmlhintrcOptions [ tmpConfigFile ] ;
237+ trace ( `[HTMLHint Debug] Using config from: ${ tmpConfigFile } ` ) ;
238+ return options ;
239+ }
232240 }
233241
234242 // Move to parent directory
235- let parentBase = base . substring ( 0 , base . lastIndexOf ( path . sep ) ) ;
243+ let parentBase = path . dirname ( base ) ;
236244 if ( parentBase === base ) {
237245 // Reached root directory, stop searching
238246 break ;
0 commit comments