eslint: add a new rule to enforce declare _serviceBrand: undefined (#165396)

This commit is contained in:
Johannes Rieken 2022-11-03 18:32:37 +01:00 committed by GitHub
parent bc1088e8a5
commit 98546b2287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View file

@ -0,0 +1,27 @@
/*---------------------------------------------------------------------------------------------
* 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 DeclareServiceBrand implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
fixable: 'code'
};
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
return {
['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: any) => {
return context.report({
node,
message: `The '_serviceBrand'-property should not have a value`,
fix: (fixer) => {
return fixer.replaceText(node, 'declare _serviceBrand: undefined;')
}
});
}
};
}
};

View file

@ -72,6 +72,7 @@
"local/code-no-nls-in-standalone-editor": "warn",
"local/code-no-standalone-editor": "warn",
"local/code-no-unexternalized-strings": "warn",
"local/code-declare-service-brand": "warn",
"local/code-layering": [
"warn",
{
@ -331,7 +332,7 @@
"vs/base/parts/*/~",
"vs/platform/*/~",
"tas-client-umd", // node module allowed even in /common/
"@microsoft/1ds-core-js",// node module allowed even in /common/
"@microsoft/1ds-core-js", // node module allowed even in /common/
"@microsoft/1ds-post-js" // node module allowed even in /common/
]
},

View file

@ -35,7 +35,7 @@ type AuthenticationProviderOption = IQuickPickItem & { provider: IAuthentication
const configureContinueOnPreference = { iconClass: Codicon.settingsGear.classNames, tooltip: localize('configure continue on', 'Configure this preference in settings') };
export class EditSessionsWorkbenchService extends Disposable implements IEditSessionsStorageService {
_serviceBrand = undefined;
declare _serviceBrand: undefined;
private serverConfiguration = this.productService['editSessions.store'];
private storeClient: EditSessionsStoreClient | undefined;