Skip to content

Commit fce04e8

Browse files
committed
Closes #1317: Add filepath to the start event
1 parent 01a3194 commit fce04e8

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/cli/htmlhint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ function hintFile(filepath: string, ruleset?: Ruleset) {
505505
// ignore
506506
}
507507

508-
return HTMLHint.verify(content, ruleset)
508+
return HTMLHint.verify(content, ruleset, filepath)
509509
}
510510

511511
// hint stdin

src/core/core.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class HTMLHintCore {
2727
this.rules[rule.id] = rule
2828
}
2929

30-
public verify(html: string, ruleset: Ruleset = this.defaultRuleset) {
30+
public verify(
31+
html: string,
32+
ruleset: Ruleset = this.defaultRuleset,
33+
filepath: string = ''
34+
) {
3135
if (Object.keys(ruleset).length === 0) {
3236
ruleset = this.defaultRuleset
3337
}
@@ -74,7 +78,7 @@ class HTMLHintCore {
7478
}
7579
}
7680

77-
parser.parse(html)
81+
parser.parse(html, filepath)
7882

7983
return reporter.messages
8084
}

src/core/htmlparser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface Block {
1818
long: boolean
1919
close: string
2020
lastEvent?: Partial<Block>
21+
filepath?: string
2122
}
2223

2324
export type Listener = (event: Block) => void
@@ -49,7 +50,7 @@ export default class HTMLParser {
4950
return obj
5051
}
5152

52-
public parse(html: string): void {
53+
public parse(html: string, filepath: string): void {
5354
const mapCdataTags = this._mapCdataTags
5455

5556
const regTag =
@@ -78,6 +79,7 @@ export default class HTMLParser {
7879
pos: 0,
7980
line: 1,
8081
col: 1,
82+
filepath: filepath,
8183
})
8284

8385
// Do not ignore validation inside <script type="ng/template"> template

0 commit comments

Comments
 (0)