Skip to content

Commit 98546b2

Browse files
authored
eslint: add a new rule to enforce declare _serviceBrand: undefined (microsoft#165396)
1 parent bc1088e commit 98546b2

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as eslint from 'eslint';
7+
8+
export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
9+
10+
readonly meta: eslint.Rule.RuleMetaData = {
11+
fixable: 'code'
12+
};
13+
14+
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
15+
return {
16+
['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: any) => {
17+
return context.report({
18+
node,
19+
message: `The '_serviceBrand'-property should not have a value`,
20+
fix: (fixer) => {
21+
return fixer.replaceText(node, 'declare _serviceBrand: undefined;')
22+
}
23+
});
24+
}
25+
};
26+
}
27+
};

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"local/code-no-nls-in-standalone-editor": "warn",
7373
"local/code-no-standalone-editor": "warn",
7474
"local/code-no-unexternalized-strings": "warn",
75+
"local/code-declare-service-brand": "warn",
7576
"local/code-layering": [
7677
"warn",
7778
{
@@ -331,7 +332,7 @@
331332
"vs/base/parts/*/~",
332333
"vs/platform/*/~",
333334
"tas-client-umd", // node module allowed even in /common/
334-
"@microsoft/1ds-core-js",// node module allowed even in /common/
335+
"@microsoft/1ds-core-js", // node module allowed even in /common/
335336
"@microsoft/1ds-post-js" // node module allowed even in /common/
336337
]
337338
},

src/vs/workbench/contrib/editSessions/browser/editSessionsStorageService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type AuthenticationProviderOption = IQuickPickItem & { provider: IAuthentication
3535
const configureContinueOnPreference = { iconClass: Codicon.settingsGear.classNames, tooltip: localize('configure continue on', 'Configure this preference in settings') };
3636
export class EditSessionsWorkbenchService extends Disposable implements IEditSessionsStorageService {
3737

38-
_serviceBrand = undefined;
38+
declare _serviceBrand: undefined;
3939

4040
private serverConfiguration = this.productService['editSessions.store'];
4141
private storeClient: EditSessionsStoreClient | undefined;

0 commit comments

Comments
 (0)