diff --git a/extensions/extension-editing/package.json b/extensions/extension-editing/package.json index b14485fa785a0c..78620f1b38dfa9 100644 --- a/extensions/extension-editing/package.json +++ b/extensions/extension-editing/package.json @@ -28,7 +28,7 @@ "dependencies": { "jsonc-parser": "^3.2.0", "markdown-it": "^13.0.1", - "parse5": "^7.1.1", + "parse5-sax-parser": "^7.0.0", "vscode-nls": "^5.2.0" }, "contributes": { diff --git a/extensions/extension-editing/src/extensionLinter.ts b/extensions/extension-editing/src/extensionLinter.ts index f0288d05739c83..71048b0dddd43b 100644 --- a/extensions/extension-editing/src/extensionLinter.ts +++ b/extensions/extension-editing/src/extensionLinter.ts @@ -62,7 +62,7 @@ export class ExtensionLinter { private readmeQ = new Set(); private timer: NodeJS.Timer | undefined; private markdownIt: MarkdownItType | undefined; - private parse5: typeof import('parse5') | undefined; + private parse5: typeof import('parse5-sax-parser') | undefined; constructor() { this.disposables.push( @@ -225,10 +225,11 @@ export class ExtensionLinter { for (const tnp of tokensAndPositions) { if (tnp.token.type === 'text' && tnp.token.content) { if (!this.parse5) { - this.parse5 = await import('parse5'); + this.parse5 = await import('parse5-sax-parser'); } - const parser = new this.parse5.SAXParser({ locationInfo: true }); - parser.on('startTag', (name, attrs, _selfClosing, location) => { + const parser = new this.parse5.SAXParser({ sourceCodeLocationInfo: true }); + parser.on('startTag', (startTag) => { + const { tagName: name, attrs, sourceCodeLocation: location } = startTag; if (name === 'img') { const src = attrs.find(a => a.name === 'src'); if (src && src.value && location) { @@ -245,7 +246,8 @@ export class ExtensionLinter { diagnostics.push(svgStart); } }); - parser.on('endTag', (name, location) => { + parser.on('endTag', (endTag) => { + const { tagName: name, sourceCodeLocation: location } = endTag; if (name === 'svg' && svgStart && location) { const end = tnp.begin + location.endOffset; svgStart.range = new Range(svgStart.range.start, document.positionAt(end)); diff --git a/extensions/extension-editing/yarn.lock b/extensions/extension-editing/yarn.lock index 99131e01f50ecd..5ff01a3b0329cf 100644 --- a/extensions/extension-editing/yarn.lock +++ b/extensions/extension-editing/yarn.lock @@ -68,7 +68,14 @@ mdurl@^1.0.1: resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4= -parse5@^7.1.1: +parse5-sax-parser@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/parse5-sax-parser/-/parse5-sax-parser-7.0.0.tgz#4c05064254f0488676aca75fb39ca069ec96dee5" + integrity sha512-5A+v2SNsq8T6/mG3ahcz8ZtQ0OUFTatxPbeidoMB7tkJSGDY3tdfl4MHovtLQHkEn5CGxijNWRQHhRQ6IRpXKg== + dependencies: + parse5 "^7.0.0" + +parse5@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.1.1.tgz#4649f940ccfb95d8754f37f73078ea20afe0c746" integrity sha512-kwpuwzB+px5WUg9pyK0IcK/shltJN5/OVhQagxhCQNtT9Y9QRZqNY2e1cmbu/paRh5LMnz/oVTVLBpjFmMZhSg==