diff --git a/.eslintrc.json b/.eslintrc.json index 1c9dd12c305..24b5b101e17 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -976,6 +976,7 @@ "vscode-dts-interface-naming": "warn", "vscode-dts-cancellation": "warn", "vscode-dts-use-thenable": "warn", + "vscode-dts-region-comments": "warn", "vscode-dts-provider-naming": [ "warn", { diff --git a/build/lib/eslint/vscode-dts-region-comments.js b/build/lib/eslint/vscode-dts-region-comments.js new file mode 100644 index 00000000000..7d37a20fb6a --- /dev/null +++ b/build/lib/eslint/vscode-dts-region-comments.js @@ -0,0 +1,35 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +module.exports = new class ApiEventNaming { + constructor() { + this.meta = { + messages: { + comment: 'region comments should start with the GH issue link, e.g #region https://github.com/microsoft/vscode/issues/', + } + }; + } + create(context) { + const sourceCode = context.getSourceCode(); + return { + ['Program']: (_node) => { + for (let comment of sourceCode.getAllComments()) { + if (comment.type !== 'Line') { + continue; + } + if (!comment.value.match(/^\s*#region /)) { + continue; + } + if (!comment.value.match(/https:\/\/github.com\/microsoft\/vscode\/issues\/\d+/i)) { + context.report({ + node: comment, + messageId: 'comment', + }); + } + } + } + }; + } +}; diff --git a/build/lib/eslint/vscode-dts-region-comments.ts b/build/lib/eslint/vscode-dts-region-comments.ts new file mode 100644 index 00000000000..175fb9040ab --- /dev/null +++ b/build/lib/eslint/vscode-dts-region-comments.ts @@ -0,0 +1,41 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as eslint from 'eslint'; + +export = new class ApiEventNaming implements eslint.Rule.RuleModule { + + readonly meta: eslint.Rule.RuleMetaData = { + messages: { + comment: 'region comments should start with the GH issue link, e.g #region https://github.com/microsoft/vscode/issues/', + } + }; + + create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { + + const sourceCode = context.getSourceCode(); + + + return { + ['Program']: (_node: any) => { + + for (let comment of sourceCode.getAllComments()) { + if (comment.type !== 'Line') { + continue; + } + if (!comment.value.match(/^\s*#region /)) { + continue; + } + if (!comment.value.match(/https:\/\/github.com\/microsoft\/vscode\/issues\/\d+/i)) { + context.report({ + node: comment, + messageId: 'comment', + }); + } + } + } + }; + } +}; diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 228526db133..d92e2abb9e9 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -131,6 +131,7 @@ declare module 'vscode' { //#endregion + // eslint-disable-next-line vscode-dts-region-comments //#region @alexdima - resolvers export interface MessageOptions { @@ -728,6 +729,7 @@ declare module 'vscode' { //#endregion + // eslint-disable-next-line vscode-dts-region-comments //#region debug /** @@ -748,6 +750,7 @@ declare module 'vscode' { //#endregion + // eslint-disable-next-line vscode-dts-region-comments //#region @joaomoreno: SCM validation /** @@ -798,6 +801,7 @@ declare module 'vscode' { //#endregion + // eslint-disable-next-line vscode-dts-region-comments //#region @joaomoreno: SCM selected provider export interface SourceControl { @@ -873,6 +877,7 @@ declare module 'vscode' { //#endregion + // eslint-disable-next-line vscode-dts-region-comments //#region @jrieken -> exclusive document filters export interface DocumentFilter { @@ -984,7 +989,7 @@ declare module 'vscode' { //#endregion - //#region @rebornix: Notebook + //#region notebook https://github.com/microsoft/vscode/issues/106744 export enum CellKind { Markdown = 1,