add new rule to enforce Thenable over Promise, adopt in vscode.d.ts and vscode.proposed.d.ts
This commit is contained in:
parent
dfc8f5ab91
commit
845a4d4268
5 changed files with 132 additions and 24 deletions
|
@ -5,7 +5,10 @@
|
|||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@typescript-eslint", "jsdoc"],
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"jsdoc"
|
||||
],
|
||||
"rules": {
|
||||
"constructor-super": "warn",
|
||||
"curly": "warn",
|
||||
|
@ -43,7 +46,9 @@
|
|||
"warn",
|
||||
{
|
||||
"selector": "class",
|
||||
"format": ["PascalCase"]
|
||||
"format": [
|
||||
"PascalCase"
|
||||
]
|
||||
}
|
||||
],
|
||||
"code-no-unused-expressions": [
|
||||
|
@ -60,11 +65,26 @@
|
|||
"warn",
|
||||
{
|
||||
"common": [],
|
||||
"node": ["common"],
|
||||
"browser": ["common"],
|
||||
"electron-sandbox": ["common", "browser"],
|
||||
"electron-browser": ["common", "browser", "node", "electron-sandbox"],
|
||||
"electron-main": ["common", "node"]
|
||||
"node": [
|
||||
"common"
|
||||
],
|
||||
"browser": [
|
||||
"common"
|
||||
],
|
||||
"electron-sandbox": [
|
||||
"common",
|
||||
"browser"
|
||||
],
|
||||
"electron-browser": [
|
||||
"common",
|
||||
"browser",
|
||||
"node",
|
||||
"electron-sandbox"
|
||||
],
|
||||
"electron-main": [
|
||||
"common",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
],
|
||||
"code-import-patterns": [
|
||||
|
@ -74,7 +94,10 @@
|
|||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
{
|
||||
"target": "**/vs/base/common/**",
|
||||
"restrictions": ["vs/nls", "**/vs/base/common/**"]
|
||||
"restrictions": [
|
||||
"vs/nls",
|
||||
"**/vs/base/common/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "**/vs/base/test/common/**",
|
||||
|
@ -432,7 +455,11 @@
|
|||
},
|
||||
{
|
||||
"target": "**/vs/workbench/api/worker/**",
|
||||
"restrictions": ["vscode", "vs/nls", "**/vs/**/{common,worker}/**"]
|
||||
"restrictions": [
|
||||
"vscode",
|
||||
"vs/nls",
|
||||
"**/vs/**/{common,worker}/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "**/vs/workbench/electron-sandbox/**",
|
||||
|
@ -878,7 +905,13 @@
|
|||
},
|
||||
{
|
||||
"target": "**/api/**.test.ts",
|
||||
"restrictions": ["**/vs/**", "assert", "sinon", "crypto", "vscode"]
|
||||
"restrictions": [
|
||||
"**/vs/**",
|
||||
"assert",
|
||||
"sinon",
|
||||
"crypto",
|
||||
"vscode"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "**/{node,electron-browser,electron-main}/**/*.test.ts",
|
||||
|
@ -903,28 +936,46 @@
|
|||
},
|
||||
{
|
||||
"target": "**/**.test.ts",
|
||||
"restrictions": ["**/vs/**", "assert", "sinon", "crypto", "xterm*"]
|
||||
"restrictions": [
|
||||
"**/vs/**",
|
||||
"assert",
|
||||
"sinon",
|
||||
"crypto",
|
||||
"xterm*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"target": "**/test/**",
|
||||
"restrictions": ["**/vs/**", "assert", "sinon", "crypto", "xterm*"]
|
||||
"restrictions": [
|
||||
"**/vs/**",
|
||||
"assert",
|
||||
"sinon",
|
||||
"crypto",
|
||||
"xterm*"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.js"],
|
||||
"files": [
|
||||
"*.js"
|
||||
],
|
||||
"rules": {
|
||||
"jsdoc/no-types": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["**/vscode.d.ts", "**/vscode.proposed.d.ts"],
|
||||
"files": [
|
||||
"**/vscode.d.ts",
|
||||
"**/vscode.proposed.d.ts"
|
||||
],
|
||||
"rules": {
|
||||
"vscode-dts-create-func": "warn",
|
||||
"vscode-dts-literal-or-types": "warn",
|
||||
"vscode-dts-interface-naming": "warn",
|
||||
"vscode-dts-cancellation": "warn",
|
||||
"vscode-dts-use-thenable": "warn",
|
||||
"vscode-dts-provider-naming": [
|
||||
"warn",
|
||||
{
|
||||
|
@ -940,7 +991,10 @@
|
|||
"vscode-dts-event-naming": [
|
||||
"warn",
|
||||
{
|
||||
"allowed": ["onCancellationRequested", "event"],
|
||||
"allowed": [
|
||||
"onCancellationRequested",
|
||||
"event"
|
||||
],
|
||||
"verbs": [
|
||||
"accept",
|
||||
"change",
|
||||
|
|
24
build/lib/eslint/vscode-dts-use-thenable.js
Normal file
24
build/lib/eslint/vscode-dts-use-thenable.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
"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: {
|
||||
usage: 'Use the Thenable-type instead of the Promise type',
|
||||
}
|
||||
};
|
||||
}
|
||||
create(context) {
|
||||
return {
|
||||
['TSTypeAnnotation TSTypeReference Identifier[name="Promise"]']: (node) => {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'usage',
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
30
build/lib/eslint/vscode-dts-use-thenable.ts
Normal file
30
build/lib/eslint/vscode-dts-use-thenable.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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: {
|
||||
usage: 'Use the Thenable-type instead of the Promise type',
|
||||
}
|
||||
};
|
||||
|
||||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
|
||||
|
||||
|
||||
return {
|
||||
['TSTypeAnnotation TSTypeReference Identifier[name="Promise"]']: (node: any) => {
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'usage',
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
2
src/vs/vscode.d.ts
vendored
2
src/vs/vscode.d.ts
vendored
|
@ -12161,7 +12161,7 @@ declare module 'vscode' {
|
|||
/**
|
||||
* Optional reaction handler for creating and deleting reactions on a [comment](#Comment).
|
||||
*/
|
||||
reactionHandler?: (comment: Comment, reaction: CommentReaction) => Promise<void>;
|
||||
reactionHandler?: (comment: Comment, reaction: CommentReaction) => Thenable<void>;
|
||||
|
||||
/**
|
||||
* Dispose this comment controller.
|
||||
|
|
16
src/vs/vscode.proposed.d.ts
vendored
16
src/vs/vscode.proposed.d.ts
vendored
|
@ -1577,16 +1577,16 @@ declare module 'vscode' {
|
|||
* resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
|
||||
*/
|
||||
// eslint-disable-next-line vscode-dts-provider-naming
|
||||
openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext): NotebookData | Promise<NotebookData>;
|
||||
openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext): NotebookData | Thenable<NotebookData>;
|
||||
// eslint-disable-next-line vscode-dts-provider-naming
|
||||
// eslint-disable-next-line vscode-dts-cancellation
|
||||
resolveNotebook(document: NotebookDocument, webview: NotebookCommunication): Promise<void>;
|
||||
resolveNotebook(document: NotebookDocument, webview: NotebookCommunication): Thenable<void>;
|
||||
// eslint-disable-next-line vscode-dts-provider-naming
|
||||
saveNotebook(document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
|
||||
saveNotebook(document: NotebookDocument, cancellation: CancellationToken): Thenable<void>;
|
||||
// eslint-disable-next-line vscode-dts-provider-naming
|
||||
saveNotebookAs(targetResource: Uri, document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
|
||||
saveNotebookAs(targetResource: Uri, document: NotebookDocument, cancellation: CancellationToken): Thenable<void>;
|
||||
// eslint-disable-next-line vscode-dts-provider-naming
|
||||
backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, cancellation: CancellationToken): Promise<NotebookDocumentBackup>;
|
||||
backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, cancellation: CancellationToken): Thenable<NotebookDocumentBackup>;
|
||||
}
|
||||
|
||||
export interface NotebookKernel {
|
||||
|
@ -1685,7 +1685,7 @@ declare module 'vscode' {
|
|||
): Disposable;
|
||||
|
||||
export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
|
||||
export function openNotebookDocument(uri: Uri, viewType?: string): Promise<NotebookDocument>;
|
||||
export function openNotebookDocument(uri: Uri, viewType?: string): Thenable<NotebookDocument>;
|
||||
export const onDidOpenNotebookDocument: Event<NotebookDocument>;
|
||||
export const onDidCloseNotebookDocument: Event<NotebookDocument>;
|
||||
export const onDidSaveNotebookDocument: Event<NotebookDocument>;
|
||||
|
@ -1729,7 +1729,7 @@ declare module 'vscode' {
|
|||
export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
|
||||
export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
|
||||
export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
|
||||
export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Promise<NotebookEditor>;
|
||||
export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
@ -1940,7 +1940,7 @@ declare module 'vscode' {
|
|||
}
|
||||
|
||||
export namespace languages {
|
||||
export function getTokenInformationAtPosition(document: TextDocument, position: Position): Promise<TokenInformation>;
|
||||
export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
Loading…
Reference in a new issue