Skip to content

Commit

Permalink
eslint: add a new rule to enforce declare _serviceBrand: undefined (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken authored Nov 3, 2022
1 parent bc1088e commit 98546b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .eslintplugin/code-declare-service-brand.ts
Original file line number Diff line number Diff line change
@@ -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;')
}
});
}
};
}
};
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
{
Expand Down Expand Up @@ -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/
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 98546b2

Please sign in to comment.