Merge b58b850066
into 7dfcd74e63
This commit is contained in:
commit
d965b1781e
|
@ -26,6 +26,7 @@
|
|||
"watch": "gulp watch-extension:extension-editing"
|
||||
},
|
||||
"dependencies": {
|
||||
"hosted-git-info": "^4.0.2",
|
||||
"jsonc-parser": "^2.2.1",
|
||||
"markdown-it": "^12.0.4",
|
||||
"parse5": "^3.0.2",
|
||||
|
@ -67,6 +68,7 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/hosted-git-info": "^3.0.2",
|
||||
"@types/markdown-it": "0.0.2",
|
||||
"@types/node": "14.x"
|
||||
},
|
||||
|
|
|
@ -10,6 +10,7 @@ import * as nls from 'vscode-nls';
|
|||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { parseTree, findNodeAtLocation, Node as JsonNode } from 'jsonc-parser';
|
||||
import GitHost = require('hosted-git-info');
|
||||
import * as MarkdownItType from 'markdown-it';
|
||||
|
||||
import { languages, workspace, Disposable, TextDocument, Uri, Diagnostic, Range, DiagnosticSeverity, Position, env } from 'vscode';
|
||||
|
@ -44,8 +45,7 @@ interface TokenAndPosition {
|
|||
|
||||
interface PackageJsonInfo {
|
||||
isExtension: boolean;
|
||||
hasHttpsRepository: boolean;
|
||||
repository: Uri;
|
||||
repository: string | undefined;
|
||||
}
|
||||
|
||||
export class ExtensionLinter {
|
||||
|
@ -259,16 +259,24 @@ export class ExtensionLinter {
|
|||
|
||||
private readPackageJsonInfo(folder: Uri, tree: JsonNode | undefined) {
|
||||
const engine = tree && findNodeAtLocation(tree, ['engines', 'vscode']);
|
||||
const repo = tree && findNodeAtLocation(tree, ['repository', 'url']);
|
||||
const uri = repo && parseUri(repo.value);
|
||||
const repo = tree && findNodeAtLocation(tree, ['repository']);
|
||||
let repoUrl: string | undefined;
|
||||
if (repo && repo.type === 'string') {
|
||||
repoUrl = repo.value;
|
||||
} else if (repo) {
|
||||
const urlNode = findNodeAtLocation(repo, ['url']);
|
||||
if (urlNode && urlNode.type === 'string') {
|
||||
repoUrl = urlNode.value;
|
||||
}
|
||||
}
|
||||
const gitHost = repoUrl && GitHost.fromUrl(repoUrl, { noGitPlus: true });
|
||||
const info: PackageJsonInfo = {
|
||||
isExtension: !!(engine && engine.type === 'string'),
|
||||
hasHttpsRepository: !!(repo && repo.type === 'string' && repo.value && uri && uri.scheme.toLowerCase() === 'https'),
|
||||
repository: uri!
|
||||
repository: gitHost && gitHost.https() || repoUrl
|
||||
};
|
||||
const str = folder.toString();
|
||||
const oldInfo = this.folderToPackageJsonInfo[str];
|
||||
if (oldInfo && (oldInfo.isExtension !== info.isExtension || oldInfo.hasHttpsRepository !== info.hasHttpsRepository)) {
|
||||
if (oldInfo && (oldInfo.isExtension !== info.isExtension || oldInfo.repository !== info.repository)) {
|
||||
this.packageJsonChanged(folder); // clears this.folderToPackageJsonInfo[str]
|
||||
}
|
||||
this.folderToPackageJsonInfo[str] = info;
|
||||
|
@ -301,7 +309,7 @@ export class ExtensionLinter {
|
|||
|
||||
private addDiagnostics(diagnostics: Diagnostic[], document: TextDocument, begin: number, end: number, src: string, context: Context, info: PackageJsonInfo) {
|
||||
const hasScheme = /^\w[\w\d+.-]*:/.test(src);
|
||||
const uri = parseUri(src, info.repository ? info.repository.toString() : document.uri.toString());
|
||||
const uri = parseUri(src, info.repository || document.uri.toString());
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
@ -317,7 +325,7 @@ export class ExtensionLinter {
|
|||
diagnostics.push(new Diagnostic(range, dataUrlsNotValid, DiagnosticSeverity.Warning));
|
||||
}
|
||||
|
||||
if (!hasScheme && !info.hasHttpsRepository) {
|
||||
if (!hasScheme && !info.repository?.startsWith('https')) {
|
||||
const range = new Range(document.positionAt(begin), document.positionAt(end));
|
||||
let message = (() => {
|
||||
switch (context) {
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/hosted-git-info@^3.0.2":
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/hosted-git-info/-/hosted-git-info-3.0.2.tgz#aa671076f5edefa4fab1189b467e6c63987be818"
|
||||
integrity sha512-RURNTeEFUwF+ifnp7kK3WLLlTmBSlRynLNS9jeAsI6RHtSrupV0l0nO6kmpaz75EUJVexy348bR452SvmH98vQ==
|
||||
|
||||
"@types/markdown-it@0.0.2":
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
|
||||
|
@ -27,6 +32,13 @@ entities@~2.1.0:
|
|||
resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5"
|
||||
integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==
|
||||
|
||||
hosted-git-info@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.2.tgz#5e425507eede4fea846b7262f0838456c4209961"
|
||||
integrity sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
jsonc-parser@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.2.1.tgz#db73cd59d78cce28723199466b2a03d1be1df2bc"
|
||||
|
@ -39,6 +51,13 @@ linkify-it@^3.0.1:
|
|||
dependencies:
|
||||
uc.micro "^1.0.1"
|
||||
|
||||
lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
|
||||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
markdown-it@^12.0.4:
|
||||
version "12.0.4"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.0.4.tgz#eec8247d296327eac3ba9746bdeec9cfcc751e33"
|
||||
|
@ -76,3 +95,8 @@ vscode-nls@^5.0.0:
|
|||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
|
||||
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
|
||||
|
||||
yallist@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
|
||||
|
|
Loading…
Reference in a new issue